From e03fdc5ac5be1cb2e43f33885580c773289b2150 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 6 Dec 2005 13:24:47 +0000 Subject: [PATCH] Lazy initialisation of wgProxyList, no flip required --- includes/ProxyTools.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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; +} + + + + ?> -- 2.20.1