Countering Comment Spam
It appears that my comment spammers have departed for greener pastures. Meaning that I can defer implementation of any spam counter measures. But if you're using my Standalone Trackback and Comments, then here's my defense strategy:
- Enable the comment RSS file. This will alert you to any new comments and allow you to remove them promptly. They target old posts in hopes of escaping notice.
- Eliminate outbound links from comments. Which is not as easy as I'd like it to be.
- Eliminate links from the comment body by setting ALLOWED_TAGS.
- Modify the comment entry form to reflect the new allowed tags by setting FORM.
- Modify the comment display to unlink the author's website by setting BODY_FUNCTION.
- Modify the package to add comment moderation. I was thinking about eliminating outbound links in unapproved comments and allowing them in approved comments. This would call for the addition of UNAPPROVED_TAGS and UNAPPROVED_BODY_FUNCTION member variables.
After steps 1 and 2, you should end up with a comment script something like this:
#!/usr/bin/perl
use lib '../cgi-lib';
use comment::service;
sub my_comment_display {
my ($data) = @_;
my $tmpl = <<TEMPLATE;
<div class="%s">
<div class="comment">%s</div>
<div class="nameDate">%s • %s</div>
</div>
TEMPLATE
my $i = 0;
for my $item (@$data) {
my $ts = POSIX::strftime("%d %b %Y, %I:%M %p %Z", localtime($item->{timestamp}) );
my $name = $item->{blog_name} || "Anonymous Coward";
my $nameUrl = $item->{url}
? "$name [$item->{url}]"
: $name;
printf $tmpl, ($i % 2 ? "odd" : "even"), $item->{excerpt}, $nameUrl, $ts;
$i++;
}
print "<hr>\n";
}
$input_form = <<FORM_END;
<form method="POST" target="_self">
<input type="hidden" name="%s" value="%s">
<input type="hidden" name="link" value="%s">
<input type="hidden" name="%s" value="ping">
<table>
<tr><td colspan="2"><b>Add your comment (b, i, em, p tags allowed):</b></td></tr>
<tr><td valign="top" width="1%">Name:</td>
<td valign="top" width="99%"><input type="text" name="blog_name" size="50"
maxlength="255" />
</td>
</tr>
<tr><td valign="top">Web site:</td>
<td valign="top"><input type="text" name="url" size="50" maxlength="255" /></td>
</tr>
<tr><td colspan="2">Due to a rash of comment spam, links are not allowed in comments</td>
</tr>
<tr><td valign="top" width="1%">Comment:</td>
<td valign="top">
<textarea name="excerpt" rows="7" cols="80" style="width:100%"></textarea>
</td>
</tr>
<tr><td> </td>
<td><input type="submit" name="submitComment"
value=" Submit " /> <input type="button" name="cancelComment"
value=" Cancel " onclick="window.close()" />
</td>
</table>
</form>
FORM_END
$tb = new comment::service(
BODY_FUNCTION=>\\&my_comment_display,
ALLOWED_TAGS=>"b,i,em,p",
FORM=>$input_form,
DATA_DIRECTORY=>"/Path/to/comments/directory",
RSS_FILE=>"/Path/to/comments.xml",
BLOG_NAME=>"Take the First Step",
BLOG_URL=>"http://www.ideoplex.com/blog/"
);
$tb->handle();
exit(0);