Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -302,6 +302,7 @@ |
303 | 303 | 'count' => 'funcCount', |
304 | 304 | 'rcount' => 'funcRCount', |
305 | 305 | 'ip_in_range' => 'funcIPInRange', |
| 306 | + 'contains_any' => 'funcContainsAny', |
306 | 307 | ); |
307 | 308 | |
308 | 309 | // Order is important. The punctuation-matching regex requires that |
— | — | @@ -1140,6 +1141,38 @@ |
1141 | 1142 | return new AFPData( AFPData::DString, $s ); |
1142 | 1143 | } |
1143 | 1144 | |
| 1145 | + protected function funcContainsAny( $args ) { |
| 1146 | + if (count( $args ) < 2 ) { |
| 1147 | + throw new AFPException( "Not enough params to ".__METHOD__ ); |
| 1148 | + } |
| 1149 | + |
| 1150 | + $s = array_shift( $args ); |
| 1151 | + $s = $s->toString(); |
| 1152 | + |
| 1153 | + $searchStrings = array(); |
| 1154 | + |
| 1155 | + foreach( $args as $arg ) { |
| 1156 | + $searchStrings[] = $arg->toString(); |
| 1157 | + } |
| 1158 | + |
| 1159 | + if ( function_exists( 'fss_prep_search' ) ) { |
| 1160 | + $fss = fss_prep_search( $searchStrings ); |
| 1161 | + $result = fss_exec_search( $fss, $s ); |
| 1162 | + |
| 1163 | + $ok = is_array($result); |
| 1164 | + } else { |
| 1165 | + $ok = false; |
| 1166 | + foreach( $searchStrings as $needle ) { |
| 1167 | + if (in_string( $needle, $s ) ) { |
| 1168 | + $ok = true; |
| 1169 | + break; |
| 1170 | + } |
| 1171 | + } |
| 1172 | + } |
| 1173 | + |
| 1174 | + return new AFPData( AFPData::DBool, $ok ); |
| 1175 | + } |
| 1176 | + |
1144 | 1177 | protected function ccnorm( $s ) { |
1145 | 1178 | if (!class_exists( 'AntiSpoof' ) ) { |
1146 | 1179 | return $s; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -65,6 +65,7 @@ |
66 | 66 | 'rmwhitespace(text)' => 'rmwhitespace', |
67 | 67 | 'rmspecials(text)' => 'rmspecials', |
68 | 68 | 'ip_in_range(ip, range)' => 'ip_in_range', |
| 69 | + 'contains_any(haystack,needle1,needle2,needle3)' => 'contains-any', |
69 | 70 | ), |
70 | 71 | 'vars' => array( |
71 | 72 | 'accountname' => 'accountname', |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -246,6 +246,7 @@ |
247 | 247 | 'abusefilter-edit-builder-funcs-rmwhitespace' => 'Remove whitespace', |
248 | 248 | 'abusefilter-edit-builder-funcs-rmspecials' => 'Remove special characters', |
249 | 249 | 'abusefilter-edit-builder-funcs-ip_in_range' => 'Is IP in range?', |
| 250 | + 'abusefilter-edit-builder-funcs-contains-any' => 'Search string for multiple substrings', |
250 | 251 | 'abusefilter-edit-builder-group-vars' => 'Variables', |
251 | 252 | 'abusefilter-edit-builder-vars-accountname' => 'Account name (on account creation)', |
252 | 253 | 'abusefilter-edit-builder-vars-action' => 'Action', |