From: Brion Vibber Date: Thu, 19 Apr 2007 13:33:13 +0000 (+0000) Subject: wfGetLastIPfromXFF() was clearly never tested either because it also DOESN'T FUCKING... X-Git-Tag: 1.31.0-rc.0~53360 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=6273156469f9ad8aaad5af6e3541d44454b6c4e3;p=lhc%2Fweb%2Fwiklou.git wfGetLastIPfromXFF() was clearly never tested either because it also DOESN'T FUCKING WORK and HAS NO FUCKING DOCUMENTATION and CAUSES ERRORS AND FAILURES This quick hack should make it appear to basically work, assuming it does anything useful at all. --- diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index fcd6a90186..e72a338d14 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -25,6 +25,9 @@ function wfGetForwardedFor() { } } +/** + * @todo FUCKING DOCUMENT THIS FUCKING FUNCTION + */ function wfGetLastIPfromXFF( $xff ) { if ( $xff ) { // Avoid annoyingly long xff hacks @@ -34,12 +37,12 @@ function wfGetLastIPfromXFF( $xff ) { if ( strrpos !== false ) { $last = trim( substr( $xff, $n + 1 ) ); // Make sure it is an IP - $m = preg_match('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#', $last, $last_ip4); - $n = preg_match('#:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}#', $last, $last_ip6); + $m = preg_match('#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $last); + $n = preg_match('#^:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7}$#', $last); if ( $m > 0 ) - $xff_ip = $last_ip4; + $xff_ip = $last; else if ( $n > 0 ) - $xff_ip = $last_ip6; + $xff_ip = $last; else $xff_ip = null; } else {