From: Tim Starling Date: Thu, 31 Mar 2005 10:39:15 +0000 (+0000) Subject: oops, committed from wrong branch, this is the fixed version X-Git-Tag: 1.5.0alpha1~445 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=1b19057db32d671126659df5f1377148b5fd8514;p=lhc%2Fweb%2Fwiklou.git oops, committed from wrong branch, this is the fixed version --- diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index cf19119571..0978621d91 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -32,12 +32,10 @@ function wfGetIP() if ( count( $trustedProxies ) ) { # Append XFF on to $ipchain if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { - $xff = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ); - for ( $i = 1; $i <= count( $xff ); $i++ ) { - $ipchain[$i] = trim( $xff[count($xff) - $i ); - } + $xff = array_map( 'trim', explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ) ); + $xff = array_reverse( $xff ); + $ipchain = array_merge( $ipchain, $xff ); } - var_dump( $ipchain ); # Step through XFF list and find the last address in the list which is a trusted server # Set $ip to the IP address given by that trusted server, unless the address is not sensible (e.g. private) foreach ( $ipchain as $i => $curIP ) {