|
@@ 304-312 (lines=9) @@
|
| 301 |
|
// Make sure it's in a valid range... |
| 302 |
|
if (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $ip) != 0 && preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) == 0) |
| 303 |
|
{ |
| 304 |
|
if (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
| 305 |
|
{ |
| 306 |
|
$_SERVER[$proxyIPheader] = preg_replace('~^::ffff:(\d+\.\d+\.\d+\.\d+)~', '\1', $_SERVER[$proxyIPheader]); |
| 307 |
|
|
| 308 |
|
// Just incase we have a legacy IPv4 address. |
| 309 |
|
// @ TODO: Convert to IPv6. |
| 310 |
|
if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
| 311 |
|
continue; |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
continue; |
| 315 |
|
} |
|
@@ 325-333 (lines=9) @@
|
| 322 |
|
// Otherwise just use the only one. |
| 323 |
|
elseif (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER[$proxyIPheader]) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) != 0) |
| 324 |
|
$_SERVER['BAN_CHECK_IP'] = $_SERVER[$proxyIPheader]; |
| 325 |
|
elseif (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
| 326 |
|
{ |
| 327 |
|
$_SERVER[$proxyIPheader] = preg_replace('~^::ffff:(\d+\.\d+\.\d+\.\d+)~', '\1', $_SERVER[$proxyIPheader]); |
| 328 |
|
|
| 329 |
|
// Just incase we have a legacy IPv4 address. |
| 330 |
|
// @ TODO: Convert to IPv6. |
| 331 |
|
if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
| 332 |
|
continue; |
| 333 |
|
} |
| 334 |
|
} |
| 335 |
|
|
| 336 |
|
// Make sure we know the URL of the current request. |