New ip_in_range function

This commit is contained in:
Andrew Garrett 2009-03-09 12:39:52 +00:00
parent 7e6b548b4c
commit 864a73e907

View file

@ -306,6 +306,7 @@ class AbuseFilterParser {
'rmwhitespace' => 'funcRMWhitespace',
'count' => 'funcCount',
'rcount' => 'funcRCount',
'ip_in_range' => 'funcIPInRange',
);
// Order is important. The punctuation-matching regex requires that
@ -991,6 +992,18 @@ class AbuseFilterParser {
return new AFPData( AFPData::DInt, $count );
}
protected function funcIPInRange( $args ) {
if( count( $args ) < 2 )
throw new AFPExpection( "No params passed to ".__METHOD__ );
$ip = $args[0]->toString();
$range = $args[1]->toString();
$result = IP::isInRange( $ip, $range );
return new AFPData( AFPData::DBool, $result );
}
protected function funcCCNorm( $args ) {
if( count( $args ) < 1 )
throw new AFPExpection( "No params passed to ".__METHOD__ );