mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
Merge branch '3.3.x'
This commit is contained in:
@@ -252,8 +252,7 @@ class session
|
||||
$ips = explode(' ', $this->forwarded_for);
|
||||
foreach ($ips as $ip)
|
||||
{
|
||||
// check IPv4 first, the IPv6 is hopefully only going to be used very seldom
|
||||
if (!empty($ip) && !preg_match(get_preg_expression('ipv4'), $ip) && !preg_match(get_preg_expression('ipv6'), $ip))
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP))
|
||||
{
|
||||
// contains invalid data, don't use the forwarded for header
|
||||
$this->forwarded_for = '';
|
||||
@@ -313,49 +312,17 @@ class session
|
||||
|
||||
foreach ($ips as $ip)
|
||||
{
|
||||
if (function_exists('phpbb_ip_normalise'))
|
||||
// Normalise IP address
|
||||
$ip = phpbb_ip_normalise($ip);
|
||||
|
||||
if ($ip === false)
|
||||
{
|
||||
// Normalise IP address
|
||||
$ip = phpbb_ip_normalise($ip);
|
||||
|
||||
if (empty($ip))
|
||||
{
|
||||
// IP address is invalid.
|
||||
break;
|
||||
}
|
||||
|
||||
// IP address is valid.
|
||||
$this->ip = $ip;
|
||||
|
||||
// Skip legacy code.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match(get_preg_expression('ipv4'), $ip))
|
||||
{
|
||||
$this->ip = $ip;
|
||||
}
|
||||
else if (preg_match(get_preg_expression('ipv6'), $ip))
|
||||
{
|
||||
// Quick check for IPv4-mapped address in IPv6
|
||||
if (stripos($ip, '::ffff:') === 0)
|
||||
{
|
||||
$ipv4 = substr($ip, 7);
|
||||
|
||||
if (preg_match(get_preg_expression('ipv4'), $ipv4))
|
||||
{
|
||||
$ip = $ipv4;
|
||||
}
|
||||
}
|
||||
|
||||
$this->ip = $ip;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want to use the last valid address in the chain
|
||||
// Leave foreach loop when address is invalid
|
||||
// IP address is invalid.
|
||||
break;
|
||||
}
|
||||
|
||||
// IP address is valid.
|
||||
$this->ip = $ip;
|
||||
}
|
||||
|
||||
$this->load = false;
|
||||
|
Reference in New Issue
Block a user