Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


How can I delete Movable Type (MT) blog comment spam easily?

A technical wizard pal of mine asks: "I have all sorts of challenge/response barriers to comment spam on my Movable Type weblog, but occasionally someone goes through the work of identifying themselves and still leaves some silly spam comment. I want to delete it, but right now I get the email notification of the new comment, then have to log in to the administrative interface, find the comment, and delete it by hand. Quite a hassle. Isn't there a better solution to this?"

Dave's Answer:

Ah yes, those wonderful people with their blogspam comments on weblogs.

A personal message from Ask Dave Taylor about this type of comment:

Keep it off our site!

I feel better now. Thanks for letting me vent.

To make life easier for me, I hacked into the Comments.pm module within Movable Type (which you can find in lib/MT/App in your installation) and made the following addition:

$body .= "\nDelete:" . 
$app->{cfg}->CGIPath . 
"mt.cgi?__mode=delete_confirm&" .
"_type=comment&id=".$comment->id . 
"&blog_id=" . $blog->id . "\n";
This should be placed immediately after the message construction line:
$body = Text::Wrap::wrap('', '', $body) . "\n$link_url\n\n" .
$app->translate('IP Address:') . ' ' . $comment->ip . "\n" .
$app->translate('Name:') . ' ' . $comment->author . "\n" .
$app->translate('Email Address:') . ' ' . $comment->email . "\n" .
$app->translate('URL:') . ' ' . $comment->url . "\n\n" .
$app->translate('Comments:') . "\n\n" . $comment->text . "\n";
Now, when I get notification of a new comment, I have an instant "Delete" link I can click, which then takes me directly to the confirm dialog box (though in a big browser window, which is kinda weird). I click "delete" a second time, and the comment is wiped out of the database.

However, and this is an important caveat, I still need to rebuild the weblog to finish the removal process. Not a big deal: I usually find myself rebuilding every 2-3 days anyway, but unfortunately I haven't figured out how to do everything with a single mouse click. Yet.

If you know of other ways to build a URL to embed in the email notification that offers a one-click delete comment and rebuild weblog as needed feature, I'd sure love to hear about it!


Related HTML, JavaScript and Web Site Programming articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  








Reader Comments To Date: 7

Sean said, on November 18, 2004 4:03 AM:

I use MT-Blacklist. While it lets through a fair bit of spam, it provides a great interface to bulk delete comments, including rebuilding all the relevent pages.

BTW, how did you get that math question in there? Does it work well? I was going to hack it into mt-comments.cgi, but I see a few people have similar schemes so I thought there might be something out there.

Sean

Dave Taylor said, on November 18, 2004 4:46 AM:

Thanks for your note, Sean. MT-Blacklist is something that only comes along with an upgraded version of Movable Type: I'm still running 2.x so I can't use it. I am, however, starting to think about an upgrade. :-)

In terms of the math formula, I paid someone to write a custom plug-in for me and then added some code both in the comment templates and in the Comments.pm module...

Nick said, on November 18, 2004 2:52 PM:

You can actually use the earlier versions of MT-Blacklist on a 2.X MT blog. It's not as advanced, and the blacklist isn't being updated, but I still find it useful for those situations in which I get 300 identical spam comments, all on different entries. I can click the link in the notification email, delete the comment and rebuild that one entry, then "de-spam" the whole blog and rebuild the relevant entries in one step.

And I agree; the math formula is terrific! Does it actually cut down on the amount of comment spam? If it does, maybe you'll take a contribution towards costs to share it ...?

---- Nick

Dave Taylor said, on November 19, 2004 7:08 AM:

I get almost zero comment spam, actually. It's a rare occurrence, probably less than six/month at this point (I cringe at even writing this, though). However, I'm a pretty open source sort of guy, but I am not willing to share this particular plug-in for the simple reason that the more sites that use it, the more motivation spammers will have for figuring out how to reverse-engineer it. Sorry. :-|

Mark C. said, on April 25, 2006 1:12 AM:

Can someone elaborate on what comment spam is all about? I'll come back to see if there's a clarification later this week. Thanks.

Nicholas Barnard said, on November 27, 2007 6:01 PM:

Here's how to do it in one click. First you have to have Jay Allen's MT-Blacklist installed http://www.jayallen.org/projects/mt-blacklist/

Then instead of the code in the Comments.pm file, add the following in the same place:
$body .= "\nDelete: " . $app->{cfg}->CGIPath."commentremove.cgi?".$comment->id."\n";

Then in your MovableType directory drop this file as commentremove.cgi (you'll probably need to edit the action= path to mt-blacklist.cgi)

#!/bin/sh

echo Content-type: text/html; charset=utf-8
echo

echo \<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\>
echo \<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"\>
echo \<head\>
echo \<title\>Delete Comment $QUERY_STRING \</title\>
echo \</head\>
echo \<body onLoad=\"javascript:submitform\(\)\"\>
echo \<script language=\"JavaScript\"\>
echo function submitform\(\)
echo \{
echo setTimeout\(\"document.onlyform.submit\(\)\",45000\)\;
echo \}
echo \</script\>
echo \<div align=\"center\"\>
echo \<form method=\"post\" action=\"/mt/mt-blacklist.cgi\" name=\"onlyform\" enctype=\"application/x-www-form-urlencoded\"\>
echo \<input type=\"hidden\" name=\"__mode\" value=\"despam_multi\" /\>
echo \<input type=\"hidden\" name=\"_type\" value=\"comment\" /\>
echo \<input type=\"hidden\" name=\"deleteObject\" value=\"$QUERY_STRING\" /\>
echo \<input type=\"hidden\" name=\"rebuildEntries\" value=\"1\" /\>
echo \<input type=\"submit\" name=\"\" value=\"Delete Comment $QUERY_STRING\" /\>
echo \</form\>
echo \</div\>
echo \</body\>
echo \</html\>


And that is how you get comment removal and rebuilding in one click.

Rajiv Kumar said, on October 3, 2008 1:12 PM:

Actually i am unable to post comments without login
Please Help me Out

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.