Index: trunk/phase3/includes/ProxyTools.php |
— | — | @@ -175,4 +175,38 @@ |
176 | 176 | return array( $network, $bits ); |
177 | 177 | } |
178 | 178 | |
| 179 | +/** |
| 180 | + * Check if an IP address is in the local proxy list |
| 181 | + */ |
| 182 | +function wfIsLocallyBlockedProxy( $ip ) { |
| 183 | + global $wgProxyList; |
| 184 | + $fname = 'wfIsLocallyBlockedProxy'; |
| 185 | + |
| 186 | + if ( !$wgProxyList ) { |
| 187 | + return false; |
| 188 | + } |
| 189 | + wfProfileIn( $fname ); |
| 190 | + |
| 191 | + if ( !is_array( $wgProxyList ) ) { |
| 192 | + # Load from the specified file |
| 193 | + $wgProxyList = array_map( 'trim', file( $wgProxyList ) ); |
| 194 | + } |
| 195 | + |
| 196 | + if ( !is_array( $wgProxyList ) ) { |
| 197 | + $ret = false; |
| 198 | + } elseif ( array_search( $ip, $wgProxyList ) !== false ) { |
| 199 | + $ret = true; |
| 200 | + } elseif ( array_key_exists( $ip, $wgProxyList ) ) { |
| 201 | + # Old-style flipped proxy list |
| 202 | + $ret = true; |
| 203 | + } else { |
| 204 | + $ret = false; |
| 205 | + } |
| 206 | + wfProfileOut( $fname ); |
| 207 | + return $ret; |
| 208 | +} |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
179 | 213 | ?> |