[Howto] Advanced Spam Fighting with Regular Expressions
-
The following changes assume that you have Antispam Bee version 2.5.7 installed.
Since a few days, more and more spam comments managed to get around ASB, because of changing IP, email and web addresses. So I updated the _is_regexp_spam(.) function of my antispam_bee.php to target the common denominator of all those spammers: certain keywords they use in the ‘author’ field.
I extended this (antispam_bee.php, lines 1395-1405):
/* Regexp */ $patterns = array( 0 => array( 'host' => '^(www\.)?\d+\w+\.com$', 'body' => '^\w+\s\d+$', 'email' => '@gmail.com$' ), 1 => array( 'body' => '\<\!.+?mfunc.+?\>' ) );
to this (my wife has a fashion oriented blog):
/* Regexp */ $patterns = array( 0 => array( 'host' => '^(www\.)?\d+\w+\.com$', 'body' => '^\w+\s\d+$', 'email' => '@gmail.com$' ), 1 => array( 'body' => '\<\!.+?mfunc.+?\>' ), 2 => array( 'author' => 'moncler|north face|vuitton|handbag|burberry|outlet|dress|プラダ|maillot' ), 3 => array( 'ip' => '^27\.159\.|^110\.86\.' ) );
Additionally, I had to change line 1444 from this:
if ( preg_match('|' .$regexp. '|isu', $comment[$field]) ) {
to this:
if ( preg_match('/' .$regexp. '/isu', $comment[$field]) ) {
(because the RegEx pipe symbol I use in my expression says this-or-this-or-this for the my new author expression, and I can’t have them in the preg_match string as separators)I hope this is also useful for anybody else. ??
Greetings,
Simon
- The topic ‘[Howto] Advanced Spam Fighting with Regular Expressions’ is closed to new replies.