Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
f255d654
Commit
f255d654
authored
Mar 02, 2020
by
Dominik Hebeler
Browse files
added default useragent
parent
ce7a6c1f
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Middleware/UserAgentMaster.php
View file @
f255d654
...
...
@@ -34,10 +34,13 @@ class UserAgentMaster
}
else
if
(
$agent
->
isPhone
())
{
$device
=
"mobile"
;
}
// Push an entry to a list in Redis
// App\Console\Commands\SaveUseragents.php is called regulary to save the list into a sqlite database
Redis
::
rpush
(
'useragents'
,
json_encode
([
"platform"
=>
$agent
->
platform
(),
"browser"
=>
$agent
->
browser
(),
"device"
=>
$device
,
"useragent"
=>
$_SERVER
[
'HTTP_USER_AGENT'
]]));
Redis
::
expire
(
'useragents'
,
301
);
if
(
!
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
]))
{
// Push an entry to a list in Redis
// App\Console\Commands\SaveUseragents.php is called regulary to save the list into a sqlite database
Redis
::
rpush
(
'useragents'
,
json_encode
([
"platform"
=>
$agent
->
platform
(),
"browser"
=>
$agent
->
browser
(),
"device"
=>
$device
,
"useragent"
=>
$_SERVER
[
'HTTP_USER_AGENT'
]]));
Redis
::
expire
(
'useragents'
,
301
);
}
// Try to retrieve a random User-Agent of the same category from the sqlite database
$newAgent
=
\
App\UserAgent
::
where
(
"platform"
,
$agent
->
platform
())
...
...
public/index.php
View file @
f255d654
...
...
@@ -16,7 +16,10 @@ if (isset($_SERVER["HTTP_FORWARDED"]) && isset($_SERVER["HTTP_X_FORWARDED_FOR"])
unset
(
$_SERVER
[
"HTTP_FORWARDED"
]);
}
$_SERVER
[
"AGENT"
]
=
$_SERVER
[
"HTTP_USER_AGENT"
];
$_SERVER
[
"AGENT"
]
=
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
;
if
(
!
empty
(
$_SERVER
[
"HTTP_USER_AGENT"
]))
{
$_SERVER
[
"AGENT"
]
=
$_SERVER
[
"HTTP_USER_AGENT"
];
}
/*
|--------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment