","",$srcip); $srcip = str_replace(" ","",$srcip); /* execute spamdb command */ if($action == "whitelist") { 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 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 == "spamtrap") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d \"{$srcip}\" -T"); exec("/usr/local/sbin/spamdb -d \"{$srcip}\" -t"); exec("/usr/local/sbin/spamdb -a {$srcip} -T"); } else if($action == "trapped") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d \"{$srcip}\" -T"); exec("/usr/local/sbin/spamdb -d \"{$srcip}\" -t"); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); mwexec("/sbin/pfctl -q -t spamd -T add -f /var/db/blacklist.txt"); mwexec("/sbin/pfctl -q -t blacklist -T add -f /var/db/blacklist.txt"); } /* 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}\""); mwexec("/usr/local/sbin/spamdb -T -a \"{$spamtrapemail}\""); mwexec("killall -HUP spamlogd"); $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; } if($_GET['getstatus'] <> "") { $status = exec("/usr/local/sbin/spamdb | grep \"{$_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; } /* spam trap 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 = split("\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 = split("\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"; $spamdb_items = `/usr/local/sbin/spamdb | wc -l`; ?>

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

"; } } } else { $pkgdb = split("\n", `/usr/local/sbin/spamdb | tail -n {$limit}`); } $rows = 0; $lastseenip = ""; $srcip = "|"; foreach($pkgdb as $pkgdb_row) { if($rows > $limit) break; $dontdisplay = false; $rowtext = ""; $rowtext .= ""; $rowtext .= ""; $pkgdb_split = split("\|", $pkgdb_row); $column = 0; foreach($pkgdb_split as $col) { if($column == 2) { if(strstr($pkgdb_row, "TRAPPED")) { $column++; continue; } } /* dont display these columns */ if($column == 4 || $column == 5 || $column == 6 || $column == 8) { $column++; continue; } /* don't display if column blank */ $col = str_replace("<","",$col); $col = str_replace(">","",$col); /* if string is really long allow it to be wrapped by * replacing @ with space@ */ if(strlen($col)>25) { $col = str_replace("@"," @",$col); $col = str_replace("-"," -",$col); $col = str_replace("."," .",$col); } $rowtext .= ""; $column++; } if(strstr($pkgdb_row, "TRAPPED")) { for($x=0; $x<3; $x++) { $rowtext .= ""; } } if(strstr($pkgdb_row, "SPAMTRAP")) { for($x=0; $x<3; $x++) { $rowtext .= ""; } } $rowtext .= ""; $rowtext .= ""; if($srcip == "") $dontdisplay = true; if($lastseenip == $srcip and $filter == "") $dontdisplay = true; if($dontdisplay == false) { echo $rowtext; $lastseenip = $srcip; } $rows++; } ?>
Type IP From To Attempts
 {$col}  "; $srcip = $pkgdb_split[1]; $lastrow = $rows - 1; $rowtext .= "\"Add "; $rowtext .= "\"Blacklist\" "; $rowtext .= "\"Delete\""; $rowtext .= "\"Spamtrap\" "; $rowtext .= " 

" . ($rows-1) . " 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_items} total items in the SpamDB.
"; ?>