I've been thinking a lot recently on the issues we'll be facing as blogging continues to grow and be successful. One of the spam fighting tools (metaphor: club, not lojack) I implemented was a restriction on comment posting to posts that have been created in the past week. A few people have written and asked how I implemented the time restriction on comments.
It is actually very simple, once you've got a SQL backend (see previous post) for your blog. Here's the script I have running out of my crontab:
#!/usr/bin/perluse DBI;
my $dbname = 'DATABASENAME';
my $hostname = 'localhost'; # Change this if the db is on another box
my $dbuser = 'DBUSER';
my $dbpass = 'DBPASS';$dbh=DBI->connect("dbi:mysql:database=$dbname;host=$hostname", $dbuser, $dbpass);
$dbh->do("update mt_entry set entry_allow_comments='0' where entry_created_on < date_sub(NOW(),interval 7 day)");
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |