This allows extensions to "make mediawiki ignore ips completely", as requested earlier today in #mediawiki
$url: string value as output (out parameter, can modify)
$query: query options passed to Title::getInternalURL()
+'GetIP': modify the ip of the current user (called only once)
+&$ip: string holding the ip as determined so far
+
'GetLinkColours': modify the CSS class of an array of page links
$linkcolour_ids: array of prefixed DB keys of the pages linked to,
indexed by page_id.
* @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
}
}
+ # 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;
}
date_default_timezone_set( date_default_timezone_get() );
wfRestoreWarnings();
-$wgIP = false; # Load on demand
# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
$wgRequest = new WebRequest;