diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2006-06-02 16:57:59 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2006-06-02 16:57:59 +0000 |
commit | f14370090e067ae878690b3886dbb13a1f22f52e (patch) | |
tree | 01345b4187412011a134524d8c1d9011ff46216d /packages/spamd_db.php | |
parent | a260a70221d035dbedbba3d217344f28d31f1c1e (diff) | |
download | pfsense-packages-f14370090e067ae878690b3886dbb13a1f22f52e.tar.gz pfsense-packages-f14370090e067ae878690b3886dbb13a1f22f52e.tar.bz2 pfsense-packages-f14370090e067ae878690b3886dbb13a1f22f52e.zip |
Delete items from SpamD blacklist when they are deleted from the SpamDB as well.
Diffstat (limited to 'packages/spamd_db.php')
-rw-r--r-- | packages/spamd_db.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/spamd_db.php b/packages/spamd_db.php index 7738ce95..dd10aaad 100644 --- a/packages/spamd_db.php +++ b/packages/spamd_db.php @@ -60,6 +60,7 @@ if($_GET['action'] or $_POST['action']) { 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_spamd_bl($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}"); @@ -67,6 +68,7 @@ if($_GET['action'] or $_POST['action']) { 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_spamd_bl($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") { @@ -110,6 +112,27 @@ if($_GET['getstatus'] <> "") { exit; } +function delete_from_spamd_bl($ip) { + config_lock(); + if(!file_exists("/var/db/blacklist.txt")) + return; + $blacklist = file("/var/db/blacklist.txt"); + $new_blacklist = array(); + foreach($blacklist as $bl) { + if(stristr($bl, $ip)) { + /* don't add item */ + } else { + $new_blacklist[] = $bl; + } + } + $fd = fopen("/var/db/blacklist.txt", "w"); + foreach($new_blacklist as $bl) + fwrite($fd, $bl . "\n"); + flose($fd); + mwexec("/sbin/pfctl -q -t blacklist -T replace -f /var/db/blacklist.txt"); + config_unlock(); +} + /* spam trap e-mail address */ if($_GET['spamtrapemail'] <> "") { $status = exec("spamdb -T -a \"<{$_GET['spamtrapemail']}>\""); |