Speed up CIDR matching from $wgSquidServersNoPurge
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index ed99aa9..91724dd 100644 (file)
@@ -1726,10 +1726,7 @@ function wfMsgExt( $key, $options ) {
                }
 
                if ( $parseInline ) {
-                       $m = array();
-                       if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
-                               $string = $m[1];
-                       }
+                       $string = Parser::stripOuterParagraph( $string );
                }
        } elseif ( in_array( 'parsemag', $options, true ) ) {
                $string = $messageCache->transform( $string,
@@ -4151,39 +4148,23 @@ function wfGetIP() {
  * Checks if an IP is a trusted proxy provider.
  * Useful to tell if X-Forwarded-For data is possibly bogus.
  * Squid cache servers for the site are whitelisted.
+ * @deprecated Since 1.24, use IP::isTrustedProxy()
  *
  * @param string $ip
  * @return bool
  */
 function wfIsTrustedProxy( $ip ) {
-       $trusted = wfIsConfiguredProxy( $ip );
-       wfRunHooks( 'IsTrustedProxy', array( &$ip, &$trusted ) );
-       return $trusted;
+       return IP::isTrustedProxy( $ip );
 }
 
 /**
  * Checks if an IP matches a proxy we've configured.
+ * @deprecated Since 1.24, use IP::isConfiguredProxy()
  *
  * @param string $ip
  * @return bool
  * @since 1.23 Supports CIDR ranges in $wgSquidServersNoPurge
  */
 function wfIsConfiguredProxy( $ip ) {
-       global $wgSquidServers, $wgSquidServersNoPurge;
-
-       // quick check of known proxy servers
-       $trusted = in_array( $ip, $wgSquidServers )
-               || in_array( $ip, $wgSquidServersNoPurge );
-
-       if ( !$trusted ) {
-               // slightly slower check to see if the ip is listed directly or in a CIDR
-               // block in $wgSquidServersNoPurge
-               foreach ( $wgSquidServersNoPurge as $block ) {
-                       if ( strpos( $block, '/' ) !== false && IP::isInRange( $ip, $block ) ) {
-                               $trusted = true;
-                               break;
-                       }
-               }
-       }
-       return $trusted;
+       return IP::isTrustedProxy( $ip );
 }