Feed on Posts or Comments

Site News admin on 01 Aug 2004 02:12 pm

I am sporting a tremendous woody…

That comment queue hack, is “TEH Shit.”

Total comments blocked so far: 183. Go peddle your online casinos elsewhere.
Total comments blocked so far: 187. (yes, they tried 4 while I was adding up the last batch)

Since I haven’t implemented a blacklist or all the other spam reduction methods (yet) I still get comment spam attempts that I have to deal with in the comment queue. When they dump 20-30 messages at a time it becomes tedious to deny each of those individually — the fancier SQL version may have a nice way to deal with that sort of thing but the Perl hack doesn’t didn’t.

My version of the comment queue hack has an extra subroutine to delete all the pending comments. That lets me “allow” the one legitimate comment, for instance, and then “deny” all the rest with just one click of the spiffy new button:

I’m only posting my changes, instead of the whole file, because this is a hack of a hack and I’ve only got a vague understanding of the script, so you should only muck with this if you know your way around Perl and MT.

Anywho, here’s the gist…

In sub init update the methods:

$app->add_methods (
   list => \&list,
   allow => \&allow,
   deny => \&deny,
   denyall => \&denyall,
);

In sub list add the new button:

...
require MT::Entry;

$html .= "<table>\n";
$html .= "<td><form method='post' action='".$app->uri."'>\n";
$html .= "<input type='hidden' name='__mode' value='denyall'>\n";
$html .= "<input type='submit' value='Deny All Remaining Comments'></form></td></tr>\n";
$html .= "</table>\n";

foreach my $c (@comments) {
...

Add a new subroutine:

sub denyall {
my ($app) = @_;

my $html = "<P>Whacking all pending comments!</p>";

require MT::Comment;
my @comments = MT::Comment->load ({ entry_id => '0' }) or return $html."<p>No pending comments found.</p>";
return $html."<p>No pending comments.</p>" if (!scalar (@comments));
require MT::Blog;
require MT::Entry;

foreach my $c (@comments) {
   my $e = MT::Entry->load ($c->temp_entry_id) or next;
   my $b = MT::Blog->load ($c->blog_id) or next;
   my $id = $c->id;
   my $cx = MT::Comment->load ($id) or return "Cannot find comment";
   $cx->remove or return "Error deleting comment";
   $html .= "Removed comment from ".$cx->author."<br />\n";
}

$html;

}

That should do it. Make a point of renaming the script, or otherwise protect access to it, lest the spammers start authorizing their own spam.

Total comments blocked so far: 203

Update, 5 minutes later…
Well… Son of a B!

Beth at IDblog added the exact same feature, with no extraneous code (unlike mine), mere days before I did my version.

Turns out you don’t need the extra MT::Entry and MT::Blog crap in the denyall subroutine — I suspected that but I just stopped futzing when the code was functional… I copied the “list” code and removed stuff, as opposed to copying the “deny” code and adding a loop.

5 Responses to “I am sporting a tremendous woody…”

  1. on 01 Aug 2004 at 5:08 pm 1.cavedog said …

    Tell us about your new car, already!!

  2. on 01 Aug 2004 at 7:47 pm 2.MostlyHarmless said …

    Bah! I started a post about 10 days ago but haven’t gotten back to it yet. Perhaps tonight, but I gotta get out of the house for a bit first.

    Preview of exciting posts to come:
    * Amish Who in the What now?
    * Look at that S-Car go!
    * Pod Person

  3. on 04 Aug 2004 at 11:20 am 3.Tim said …

    You’re going to want to add a blacklist for sure. I use the movable type plugin MT-Blacklist (http://www.jayallen.org/comment_spam/). I currently have a blacklist of over 3,000 sites and regular expression strings that have thwarted over 20,000 comment entry attempts. There is a constantly updated blacklist (http://www.jayallen.org/comment_spam/blacklist.txt) a cron task to add them to your blacklist would be a smart thing to do.

    Maybe a combination of your method, the mt-blacklist and the updated blacklist is a way to go.

  4. on 04 Aug 2004 at 6:15 pm 4.Mark said …

    You really should make the button in the entry do something different if I press it more than once. I means pressing a button only to be told “Please do not press this button again” over and over pales after a while. I demand more entertainment!

    Oh, and change your link so it points to my blog, not VectorWorld, as I only post something there once in a blue moon.

  5. on 06 Aug 2004 at 9:46 am 5.MostlyHarmless said …

    The blacklist is on. Found an old spam comment during the de-spamming process.

    Vector’s link is updated, and here is a more interesting button for you to play with:

    http://hitchhikers.movies.go.com/main.html

    (The animation changes every time you load the page…)