]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/ProxyTools.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / ProxyTools.php
index 5719e3e8d6a179bcd3b5c50055f11af7bf2e42fe..13c199654d606c9943179d0eaf5d56d47341449b 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
  * Functions for dealing with proxies
+ *
  * @file
  */
 
@@ -67,15 +68,15 @@ function wfGetAgent() {
  * @return string
  */
 function wfGetIP() {
-       global $wgIP, $wgUsePrivateIPs, $wgCommandLineMode;
+       global $wgUsePrivateIPs, $wgCommandLineMode;
+       static $ip = false;
 
        # Return cached result
-       if ( !empty( $wgIP ) ) {
-               return $wgIP;
+       if ( !empty( $ip ) ) {
+               return $ip;
        }
 
        $ipchain = array();
-       $ip = false;
 
        /* collect the originating ips */
        # Client connecting to this webserver
@@ -111,12 +112,14 @@ function wfGetIP() {
                }
        }
 
+       # Allow extensions to improve our guess
+       wfRunHooks( 'GetIP', array( &$ip ) );
+
        if( !$ip ) {
                throw new MWException( "Unable to determine IP" );
        }
 
        wfDebug( "IP: $ip\n" );
-       $wgIP = $ip;
        return $ip;
 }
 
@@ -183,9 +186,12 @@ function wfProxyCheck() {
 
 /**
  * Convert a network specification in CIDR notation to an integer network and a number of bits
+ *
+ * @deprecated Call IP::parseCIDR() directly, will be removed in 1.19
  * @return array(string, int)
  */
 function wfParseCIDR( $range ) {
+       wfDeprecated( __FUNCTION__ );
        return IP::parseCIDR( $range );
 }