diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2019-11-01 22:01:26 +0100 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2019-11-01 22:01:26 +0100 |
| commit | 912eb28223c937a679bd2c78ea139033f7796b26 (patch) | |
| tree | d7b119bb5627d0814a0177070bf12ba15c939f15 /phpBB/phpbb | |
| parent | ce35aa8b0b90870608a5b0782a36c6aedad8c7e4 (diff) | |
| parent | 00682db8a625e40f720c513c72267395c4354766 (diff) | |
| download | forums-912eb28223c937a679bd2c78ea139033f7796b26.tar forums-912eb28223c937a679bd2c78ea139033f7796b26.tar.gz forums-912eb28223c937a679bd2c78ea139033f7796b26.tar.bz2 forums-912eb28223c937a679bd2c78ea139033f7796b26.tar.xz forums-912eb28223c937a679bd2c78ea139033f7796b26.zip | |
Merge pull request #5718 from rubencm/ticket/16189
[ticket/16189] Deprecate inet_ntop and inet_pton wrappers
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/session.php | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index ba200f38df..7c76c08b73 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -250,8 +250,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 = ''; @@ -311,49 +310,17 @@ class session foreach ($ips as $ip) { - if (function_exists('phpbb_ip_normalise')) - { - // Normalise IP address - $ip = phpbb_ip_normalise($ip); - - if (empty($ip)) - { - // IP address is invalid. - break; - } - - // IP address is valid. - $this->ip = $ip; + // Normalise IP address + $ip = phpbb_ip_normalise($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)) + if ($ip === false) { - // 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; |
