$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 = $_GET['action']; if($_POST['action']) $action = $_POST['action']; if($_GET['srcip']) $srcip = $_GET['srcip']; if($_POST['srcip']) $srcip = $_POST['srcip']; /* execute spamdb command */ if($action == "whitelist") { exec("/usr/local/sbin/spamdb -a {$srcip}"); exit; } else if($action == "delete") { $fd = fopen("/tmp/execcmds", "w"); config_lock(); fwrite($fd, "#!/bin/sh\n"); fwrite($fd, "/usr/local/sbin/spamdb -d {$srcip}\n"); fwrite($fd, "/usr/local/sbin/spamdb -T -d \"<{$srcip}>\"\n"); fwrite($fd, "/usr/local/sbin/spamdb -t -d \"<{$srcip}>\"\n"); fwrite($fd, "/usr/local/sbin/spamdb | grep {$srcip}\n"); fclose($fd); exec("chmod a+rx /tmp/execcmds"); system("/bin/sh /tmp/execcmds"); remove_from_blacklist($srcip); config_unlock(); exit; } else if($action == "spamtrap") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d -T \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -d -t \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -a {$srcip} -T"); exit; } else if($action == "trapped") { exec("/usr/local/sbin/spamdb -d {$srcip}"); exec("/usr/local/sbin/spamdb -d -T \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -d -t \"<{$srcip}>\""); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); config_lock(); add_to_blacklist($srcip); config_unlock(); 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 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; ?>