$username) { echo "550. INVALID USERNAME {$username}."; exit; } if($outlook['password'] <> $password) { echo "550. INVALID PASSWORD {$password}."; exit; } } exec("echo {$_GET['action']} > /tmp/tmp"); /* handle AJAX operations */ if($_GET['action'] or $_POST['action']) { /* echo back buttonid so it can be turned * back off when request is completed. */ if($_GET['action']) $action = trim($_GET['action']); if($_POST['action']) $action = trim($_POST['action']); if($_GET['srcip']) $srcip = trim($_GET['srcip']); if($_POST['srcip']) $srcip = trim($_POST['srcip']); /* execute spamdb command */ if($action == "whitelist") { delete_from_spamd_db($srcip); usleep(100); exec("/usr/local/sbin/spamdb -a {$srcip}"); mwexec("/usr/bin/killall -HUP spamlogd"); exit; } else if($action == "delete") { delete_from_spamd_db($srcip); usleep(100); exit; } else if($action == "spamtrap") { delete_from_spamd_db($srcip); usleep(100); exec("/usr/local/sbin/spamdb -a \"<{$srcip}>\" -T"); mwexec("/usr/bin/killall -HUP spamlogd"); exit; } else if($action == "trapped") { delete_from_spamd_db($srcip); usleep(100); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); mwexec("/usr/bin/killall -HUP spamlogd"); add_to_blacklist($srcip); exit; } /* signal a reload for real time effect. */ mwexec("killall -HUP spamlogd"); exit; } /* spam trap e-mail address */ if($_POST['spamtrapemail'] <> "") { exec("/usr/local/sbin/spamdb -d {$_POST['spamtrapemail']}"); exec("/usr/local/sbin/spamdb -d -T \"<{$_POST['spamtrapemail']}>\""); exec("/usr/local/sbin/spamdb -d -t \"<{$_POST['spamtrapemail']}>\""); mwexec("/usr/local/sbin/spamdb -T -a \"<{$_POST['spamtrapemail']}>\""); mwexec("killall -HUP spamlogd"); $savemsg = $_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'] <> "") { $status = exec("spamdb -T -a \"<{$_GET['spamtrapemail']}>\""); mwexec("killall -HUP spamlogd"); if($status) echo $status; else echo $_POST['spamtrapemail'] . " added to spam trap database."; exit; } /* spam trap e-mail address */ if($_GET['whitelist'] <> "") { $status = exec("spamdb -a \"<{$_GET['spamtrapemail']}>\""); mwexec("killall -HUP spamlogd"); if($status) echo $status; else echo $_POST['spamtrapemail'] . " added to whitelist database."; exit; } function delete_from_spamd_db($srcip) { config_lock(); $fd = fopen("/tmp/execcmds", "w"); fwrite($fd, "#!/bin/sh\n"); fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -T\n"); fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip} -t\n"); fwrite($fd, "/usr/local/sbin/spamdb -d \"<{$srcip}>\" -t\n"); fwrite($fd, "/usr/local/sbin/spamdb -d \"<{$srcip}>\" -T\n"); fclose($fd); exec("/bin/chmod a+rx /tmp/execcmds"); system("/bin/sh /tmp/execcmds"); mwexec("/usr/bin/killall -HUP spamlogd"); config_unlock(); } function basic_auth_prompt(){ header("WWW-Authenticate: Basic realm=\".\""); header("HTTP/1.0 401 Unauthorized"); echo "You must enter valid credentials to access this resource."; exit; } function add_to_blacklist($srcip) { $fd = fopen("/var/db/blacklist.txt", "a"); fwrite($fd, "{$srcip}\n"); fclose($fd); } function delete_from_blacklist($srcip) { $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); foreach($blacklist as $bl) { if($blacklist <> $srcip) fwrite($fd, "{$srcip}\n"); } fclose($fd); } exit; ?>