#!/usr/bin/env perl BEGIN { @INC=(("/home/thehyatts/cgi-bin/mt/lib", "/home/thehyatts/cgi-bin/mt/extlib"), @INC); } use MT; use MT::Object; use MT::Comment; use Getopt::Long; if (@ARGV == 0) {die "Usage: remove_matching_comments [--list] [--test] [-ip ip] [-author author] [-text regex]\n";} my $ip = ""; my $author = ""; my $list = 0; GetOptions("ip=s" => \$ip, "test" => \$test, "author=s" => \$author, "text=s" => \$text, "list" => \$list); my $mt = MT->new(Config => "/home/thehyatts/cgi-bin/mt/mt.cfg"); my @comments = MT::Comment->load(undef, undef); for my $comment (@comments) { if ($list == 1) { print "author = " . $comment->author . ", ip = " . $comment->ip . " text = " . $comment->text . "\n"; } else { if ($ip ne "" && $comment->ip eq $ip) { print "removing comment by " . $comment->author . "\n"; if ($test != 1) { $comment->remove; } } if (($author ne "" && $comment->author =~ /$author/) || ($text ne "" && $comment->text =~ /$text/)) { print "removing comment: " . $comment->text . "\n"; if ($test != 1) { $comment->remove; } } } }