mirror of
https://github.com/torrentpier/torrentpier-lts.git
synced 2025-02-28 15:10:54 +03:00
parent
b455105741
commit
e5b5ea3a26
@ -139,19 +139,24 @@ if ($bb_cfg['client_ban']['enabled'])
|
||||
// IP
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// 'ip' query handling
|
||||
if (!$bb_cfg['ignore_reported_ip'] && isset($_GET['ip']) && $ip !== $_GET['ip'])
|
||||
{
|
||||
if (!$bb_cfg['verify_reported_ip'] && isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
||||
if (!$bb_cfg['verify_reported_ip'])
|
||||
{
|
||||
$ip = $_GET['ip'];
|
||||
}
|
||||
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))
|
||||
{
|
||||
foreach ($matches[0] as $x_ip)
|
||||
{
|
||||
$x_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
|
||||
if ($x_ip === $_GET['ip'])
|
||||
{
|
||||
$filteredIp = filter_var($x_ip, FILTER_VALIDATE_IP);
|
||||
if ($filteredIp !== false && ($bb_cfg['allow_internal_ip'] || !filter_var($filteredIp, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)))
|
||||
if (!$bb_cfg['allow_internal_ip'] && preg_match("#(127\.([0-9]{1,3}\.){2}[0-9]{1,3}|10\.([0-9]{1,3}\.){2}[0-9]{1,3}|172\.[123][0-9]\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3})#", $x_ip))
|
||||
{
|
||||
$ip = $filteredIp;
|
||||
break;
|
||||
}
|
||||
$ip = $x_ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user