mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-05-11 20:21:05 +00:00
Fix an user agent resolved incorrectly
This commit is contained in:
parent
479eb560da
commit
cc41ac4a2e
|
@ -40,6 +40,10 @@ function array_get($key, $arr, $default = null) {
|
||||||
return array_key_exists($key, $arr) ? $arr[$key] : $default;
|
return array_key_exists($key, $arr) ? $arr[$key] : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function server_env_get($key) {
|
||||||
|
return array_get($key, $_SERVER, "");
|
||||||
|
}
|
||||||
|
|
||||||
function verity_integrity($data, $integrity) {
|
function verity_integrity($data, $integrity) {
|
||||||
if (strpos($integrity, 'sha384-') !== 0) {
|
if (strpos($integrity, 'sha384-') !== 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -655,15 +659,8 @@ function get_client_address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_agent() {
|
function get_user_agent() {
|
||||||
$user_agents = array("HTTP_USER_AGENT", "HTTP_X_USER_AGENT");
|
$user_agents = array_map("server_env_get", array("HTTP_X_USER_AGENT", "HTTP_USER_AGENT"));
|
||||||
foreach($user_agents as $key) {
|
return implode(", ", $user_agents);
|
||||||
if (array_key_exists($key, $_SERVER)) {
|
|
||||||
$user_agents[$key] = $_SERVER[$key];
|
|
||||||
} else {
|
|
||||||
$user_agents[$key] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return implode("", $user_agents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the user agent
|
// check the user agent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user