", "", $srcip); $srcip = str_replace(" ", "", $srcip); // make input safe $srcip = escapeshellarg($srcip); /* execute spamdb command */ if ($action == "whitelist") { exec("/usr/local/sbin/spamdb -d {$srcip} -T"); exec("/usr/local/sbin/spamdb -d {$srcip} -t"); delete_from_blacklist($srcip); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); exec("echo spamdb -a {$srcip} > /tmp/tmp"); exec("/usr/local/sbin/spamdb -a {$srcip}"); } elseif ($action == "delete") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d {$srcip} -T"); exec("/usr/local/sbin/spamdb -d {$srcip} -t"); delete_from_blacklist($srcip); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); } elseif ($action == "trapped") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d -t {$srcip}"); exec("/usr/local/sbin/spamdb -a -t {$srcip}"); } elseif ($action == "spamtrap") { exec("/usr/local/sbin/spamdb -a -T {$spamtrapemailarg}"); } /* signal a reload for real time effect. */ mwexec("/usr/bin/killall -HUP spamlogd"); exit; } if ($_GET['getstatus'] != "") { $status = exec("/usr/local/sbin/spamdb | /usr/bin/grep " . escapeshellarg($_GET['getstatus'])); if (stristr($status, "WHITE") == true) { echo "WHITE"; } elseif (stristr($status, "TRAPPED") == true) { echo "TRAPPED"; } elseif (stristr($status, "GREY") == true) { echo "GREY"; } elseif (stristr($status, "SPAMTRAP") == true) { echo "SPAMTRAP"; } else { echo "NOT FOUND"; } exit; } /* spam trap e-mail address */ if ($spamtrapemail != "") { $status = exec("/usr/local/sbin/spamdb -T -a {$spamtrapemailarg}"); mwexec("/usr/bin/killall -HUP spamlogd"); if ($status) { echo $status; } else { echo htmlentities($spamtrapemail) . " added to spam trap database."; } exit; } /* whitelist e-mail address */ if ($_GET['whitelist'] != "") { $status = exec("/usr/local/sbin/spamdb -a {$spamtrapemail}"); mwexec("/usr/bin/killall -HUP spamlogd"); if ($status) { echo $status; } else { echo htmlentities($spamtrapemail) . " added to whitelist database."; } exit; } function delete_from_blacklist($srcip) { $blacklist = explode("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); foreach ($blacklist as $bl) { if ($bl != "") { if (!stristr($bl, $srcip)) { fwrite($fd, "{$bl}\n"); } } } fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete {$srcip}"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); } function delete_from_whitelist($srcip) { $whitelist = explode("\n", file_get_contents("/var/db/whitelist.txt")); $fd = fopen("/var/db/whitelist.txt", "w"); foreach($whitelist as $wl) { if ($wl != "") { if (!stristr($wl, $srcip)) { fwrite($fd, "{$wl}\n"); } } } fclose($fd); mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t whitelist -T replace -f /var/db/whitelist.txt"); } $pgtitle = "SpamD: Database"; include("head.inc"); if (file_exists("/var/db/whitelist.txt")) { $whitelist_items = shell_exec("/bin/cat /var/db/whitelist.txt | /usr/bin/wc -l"); } else { $whitelist_items = 0; } if (file_exists("/var/db/blacklist.txt")) { $blacklist_items = shell_exec("/bin/cat /var/db/blacklist.txt | /usr/bin/wc -l"); } else { $blacklist_items = 0; } // Get an overall count of the database $spamdb_items = shell_exec("/usr/local/sbin/spamdb | /usr/bin/wc -l"); // Get blacklist and whitelist count from database $spamdb_white = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep WHITE | /usr/bin/wc -l"); $spamdb_black = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep BLACK | /usr/bin/wc -l"); $spamdb_grey = shell_exec("/usr/local/sbin/spamdb | /usr/bin/grep GREY | /usr/bin/wc -l"); // Now count the user contributed whitelist and blacklist count $whitelist_items = $whitelist_items + $spamdb_white; $blacklist_items = $blacklist_items + $spamdb_black; ?>
Database totals:
";
echo "{$blacklist_items} total items in the blacklist.
";
echo "{$spamdb_grey} total items in the greylist.
";
echo "{$spamdb_items} total items in the SpamDB.
";
?>