Dan is sick of comment spam and has realized that if he closes off old comments, it'll probably reduce comment spam. He's right. I've been doing this for months now and it's very effective. So, as my Giftmas gift to the blogging world, here's my whopping 26 lines of Perl code to do the job: blog_close_comments.pl.

It should be easily adapted for anyone using MT and MySQL.

Oh, the Blog::DBI module it requires looks like this.

You'll obviously need your own version.

It's not elegant or fancy, but it's working code that Does The Job and that's what's important. I could have written this using the MT API, but I was in a hurry. Someday I may fix that if I get ambitious.

UPDATE: The Blog::DBI module is not something from CPAN. It's meant to be installed "locally" rather than system-wide. I use it to supprt about half a dozen little blog/perl hacks I have. And it's actually a bit larger than the version I posted. Also, Derek sent a patch to make the blog_id an argument on the command-line. I've applied that.

Posted by jzawodn at December 25, 2003 06:44 AM

Reader Comments
# Jon Gales said:

Wow that's almost exactly what I meant. Are there no original ideas left out there? Good work!

on December 25, 2003 09:43 AM
# kasia said:

Add auto-disable trackbacks to that list.. I'm getting spam that way too..

on December 25, 2003 01:54 PM
# Dan said:

Yeah, but that only works if you're using MySQL to back things. Some of us don't trust these newfangled "database server" doodads... :-P

on December 25, 2003 05:40 PM
# Mark said:

I have a similar hack for WordPress and b2. Look here http://dinki.mine.nu/word/
Jeremy: sometime this weekend?

on December 27, 2003 07:43 AM
# James E. Robinson, III said:

Simpler, use cron:

echo 'UPDATE mt_entry SET entry_allow_comments = 2 WHERE entry_blog_id = 2 AND entry_created_on < DATE_SUB(NOW(), INTERVAL 31 DAY)' | mysql

Setting blog_id appropriately. It closes comments on entries older than 31 days.

Also, i would recommend getting the mt-rebuild script:
http://www.mplode.com/tima/archives/000238.html

Otherwise, archive entries will still have the comment form but it won't be usable.

on December 27, 2003 07:45 AM
# James E. Robinson, III said:

Ooops:

echo 'UPDATE mt_entry SET entry_allow_comments = 2 WHERE entry_blog_id = 2 AND entry_created_on < DATE_SUB(NOW(), INTERVAL 31 DAY)' | mysql

on December 27, 2003 07:47 AM
# reinhard said:

and so they use actually entries and the old entries are closed for "normal comments". I think that a keyword-list and the MT-blacklist can do it better.

on December 28, 2003 02:17 AM
# Gerald said:

> Otherwise, archive entries will still have the comment form but it won't be usable.

i am irritated that there is no hint about closing an old entry. so a lot of visitors, e.g. arriving by search engines, will be fooled. imho that's a real usability lack. how would you feel if you just had written a 5 minute elaboration and pushed the post-button, and then - this:
------------------------------------------------
Your comment submission failed for the following reasons:

Comments are not allowed on this entry.
------------------------------------------------

for closed entries you should either remove the form or give an appropriate hint.

best wishes and a happy new year,
gerald

on December 28, 2003 05:27 AM
# Justin said:

Gerald,

it's not like any one reads the comments anyways :)

on December 29, 2003 10:47 AM
# Nome said:

agree to this statement "and so they use actually entries and the old entries are closed for "normal comments". I think that a keyword-list and the MT-blacklist can do it better. "

on November 17, 2008 12:58 AM
# Essay Writing said:

this is an excellent post. It is very informative. Thank you so much.

on September 14, 2009 02:44 AM
# said:

this is an excellent post. It is very informative. Thank you so much.

Jessica Smith
Essay Writing
http://www.pureessays.com

on September 15, 2009 05:01 AM
# Essay Writing said:

Thanks for useful tips and guidelines.

on November 18, 2009 03:02 PM
# SEO Company said:

This is easier and surely gives comfort to internet users. Thanks for sharing. Post like this offers great benefit. Thank you!

on January 28, 2010 01:20 AM
# Colorado Mortgage said:

I admire what you have done here. Thank you for sharing. We will look forward for your future updates.

Thanks

on February 23, 2010 04:11 AM
# ONLINE SWEEPSTAKES said:

Cool, there are actually some great points on here some of my friends will find this worthwhile, I must send them a link, many thanks.

on March 18, 2010 05:31 AM
# Cpoe said:

Thanks for sharing such a fine piece of advice about SQL and application. Its really great to read and as well as very helpful to get to know such a great thing, thanks a lot for posting this.

on April 5, 2010 03:11 AM
# Vietnam Visa said:

Nice blog. You give me best information.

on April 29, 2010 08:11 PM
# healthgesundheitinfo.blogspot.com said:


Great share, great article, very usefull for me. Your thought of article is very much creative and interesting to read.

on June 6, 2010 09:00 AM
# Smart Car Care said:

HI, I am rowan Atkinson. I've been doing this for months now and it's very effective.
This post is really very appreciable. I think some new things if you add to your post like current affairs will increase It is popularity.
-------------------------------------------------
rowanat01

on June 16, 2010 07:06 AM
# Auto Part Index said:

Ground Motorcar Parts & Man important quantity is help. This enables our customers to wager their automotive & leatherneck ply requirements with one seed. We handle products of over 300 manufacturers and change operation to other 1350 manufacturers. This pipe of Manufacturers grants us the state to activity you with rightful almost EVERYTHING you impoverishment in the moving and leatherneck Manufacture!

on July 9, 2010 11:10 AM
Disclaimer: The opinions expressed here are mine and mine alone. My current, past, or previous employers are not responsible for what I write here, the comments left by others, or the photos I may share. If you have questions, please contact me. Also, I am not a journalist or reporter. Don't "pitch" me.

 

Privacy: I do not share or publish the email addresses or IP addresses of anyone posting a comment here without consent. However, I do reserve the right to remove comments that are spammy, off-topic, or otherwise unsuitable based on my comment policy. In a few cases, I may leave spammy comments but remove any URLs they contain.