From 222b01f5169f1c7e69762e0e8904c24f78f71882 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 28 Jul 2010 11:52:48 +0200 Subject: update to MediaWiki 1.16.0 --- includes/ProxyTools.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'includes/ProxyTools.php') diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index 771fd577..5719e3e8 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -67,22 +67,26 @@ function wfGetAgent() { * @return string */ function wfGetIP() { - global $wgIP, $wgUsePrivateIPs; + global $wgIP, $wgUsePrivateIPs, $wgCommandLineMode; # Return cached result if ( !empty( $wgIP ) ) { return $wgIP; } + $ipchain = array(); + $ip = false; + /* collect the originating ips */ # Client connecting to this webserver if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { - $ipchain = array( IP::canonicalize( $_SERVER['REMOTE_ADDR'] ) ); - } else { - # Running on CLI? - $ipchain = array( '127.0.0.1' ); + $ip = IP::canonicalize( $_SERVER['REMOTE_ADDR'] ); + } elseif( $wgCommandLineMode ) { + $ip = '127.0.0.1'; + } + if( $ip ) { + $ipchain[] = $ip; } - $ip = $ipchain[0]; # Append XFF on to $ipchain $forwardedFor = wfGetForwardedFor(); @@ -107,6 +111,10 @@ function wfGetIP() { } } + if( !$ip ) { + throw new MWException( "Unable to determine IP" ); + } + wfDebug( "IP: $ip\n" ); $wgIP = $ip; return $ip; @@ -116,7 +124,7 @@ function wfGetIP() { * Checks if an IP is a trusted proxy providor * Useful to tell if X-Fowarded-For data is possibly bogus * Squid cache servers for the site and AOL are whitelisted - * @param string $ip + * @param $ip String * @return bool */ function wfIsTrustedProxy( $ip ) { @@ -166,7 +174,7 @@ function wfProxyCheck() { escapeshellarg( $port ), escapeshellarg( $url ) )); - exec( "php $params &>/dev/null &" ); + exec( "php $params >" . wfGetNull() . " 2>&1 &" ); } # Set MemCached key $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry ); @@ -187,12 +195,11 @@ function wfParseCIDR( $range ) { */ function wfIsLocallyBlockedProxy( $ip ) { global $wgProxyList; - $fname = 'wfIsLocallyBlockedProxy'; if ( !$wgProxyList ) { return false; } - wfProfileIn( $fname ); + wfProfileIn( __METHOD__ ); if ( !is_array( $wgProxyList ) ) { # Load from the specified file @@ -209,7 +216,7 @@ function wfIsLocallyBlockedProxy( $ip ) { } else { $ret = false; } - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); return $ret; } -- cgit v1.2.2