summaryrefslogtreecommitdiff
path: root/includes/ProxyTools.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
commit222b01f5169f1c7e69762e0e8904c24f78f71882 (patch)
tree8e932e12546bb991357ec48eb1638d1770be7a35 /includes/ProxyTools.php
parent00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff)
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/ProxyTools.php')
-rw-r--r--includes/ProxyTools.php29
1 files changed, 18 insertions, 11 deletions
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;
}