« Show "nofollow" bookmarklet | Main | recently_pinged_on Plugin »

Quasi-Spam Filter Plugin

A reference implementation of a Spam filter plugin

quasi-spamfilter.zip

0.10(2005.01.28): First Release
0.15(2005.02.01): Support TBPing spam filtering
0.17(2005.03.05): Support Perl 5.0
0.20(2005.04.08): Support Logging feature and refine the interfaces of spam-detection functions

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)

TrackBack

TrackBack URL for this entry:
http://as-is.net/mt/en_US/mt-tb.cgi/5

Listed below are links to weblogs that reference Quasi-Spam Filter Plugin:

» Comment and Trackback Spam from Umair's Blog
I've been getting a lot of spam lately. Makes me sick. I love the comment and tr... [Read More]

» Quasi-Spam Filter from AStarWithin
yqicmstNice! I finally defeated my comment spam a little while back but lately I... [Read More]

» New Look, More Protection from Kai's Weblog
Starting yesterday afternoon, I completed a set of upgrades and installations to... [Read More]

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?

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.

nice, i've made this modification and i'll try it out and let you know the outcome ;) thank you!

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)