diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/spamd_db_ext.php | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/packages/spamd_db_ext.php b/packages/spamd_db_ext.php index 9463ac8b..c08099ab 100644 --- a/packages/spamd_db_ext.php +++ b/packages/spamd_db_ext.php @@ -57,45 +57,36 @@ if($_GET['action'] or $_POST['action']) { * back off when request is completed. */ if($_GET['action']) - $action = $_GET['action']; + $action = trim($_GET['action']); if($_POST['action']) - $action = $_POST['action']; + $action = trim($_POST['action']); if($_GET['srcip']) - $srcip = $_GET['srcip']; + $srcip = trim($_GET['srcip']); if($_POST['srcip']) - $srcip = $_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") { - $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(); + delete_from_spamd_db($srcip); + usleep(100); 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"); + 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") { - exec("/usr/local/sbin/spamdb -d {$srcip}"); - exec("/usr/local/sbin/spamdb -d -T \"<{$srcip}>\""); - exec("/usr/local/sbin/spamdb -d -t \"<{$srcip}>\""); + delete_from_spamd_db($srcip); + usleep(100); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); - config_lock(); + mwexec("/usr/bin/killall -HUP spamlogd"); add_to_blacklist($srcip); - config_unlock(); exit; } /* signal a reload for real time effect. */ @@ -151,6 +142,22 @@ if($_GET['whitelist'] <> "") { 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"); |