From: Alexandre Emsenhuber Date: Fri, 12 Jun 2009 09:17:21 +0000 (+0000) Subject: Fixes for r51774: X-Git-Tag: 1.31.0-rc.0~41408 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=8f79397a7cdd5cc4f7f91b43778a5eed5c51e4cb;p=lhc%2Fweb%2Fwiklou.git Fixes for r51774: * declare $ip and $ipchain so that it doesn't throw notices and warnings * don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header * fix logic when throwing the exception: throw it when there's no IP --- diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index dc30d0ef30..fe31376eb6 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -74,6 +74,9 @@ function wfGetIP() { return $wgIP; } + $ipchain = array(); + $ip = false; + /* collect the originating ips */ # Client connecting to this webserver if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { @@ -82,8 +85,6 @@ function wfGetIP() { if( $ip ) { $ipchain[] = $ip; } - - $ip = false; # Append XFF on to $ipchain $forwardedFor = wfGetForwardedFor(); @@ -108,7 +109,7 @@ function wfGetIP() { } } - if( $ip ) { + if( !$ip ) { throw new MWException( "Unable to determine IP" ); }