r48219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48218‎ | r48219 | r48220 >
Date:12:39, 9 March 2009
Author:werdna
Status:ok
Tags:
Comment:
New ip_in_range function
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -306,6 +306,7 @@
307307 'rmwhitespace' => 'funcRMWhitespace',
308308 'count' => 'funcCount',
309309 'rcount' => 'funcRCount',
 310+ 'ip_in_range' => 'funcIPInRange',
310311 );
311312
312313 // Order is important. The punctuation-matching regex requires that
@@ -991,6 +992,18 @@
992993 return new AFPData( AFPData::DInt, $count );
993994 }
994995
 996+ protected function funcIPInRange( $args ) {
 997+ if( count( $args ) < 2 )
 998+ throw new AFPExpection( "No params passed to ".__METHOD__ );
 999+
 1000+ $ip = $args[0]->toString();
 1001+ $range = $args[1]->toString();
 1002+
 1003+ $result = IP::isInRange( $ip, $range );
 1004+
 1005+ return new AFPData( AFPData::DBool, $result );
 1006+ }
 1007+
9951008 protected function funcCCNorm( $args ) {
9961009 if( count( $args ) < 1 )
9971010 throw new AFPExpection( "No params passed to ".__METHOD__ );

Status & tagging log