#!/usr/bin/perl -w use strict; use CGI; use DBI; my $q = new CGI; print $q->header(); my $dbh = DBI->connect("DBI:mysql:database=mails", "mailer", "XXX", { RaiseError => 1 }); my $table = $q->param('table'); $table = "addresses" if (!$table); my @tables; my $sth; my @row; # tables that are used internally, and not for storing addresses my %removeTables = ( 'maillog' => 1, 'unsubscribed' => 1 ); $sth = $dbh->prepare("show tables"); $sth->execute(); while (@row = $sth->fetchrow_array()) { push(@tables, $row[0]) unless $removeTables{$row[0]}; } $sth->finish(); print < axfooblug.com: Addresses

axfooblug subscribers

Tables: EOF my @alist; foreach my $t (@tables) { push(@alist, "$t"); } print join(' ', @alist); print <

Current subscribers in table $table

EOF $sth = $dbh->prepare("select * from $table order by id"); $sth->execute(); while (@row = $sth->fetchrow_array()) { my @infolist; my $a = $row[1]; push(@infolist, "subscribed on $row[4]"); if ($row[2] == 0) { push(@infolist, "subscribe"); } if ($row[3] == 1) { push(@infolist, "address bouncing"); } push(@infolist, "delete"); print "$a
\n  "; print join(";", @infolist); print "

\n"; } $sth->finish(); print <

Unsubscribe log:

EOF $sth = $dbh->prepare("select * from unsubscribed where `table` = '$table' order by id"); $sth->execute(); while (@row = $sth->fetchrow_array()) { print $row[1] . " unsubscribed on " . $row[2] . "
\n"; } $sth->finish(); $dbh->disconnect(); print <
EOF