#!/usr/local/bin/perl -w # # usage: ./blog_close_comments.pl # # a of "0" means "all" $|=1; use strict; use DBIx::DWIW; use Blog::DBI; my $dbg = $ENV{DEBUG}; my $days = shift || 5; my $blog = shift || 1; my $conn = Blog::DBI->connect() or die "$!"; my $update_sql = qq[ update mt_entry set entry_allow_comments = 2 where entry_created_on <= date_sub(CURDATE(), interval $days day) and entry_allow_comments <> 2 ]; if (defined $blog and $blog > 0) { $update_sql .= qq[ and entry_blog_id = $blog ]; } my $update_sth= $conn->Prepare($update_sql); my $ret = $update_sth->Execute(); print "Comments have been closed on $ret blog entries.\n" if $dbg; exit;