diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/spamd_db.php | 15 | ||||
-rw-r--r-- | packages/spamd_db_ext.php | 18 |
2 files changed, 33 insertions, 0 deletions
diff --git a/packages/spamd_db.php b/packages/spamd_db.php index 7b138877..761e64ac 100644 --- a/packages/spamd_db.php +++ b/packages/spamd_db.php @@ -150,6 +150,21 @@ function delete_from_blacklist($srcip) { 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"); diff --git a/packages/spamd_db_ext.php b/packages/spamd_db_ext.php index b7d30589..85aa3c68 100644 --- a/packages/spamd_db_ext.php +++ b/packages/spamd_db_ext.php @@ -84,10 +84,12 @@ if($_GET['action'] or $_POST['action']) { mwexec("/sbin/pfctl -q -t spamd -T delete $srcip"); mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); delete_from_blacklist($srcip); + delete_from_whitelist($srcip); log_error("spamd: {$srcip} has been deleted by {$_SERVER['REMOTE_ADDR']} {$loginname}"); exit; } else if($action == "spamtrap") { delete_from_spamd_db($email); + delete_from_whitelist($srcip); usleep(100); exec("/usr/local/sbin/spamdb -a \"<{$email}>\" -T"); hup_spamd(); @@ -96,6 +98,7 @@ if($_GET['action'] or $_POST['action']) { exit; } else if($action == "trapped") { delete_from_spamd_db($srcip); + delete_from_whitelist($srcip); usleep(100); exec("/usr/local/sbin/spamdb -a {$srcip} -t"); add_to_blacklist($srcip); @@ -205,6 +208,21 @@ function delete_from_blacklist($srcip) { 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(); +} + function hup_spamd() { mwexec("killall -HUP spamlogd"); } |