Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -826,6 +826,9 @@ |
827 | 827 | $url: string value as output (out parameter, can modify) |
828 | 828 | $query: query options passed to Title::getInternalURL() |
829 | 829 | |
| 830 | +'GetIP': modify the ip of the current user (called only once) |
| 831 | +&$ip: string holding the ip as determined so far |
| 832 | + |
830 | 833 | 'GetLinkColours': modify the CSS class of an array of page links |
831 | 834 | $linkcolour_ids: array of prefixed DB keys of the pages linked to, |
832 | 835 | indexed by page_id. |
Index: trunk/phase3/includes/ProxyTools.php |
— | — | @@ -68,15 +68,15 @@ |
69 | 69 | * @return string |
70 | 70 | */ |
71 | 71 | function wfGetIP() { |
72 | | - global $wgIP, $wgUsePrivateIPs, $wgCommandLineMode; |
| 72 | + global $wgUsePrivateIPs, $wgCommandLineMode; |
| 73 | + static $ip = false; |
73 | 74 | |
74 | 75 | # Return cached result |
75 | | - if ( !empty( $wgIP ) ) { |
76 | | - return $wgIP; |
| 76 | + if ( !empty( $ip ) ) { |
| 77 | + return $ip; |
77 | 78 | } |
78 | 79 | |
79 | 80 | $ipchain = array(); |
80 | | - $ip = false; |
81 | 81 | |
82 | 82 | /* collect the originating ips */ |
83 | 83 | # Client connecting to this webserver |
— | — | @@ -112,12 +112,14 @@ |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
| 116 | + # Allow extensions to improve our guess |
| 117 | + wfRunHooks( 'GetIP', array( &$ip ) ); |
| 118 | + |
116 | 119 | if( !$ip ) { |
117 | 120 | throw new MWException( "Unable to determine IP" ); |
118 | 121 | } |
119 | 122 | |
120 | 123 | wfDebug( "IP: $ip\n" ); |
121 | | - $wgIP = $ip; |
122 | 124 | return $ip; |
123 | 125 | } |
124 | 126 | |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -182,7 +182,6 @@ |
183 | 183 | date_default_timezone_set( date_default_timezone_get() ); |
184 | 184 | wfRestoreWarnings(); |
185 | 185 | |
186 | | -$wgIP = false; # Load on demand |
187 | 186 | # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor |
188 | 187 | $wgRequest = new WebRequest; |
189 | 188 | |