From c6111e2a9c430ca20ed16075868f4e5a08276c4b Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 20 Apr 2008 01:06:17 +0000 Subject: Cleanup this code dramatically. --- packages/spamd_db.php | 109 ++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 52 deletions(-) (limited to 'packages/spamd_db.php') diff --git a/packages/spamd_db.php b/packages/spamd_db.php index 4250a17f..bbd9568f 100644 --- a/packages/spamd_db.php +++ b/packages/spamd_db.php @@ -342,64 +342,69 @@ if (typeof getURL == 'undefined') { if($rows > $limit) break; $dontdisplay = false; - $rowtext = ""; - $rowtext .= ""; - $rowtext .= ""; $pkgdb_split = split("\|", $pkgdb_row); - $column = 0; - foreach($pkgdb_split as $col) { - if($column == 2) { - if(strstr($pkgdb_row, "TRAPPED")) { - $column++; - continue; - } - } - /* dont display these columns */ - if($column == 4 || $column == 5 || $column == 6 || $column == 8) { - $column++; - continue; - } - /* don't display if column blank */ - $col = str_replace("<","",$col); - $col = str_replace(">","",$col); - /* if string is really long allow it to be wrapped by - * replacing @ with space@ - */ - if(strlen($col)>25) { - $col = str_replace("@"," @",$col); - $col = str_replace("-"," -",$col); - $col = str_replace("."," .",$col); - } - $rowtext .= " {$col} "; - $column++; + + /* + + For TRAPPED entries the format is: + + type|ip|expire + + where type will be TRAPPED, IP will be the IP address blacklisted due to + hitting a spamtrap, and expire will be when the IP is due to be removed + from the blacklist. + + For GREY entries, the format is: + + type|source IP|helo|from|to|first|pass|expire|block|pass + + For WHITE entries, the format is: + + type|source IP|||first|pass|expire|block|pass + + */ + switch($pkgdb_split[0]) { + case "TRAPPED": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = ""; + $toaddress = ""; + $attempts = ""; + break; + case "GREY": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = htmlentities($pkgdb_split[3]); + $toaddress = htmlentities($pkgdb_split[4]); + $attempts = htmlentities($pkgdb_split[8]); + break; + case "WHITE": + $recordtype = htmlentities($pkgdb_split[0]); + $srcip = htmlentities($pkgdb_split[1]); + $fromaddress = ""; + $toaddress = ""; + $attempts = htmlentities($pkgdb_split[8]); + break; } - if(strstr($pkgdb_row, "TRAPPED")) { - for($x=0; $x<3; $x++) { - $rowtext .= ""; - } + + if($fromaddress == "") { + $rows++; + continue; } - if(strstr($pkgdb_row, "SPAMTRAP")) { - for($x=0; $x<3; $x++) { - $rowtext .= ""; - } - } - $rowtext .= " "; - $srcip = $pkgdb_split[1]; - $lastrow = $rows - 1; - $rowtext .= "\"Add "; + echo ""; + echo "{$recordtype}"; + echo "{$srcip}"; + echo "{$fromaddress}"; + echo "{$toaddress}"; + echo "{$attempts}"; + echo ""; + $rowtext = "\"Add "; $rowtext .= "\"Blacklist\" "; $rowtext .= "\"Delete\""; $rowtext .= "\"Spamtrap\" "; - $rowtext .= " "; - $rowtext .= ""; - if($srcip == "") - $dontdisplay = true; - if($lastseenip == $srcip and $filter == "") - $dontdisplay = true; - if($dontdisplay == false) { - echo $rowtext; - $lastseenip = $srcip; - } + echo $rowtext; + echo ""; + $rows++; } ?> -- cgit v1.2.3