log IP for API auth errors
This commit is contained in:
26
lib/util.php
26
lib/util.php
@@ -1490,4 +1490,28 @@ function common_shorten_url($long_url)
|
||||
curl_close($curlh);
|
||||
|
||||
return $short_url;
|
||||
}
|
||||
}
|
||||
|
||||
function common_client_ip()
|
||||
{
|
||||
if (!isset($_SERVER) || !array_key_exists('REQUEST_METHOD', $_SERVER)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
|
||||
if ($_SERVER['HTTP_CLIENT_IP']) {
|
||||
$proxy = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else {
|
||||
$proxy = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
if ($_SERVER['HTTP_CLIENT_IP']) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
}
|
||||
|
||||
return array($ip, $proxy);
|
||||
}
|
||||
|
Reference in New Issue
Block a user