Quasi-Spam Filter Plugin
A reference implementation of a Spam filter plugin
This is a reference implementation of a Spam filter plugin and mainly targetted to spam filter developpers as well as actual users. This plugin allows you to easily customize your filtering policy and your reaction to comment & trackback spammers.
HOW TO CUSTOMIZE: Filtering Policy
The default policy of this plugin is to drop comments and trackback pings which have H1 and A elements. If you want to change your target, you can customize $COMMENT_PATTERN and $TBPING_PATTERN variable.
# Set your spam pattern our $COMMENT_PATTERN = '<h1>|<a\s'; # H1 or A elements our $TBPING_PATTERN = '<h1>|<a\s'; # H1 or A elements
You can change the is_comment_spam and is_tbping_spam subroutines if you want more clever mechanisms for filtering.
sub is_comment_spam {
my $comment = shift;
return ($comment->text =~ /$COMMENT_PATTERN/i);
}
sub is_tbping_spam {
my $tbping = shift;
return ($tbping->excerpt =~ /$TBPING_PATTERN/i);
}
HOW TO CUSTOMIZE: Reaction to Commment Spammers
The default reaction to comment spammers is "NOT TO TELL SPAMMERS WHETHER COMMENT SUBMISSIONS ARE SUCCEEDED OR NOT, BUT KILL THEM" reaction :) The Quasi-Spam Filter Plugin supports the following six reactions to comment spammers. And you can choose one of them by setting $COMMENT_METHOD variable.
- CommentFilter
- This method does not tell spammers whether comment submissions are succeeded or not.
- CommentThrottleFilter
- This method tells spammers that their comment submissions are failed by MT throttling mechanism.
- CommentError (Default)
- Just outputs a simple "Spam Comment!" message. This is the most light-weight solution.
- CommentLongError
- Outputs a kind error message by using "Comment Error Template".
- CommentRedirect
- Redirects to the URL specified by $URL variable. You can leed spammers to "Enlightment" site, or "Bizarre" site, or whatever else.
- CommentEvilRedirect
- Redirects to the URL specified by the URL field of spammers. If no URL is filled, redirects to the URL specified by $URL variable.
If you want to stop filtering spam comments, just set anything else (ex. '') to $COMMENT_METHOD variable.
HOW TO CUSTOMIZE: Reaction to Trackback Spammers
The default reaction to trackback spammers is "NOT TO TELL SPAMMERS WHETHER TRACKBACK PINGS ARE SUCCEEDED OR NOT, BUT KILL THEM" reaction :) The Quasi-Spam Filter Plugin supports the following three reactions to trackback spammers. And you can choose one of them by setting $TBPING_METHOD variable.
- TBPingFilter
- This method does not tell spammers whether trackback pings are succeeded or not.
- TBPingThrottleFilter
- This method tells spammers that their trackback pings are failed by MT throttling mechanism.
- TBPingError (Default)
- Just outputs a simple "TBPing Comment!" message. This is the most light-weight solution.
If you want to stop filtering spam TB pings, just set anything else (ex. '') to $TBPPING_METHOD variable.
SEE ALSO
Ogawa::Memoranda: Quasi-Spam Filter Plugin (Totally in Japanese)
LICENSE
This code is released under the Artistic License. The terms of the Artistic License are described at http://www.perl.com/language/misc/Artistic.html.
AUTHOR & COPYRIGHT
Copyright 2004, Hirotaka Ogawa (hirotaka.ogawa at gmail.com)
Comments
Hello:
Does this work on MT 2.661? I'm getting some script errors when I tried to test this...errors within an mt-comments.cgi file?
Posted by: umairsalam | February 18, 2005 12:50 PM
Hi, yes I heard this plugin worked on MT 2.661 as well.
You need to set $COMMENT_METHOD to 'CommentError', or 'CommentLongError', or 'CommentRedirect', and set $TBPING_METHOD to 'TBPingError'. Because 'XXXFilter' methods requires MT3.1 APIs.
Posted by: (o) | February 18, 2005 01:28 PM
nice, i've made this modification and i'll try it out and let you know the outcome ;) thank you!
Posted by: umairsalam | February 20, 2005 06:46 AM