From 308867d25c6fbbfe1f4a2ff0e70e7efd8e376a45 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 18 Sep 2008 14:27:26 +0000 Subject: [PATCH] Fix count function --- AbuseFilter.parser.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php index 7a6a7af6e..78547ac05 100644 --- a/AbuseFilter.parser.php +++ b/AbuseFilter.parser.php @@ -833,6 +833,8 @@ class AbuseFilterParser { protected function funcCount( $args ) { if( count( $args ) < 1 ) throw new AFPExpection( "No params passed to ".__METHOD__ ); + + $offset = -1; if (count($args) == 1) { $count = count( explode( ",", $args[0]->toString() ) ); @@ -841,7 +843,7 @@ class AbuseFilterParser { $haystack = $args[1]->toString(); $count = 0; - while ( ($offset = strpos( $haystack, $needle, $offset )) !== false ) { + while ( ($offset = strpos( $haystack, $needle, $offset + 1 )) !== false ) { $count++; } }