","",$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}"); } else if($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"); } else if($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}"); } else if($action == "'spamtrap'") { exec("/usr/local/sbin/spamdb -a -T {$spamtrapemail}"); } /* signal a reload for real time effect. */ mwexec("killall -HUP spamlogd"); exit; } /* spam trap e-mail address */ if($_POST['spamtrapemail'] <> "") { $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); exec("/usr/local/sbin/spamdb -d -T {$spamtrapemail}"); exec("/usr/local/sbin/spamdb -d -t {$spamtrapemail}"); exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); mwexec("killall -HUP spamlogd"); $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; } if($_GET['getstatus'] <> "") { $status = exec("/usr/local/sbin/spamdb | grep " . escapeshellarg($_GET['getstatus'])); if(stristr($status, "WHITE") == true) { echo "WHITE"; } else if(stristr($status, "TRAPPED") == true) { echo "TRAPPED"; } else if(stristr($status, "GREY") == true) { echo "GREY"; } else if(stristr($status, "SPAMTRAP") == true) { echo "SPAMTRAP"; } else { echo "NOT FOUND"; } exit; } /* spam trap e-mail address */ if($_GET['spamtrapemail'] <> "") { $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); $status = exec("spamdb -T -a {$spamtrapemail}"); mwexec("killall -HUP spamlogd"); if($status) echo $status; else echo htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; exit; } /* whitelist e-mail address */ if($_GET['whitelist'] <> "") { $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); $status = exec("spamdb -a {$spamtrapemail}"); mwexec("killall -HUP spamlogd"); if($status) echo $status; else echo htmlentities($_POST['spamtrapemail']) . " added to whitelist database."; exit; } function delete_from_blacklist($srcip) { config_lock(); $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"); config_unlock(); } function delete_from_whitelist($srcip) { config_lock(); $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"); config_unlock(); } $pgtitle = "SpamD: Database"; include("head.inc"); if(file_exists("/var/db/whitelist.txt")) $whitelist_items = `cat /var/db/whitelist.txt | wc -l`; else $whitelist_items = 0; if(file_exists("/var/db/blacklist.txt")) $blacklist_items = `cat /var/db/blacklist.txt | wc -l`; else $blacklist_items = 0; // Get an overall count of the database $spamdb_items = `/usr/local/sbin/spamdb | wc -l`; // Get blacklist and whitelist count from database $spamdb_white = `/usr/local/sbin/spamdb | grep WHITE | wc -l`; $spamdb_black = `/usr/local/sbin/spamdb | grep BLACK | wc -l`; $spamdb_grey = `/usr/local/sbin/spamdb | grep GREY | wc -l`; // Now count the user contributed whitelist and blacklist count $whitelist_items = $whitelist_items + $spamdb_white; $blacklist_items = $blacklist_items + $spamdb_black; ?>

Filter by test:  Inverse filter (NOT):>
Limit:
 
* Add spam trap E-mail address:

"; } } } else { $pkgdb = explode("\n", `/usr/local/sbin/spamdb | tail -n {$limit}`); } $rows = 0; $lastseenip = ""; $srcip = "|"; foreach($pkgdb as $pkgdb_row) { if($rows > $limit) break; $dontdisplay = false; if(!$pkgdb_row) continue; $pkgdb_split = explode("|", $pkgdb_row); /* For TRAPPED entries the format is: type|ip|expire where type will be TRAPPED, IP will be the IP address blacklisted due to hitting a spamtrap, and expire will be when the IP is due to be removed from the blacklist. For GREY entries, the format is: type|source IP|helo|from|to|first|pass|expire|block|pass For WHITE entries, the format is: type|source IP|||first|pass|expire|block|pass */ switch($pkgdb_split[0]) { case "SPAMTRAP": $recordtype = htmlentities($pkgdb_split[0]); $srcip = htmlentities($pkgdb_split[1]); $fromaddress = htmlentities($pkgdb_split[3]); $toaddress = htmlentities($pkgdb_split[4]); $first = ""; $pass = ""; $expire = ""; $attempts = htmlentities($pkgdb_split[8]); break; case "TRAPPED": $recordtype = htmlentities($pkgdb_split[0]); $srcip = htmlentities($pkgdb_split[1]); $fromaddress = ""; $toaddress = ""; $first = ""; $pass = ""; $expire = htmlentities($pkgdb_split[2]); $attempts = ""; break; case "GREY": $recordtype = htmlentities($pkgdb_split[0]); $srcip = htmlentities($pkgdb_split[1]); $fromaddress = htmlentities($pkgdb_split[3]); $toaddress = htmlentities($pkgdb_split[4]); $first = htmlentities($pkgdb_split[5]); $pass = htmlentities($pkgdb_split[6]); $expire = htmlentities($pkgdb_split[7]); $attempts = htmlentities($pkgdb_split[8]); break; case "WHITE": $recordtype = htmlentities($pkgdb_split[0]); $srcip = htmlentities($pkgdb_split[1]); $fromaddress = ""; $toaddress = ""; $first = htmlentities($pkgdb_split[4]); $pass = htmlentities($pkgdb_split[5]); $expire = htmlentities($pkgdb_split[6]); $attempts = htmlentities($pkgdb_split[8]); break; } if($srcip == "" and $fromaddress == "" and $toaddress == "") continue; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $rows++; } ?>
Type IP From To First Pass Expire Attempts
{$recordtype}{$srcip}{$fromaddress}{$toaddress}" . date("Y-m-d", $first) . "
" . date("H:i:s", $first) . "
" . date("Y-m-d", $pass) . "
" . date("H:i:s", $pass) . "
" . date("Y-m-d", $expire) . "
" . date("H:i:s", $expire) . "
{$attempts}"; $rowtext = "\"Add "; $rowtext .= "\"Blacklist\" "; $rowtext .= "\"Delete\""; $rowtext .= "\"Spamtrap\" "; echo $rowtext; echo "

" . $rows . " rows returned."; ?>

* NOTE: adding an e-mail address to the spamtrap automatically traps any server trying to send e-mail to this address.


Note: Clicking on the action icons will invoke a AJAX query and the page will not refresh. Click refresh in you're browser if you wish to view the changes in status.

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.
"; ?>