diff options
Diffstat (limited to 'config/spamd/spamd_db.php')
-rw-r--r-- | config/spamd/spamd_db.php | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/config/spamd/spamd_db.php b/config/spamd/spamd_db.php index c2df25d1..e1d004f7 100644 --- a/config/spamd/spamd_db.php +++ b/config/spamd/spamd_db.php @@ -30,6 +30,10 @@ require("guiconfig.inc"); +$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); +if ($pf_version < 2.0) + $one_two = true; + if($_POST['filter']) $filter = $_POST['filter']; if($_POST['not']) @@ -39,6 +43,13 @@ if($_POST['limit']) else $limit = "25"; +if($_GET['spamtrapemail']) + $spamtrapemail = $_GET['spamtrapemail']; +if($_POST['spamtrapemail']) + $spamtrapemail = $_POST['spamtrapemail']; +if ($spamtrapemail) + $spamtrapemailarg = escapeshellarg($spamtrapemail); + /* handle AJAX operations */ if($_GET['action'] or $_POST['action']) { /* echo back buttonid so it can be turned @@ -46,60 +57,52 @@ if($_GET['action'] or $_POST['action']) { */ echo $_GET['buttonid'] . "|"; if($_GET['action']) - $action = escapeshellarg($_GET['action']); + $action = $_GET['action']; if($_POST['action']) - $action = escapeshellarg($_POST['action']); + $action = $_POST['action']; if($_GET['srcip']) $srcip = $_GET['srcip']; if($_POST['srcip']) $srcip = $_POST['srcip']; - if($_POST['toaddress']) - $toaddress = escapeshellarg($_POST['toaddress']); $srcip = str_replace("<","",$srcip); $srcip = str_replace(">","",$srcip); $srcip = str_replace(" ","",$srcip); // Make input safe $srcip = escapeshellarg($srcip); /* execute spamdb command */ - if($action == "'whitelist'") { - exec("/usr/local/sbin/spamdb -d {$srcip}"); + if($action == "whitelist") { exec("/usr/local/sbin/spamdb -d {$srcip} -T"); exec("/usr/local/sbin/spamdb -d {$srcip} -t"); delete_from_blacklist($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}"); - } else if($action == "'delete'") { + } else if($action == "delete") { 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_blacklist($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'") { + } else if($action == "trapped") { exec("/usr/local/sbin/spamdb -d {$srcip}"); - exec("/usr/local/sbin/spamdb -d {$srcip} -T"); - exec("/usr/local/sbin/spamdb -d {$srcip} -t"); - exec("/usr/local/sbin/spamdb -a {$srcip} -T"); - } else if($action == "'trapped'") { - exec("/usr/local/sbin/spamdb -T -d {$toaddress}"); - exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); + exec("/usr/local/sbin/spamdb -d {$srcip}"); + exec("/usr/local/sbin/spamdb -d -t {$srcip}"); + exec("/usr/local/sbin/spamdb -a -t {$srcip}"); + } else if($action == "spamtrap") { + exec("/usr/local/sbin/spamdb -a -T {$spamtrapemailarg}"); } /* signal a reload for real time effect. */ mwexec("killall -HUP spamlogd"); exit; } -/* spam trap e-mail address */ -if($_POST['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_POST['spamtrapemail']); - exec("/usr/local/sbin/spamdb -d {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -T {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -d -t {$spamtrapemail}"); - exec("/usr/local/sbin/spamdb -T -a '{$toaddress}'"); +/* spam trap e-mail address */ +if($spamtrapemail <> "") { + exec("spamdb -T -a {$spamtrapemailarg}"); mwexec("killall -HUP spamlogd"); - $savemsg = htmlentities($_POST['spamtrapemail']) . " added to spam trap database."; + $savemsg = htmlentities($spamtrapemail) . " added to spam trap database."; } if($_GET['getstatus'] <> "") { @@ -120,8 +123,7 @@ if($_GET['getstatus'] <> "") { /* spam trap e-mail address */ if($_GET['spamtrapemail'] <> "") { - $spamtrapemail = escapeshellarg($_GET['spamtrapemail']); - $status = exec("spamdb -T -a {$spamtrapemail}"); + $status = exec("spamdb -T -a {$spamtrapemailarg}"); mwexec("killall -HUP spamlogd"); if($status) echo $status; @@ -144,7 +146,7 @@ if($_GET['whitelist'] <> "") { function delete_from_blacklist($srcip) { config_lock(); - $blacklist = split("\n", file_get_contents("/var/db/blacklist.txt")); + $blacklist = explode("\n", file_get_contents("/var/db/blacklist.txt")); $fd = fopen("/var/db/blacklist.txt", "w"); foreach($blacklist as $bl) { if($bl <> "") @@ -159,7 +161,7 @@ function delete_from_blacklist($srcip) { function delete_from_whitelist($srcip) { config_lock(); - $whitelist = split("\n", file_get_contents("/var/db/whitelist.txt")); + $whitelist = explode("\n", file_get_contents("/var/db/whitelist.txt")); $fd = fopen("/var/db/whitelist.txt", "w"); foreach($whitelist as $wl) { if($wl <> "") @@ -200,7 +202,9 @@ $blacklist_items = $blacklist_items + $spamdb_black; ?> <body link="#000000" vlink="#000000" alink="#000000"> <?php include("fbegin.inc"); ?> +<?php if($one_two): ?> <p class="pgtitle"><?=$pgtitle?></font></p> +<?php endif; ?> <form action="spamd_db.php" method="post" name="iform"> <script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script> <script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script> @@ -323,25 +327,23 @@ if (typeof getURL == 'undefined') { if($filter) { if($not) { $fd = fopen("/tmp/spamdb", "w"); - $cmd = "/usr/local/sbin/spamdb | grep -v \"" . escapeshellarg($filter) . "\" | tail -n {$limit}"; + $cmd = "/usr/local/sbin/spamdb | grep -v " . escapeshellarg($filter) . " | tail -n {$limit}"; fwrite($fd, $cmd); fclose($fd); - $pkgdb = split("\n", `$cmd`); + exec($cmd, $pkgdb); if(file_exists("/var/db/blacklist.txt")) { $cmd = "cat /var/db/blacklist.txt | grep -v \"" . escapeshellarg($filter) . "\" "; - $pkgdba = split("\n", `$cmd`); + exec($cmd, $pkgdba); foreach($pkgdba as $pkg) { $pkgdb[] = "TRAPPED|{$pkg}|1149324397"; } } } else { - $cmd = "/usr/local/sbin/spamdb | grep " . escapeshellarg($filter) . " | tail -n {$limit}"; - - $pkgdb = split("\n", `$cmd`); + exec($cmd, $pkgdb); if(file_exists("/var/db/blacklist.txt")) { $cmd = "cat /var/db/blacklist.txt | grep " . escapeshellarg($filter); - $pkgdba = split("\n", `$cmd`); + exec($cmd, $pkgdba); foreach($pkgdba as $pkg) { $pkgdb[] = "TRAPPED|{$pkg}|1149324397"; } @@ -349,7 +351,7 @@ if (typeof getURL == 'undefined') { } } } else { - $pkgdb = split("\n", `/usr/local/sbin/spamdb | tail -n {$limit}`); + exec("/usr/local/sbin/spamdb | tail -n {$limit}", $pkgdb); } $rows = 0; $lastseenip = ""; @@ -361,7 +363,7 @@ if (typeof getURL == 'undefined') { $dontdisplay = false; if(!$pkgdb_row) continue; - $pkgdb_split = split("\|", $pkgdb_row); + $pkgdb_split = explode("|", $pkgdb_row); /* |