From: Tim Starling Date: Tue, 6 Dec 2005 13:24:47 +0000 (+0000) Subject: Lazy initialisation of wgProxyList, no flip required X-Git-Tag: 1.6.0~1005 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=e03fdc5ac5be1cb2e43f33885580c773289b2150;p=lhc%2Fweb%2Fwiklou.git Lazy initialisation of wgProxyList, no flip required --- diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index 991ec36874..dfddd4caf1 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -175,4 +175,38 @@ function wfParseCIDR( $range ) { return array( $network, $bits ); } +/** + * Check if an IP address is in the local proxy list + */ +function wfIsLocallyBlockedProxy( $ip ) { + global $wgProxyList; + $fname = 'wfIsLocallyBlockedProxy'; + + if ( !$wgProxyList ) { + return false; + } + wfProfileIn( $fname ); + + if ( !is_array( $wgProxyList ) ) { + # Load from the specified file + $wgProxyList = array_map( 'trim', file( $wgProxyList ) ); + } + + if ( !is_array( $wgProxyList ) ) { + $ret = false; + } elseif ( array_search( $ip, $wgProxyList ) !== false ) { + $ret = true; + } elseif ( array_key_exists( $ip, $wgProxyList ) ) { + # Old-style flipped proxy list + $ret = true; + } else { + $ret = false; + } + wfProfileOut( $fname ); + return $ret; +} + + + + ?>