mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 05:20:30 +03:00
Fix invalid algorithm in setting the value for a visitor's IP
This commit is contained in:
parent
f105a0b5d2
commit
d8a63bc2cd
@ -580,11 +580,10 @@ function get_remote_host()
|
|||||||
$has_proxy = isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
$has_proxy = isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||||
&& $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR'];
|
&& $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR'];
|
||||||
if ($has_proxy) {
|
if ($has_proxy) {
|
||||||
$count = 0;
|
$ips = explode(' ', $_SERVER['HTTP_X_FORWARDED_FOR'], 2);
|
||||||
$ext_addr = preg_replace('/^([^,]+)(,\s.+)?/', '\\1', $_SERVER['HTTP_X_FORWARDED_FOR'], -1, $count);
|
$ext_addr = (count($ips) > 1)
|
||||||
if ($count > 1) {
|
? $ips[0] . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')'
|
||||||
$ext_addr = $ext_addr . ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')';
|
: $ips[0];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $ext_addr;
|
return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $ext_addr;
|
||||||
|
Loading…
Reference in New Issue
Block a user