From b5be44d98985746b6319309d8272b297674b540c Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Mon, 21 Aug 2017 12:25:03 -0700 Subject: [PATCH] Added link for domain on various list displays. --- maps/php/MAPS.php | 230 +++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/maps/php/MAPS.php b/maps/php/MAPS.php index 72e1390..b718935 100755 --- a/maps/php/MAPS.php +++ b/maps/php/MAPS.php @@ -1,24 +1,24 @@ Error # $errno $errmsg"; print "
SQL Statement: $statement"; - exit ($errno); + exit($errno); } // DBError -function OpenDB () { - $db = mysql_connect ("localhost", "mapsadmin", "mapsadmin") - or DBError ("OpenDB: Unable to connect to database server", "Connect"); +function OpenDB() { + $db = mysql_connect("localhost", "mapsadmin", "mapsadmin") + or DBError("OpenDB: Unable to connect to database server", "Connect"); - mysql_select_db ("MAPS") - or DBError ("OpenDB: Unable to select MAPS database", "adefaria_maps"); + mysql_select_db("MAPS") + or DBError("OpenDB: Unable to select MAPS database", "adefaria_maps"); } // OpenDB -function SetContext ($new_userid) { +function SetContext($new_userid) { global $userid; $userid = $new_userid; } // SetContext -function Encrypt ($password, $userid) { +function Encrypt($password, $userid) { $statement = "select encode(\"$password\",\"$userid\")"; - $result = mysql_query ($statement) - or DBError ("Encrypt: Unable to execute statement", $statement); + $result = mysql_query($statement) + or DBError("Encrypt: Unable to execute statement", $statement); // Get return value, which should be the encoded password - $row = mysql_fetch_array ($result); + $row = mysql_fetch_array($result); - return $row [0]; + return $row[0]; } // Encrypt -function UserExists ($userid) { +function UserExists($userid) { $statement = "select userid, password from user where userid = \"$userid\""; - $result = mysql_query ($statement) + $result = mysql_query($statement) or DBError ("UserExists: Unable to execute statement", $statement); - $row = mysql_fetch_array ($result); + $row = mysql_fetch_array($result); - $dbuserid = $row ["userid"]; - $dbpassword = $row ["password"]; + $dbuserid = $row["userid"]; + $dbpassword = $row["password"]; if ($dbuserid != $userid) { return -1; @@ -87,11 +87,11 @@ function UserExists ($userid) { } # if } // UserExists -function Login ($userid, $password) { - $password = Encrypt ($password, $userid); +function Login($userid, $password) { + $password = Encrypt($password, $userid); // Check if user exists - $dbpassword = UserExists ($userid); + $dbpassword = UserExists($userid); // Return -1 if user doesn't exist if ($dbpassword == -1) { @@ -102,8 +102,8 @@ function Login ($userid, $password) { if ($password != $dbpassword) { return -2; } else { - setcookie ("MAPSUser", $userid, time()+60*60*24*30, "/maps"); - SetContext ($userid); + setcookie("MAPSUser", $userid, time()+60*60*24*30, "/maps"); + SetContext($userid); return 0; } // if } // Login @@ -113,110 +113,110 @@ function CountList ($type) { $statement = "select count(*) as count from list where type=\"$type\" and userid=\"$userid\""; - $result = mysql_query ($statement) - or DBError ("CountList: Unable to count list: ", $statement); + $result = mysql_query($statement) + or DBError("CountList: Unable to count list: ", $statement); // How many rows are there? - $row = mysql_fetch_array ($result); + $row = mysql_fetch_array($result); - return $row ["count"]; + return $row["count"]; } // CountList -function FindList ($type, $next, $lines) { +function FindList($type, $next, $lines) { global $db; global $userid; global $lines; $statement = "select * from list where type=\"$type\" and userid=\"$userid\" order by sequence limit $next, $lines"; - $result = mysql_query ($statement) + $result = mysql_query($statement) or DBError ("FindList: Unable to execute query: ", $statement); - $count = mysql_num_rows ($result); + $count = mysql_num_rows($result); - return array ($count, $result); + return array($count, $result); } // FindList -function Today2SQLDatetime () { +function Today2SQLDatetime() { return date ("Y-m-d H:i:s"); } // Today2SQLDatetime -function countem ($table, $condition) { +function countem($table, $condition) { $statement = "select count(distinct sender) as count from $table where $condition"; - $result = mysql_query ($statement) - or DBError ("countem: Unable to perform query: ", $statement); + $result = mysql_query($statement) + or DBError("countem: Unable to perform query: ", $statement); // How many rows are there? - $row = mysql_fetch_array ($result); + $row = mysql_fetch_array($result); - return $row ["count"]; + return $row["count"]; } // countem -function countlog ($condition="") { +function countlog($condition="") { global $userid; if ($condition != "") { - return countem ("log", "userid=\"$userid\" and " . $condition); + return countem("log", "userid=\"$userid\" and " . $condition); } else { - return countem ("log", "userid=\"$userid\""); + return countem("log", "userid=\"$userid\""); } // if } // countlog -function SubtractDays ($date, $nbr_days) { +function SubtractDays($date, $nbr_days) { } // SubtractDays -function GetStats ($nbr_days, $date = "") { +function GetStats($nbr_days, $date = "") { global $Types; if ($date == "") { - $date = Today2SQLDatetime (); + $date = Today2SQLDatetime(); } // if while ($nbr_days > 0) { - $ymd = substr ($date, 0, 10); + $ymd = substr($date, 0, 10); $sod = $ymd . " 00:00:00"; $eod = $ymd . " 23:59:59"; foreach ($Types as $type) { $condition = "type=\"$type\" and (timestamp > \"$sod\" and timestamp < \"$eod\")"; - $stats[$type] = countlog ($condition); + $stats[$type] = countlog($condition); } # foreach $dates[$ymd] = &$stats; - $date = SubtractDays ($date, 1); + $date = SubtractDays($date, 1); $nbr_days--; } # while return $dates; } # GetStats -function displayquickstats () { - $today = substr (Today2SQLDatetime (), 0, 10); - $dates = getquickstats ($today); - $current_time = date ("g:i a"); +function displayquickstats() { + $today = substr (Today2SQLDatetime(), 0, 10); + $dates = getquickstats($today); + $current_time = date("g:i a"); // Start quickstats print "
"; print "

Today's Activity

"; print "

as of $current_time

"; - $processed = $dates[$today]["processed"]; - $returned = $dates[$today]["returned"]; - $returned_pct = $processed == 0 ? 0 : + $processed = $dates[$today]["processed"]; + $returned = $dates[$today]["returned"]; + $returned_pct = $processed == 0 ? 0 : number_format ($returned / $processed * 100, 1, ".", ""); - $whitelist = $dates[$today]["whitelist"]; - $whitelist_pct = $processed == 0 ? 0 : + $whitelist = $dates[$today]["whitelist"]; + $whitelist_pct = $processed == 0 ? 0 : number_format ($whitelist / $processed * 100, 1, ".", ""); - $blacklist = $dates[$today]["blacklist"]; - $blacklist_pct = $processed == 0 ? 0 : + $blacklist = $dates[$today]["blacklist"]; + $blacklist_pct = $processed == 0 ? 0 : number_format ($blacklist / $processed * 100, 1, ".", ""); - $registered = $dates[$today]["registered"]; - $mailloop = $dates[$today]["mailloop"]; - $nulllist = $dates[$today]["nulllist"]; - $nulllist_pct = $processed == 0 ? 0 : + $registered = $dates[$today]["registered"]; + $mailloop = $dates[$today]["mailloop"]; + $nulllist = $dates[$today]["nulllist"]; + $nulllist_pct = $processed == 0 ? 0 : number_format ($nulllist / $processed * 100, 1, ".", ""); $returned_link = $returned == 0 ? 0 : @@ -274,23 +274,23 @@ print <<"; if (!isset ($userid) || $userid == "") { @@ -306,7 +306,7 @@ function NavigationBar ($userid) {
END; } else { - $Userid = ucfirst ($userid); + $Userid = ucfirst($userid); print <<Welcome $Userid END; - displayquickstats (); + displayquickstats(); print << @@ -349,15 +349,15 @@ END; print ""; } # NavigationBar -function GetUserLines () { +function GetUserLines() { global $userid; $lines = 10; $statement = "select value from useropts where userid=\"$userid\" and name=\"Page\""; - $result = mysql_query ($statement) - or DBError ("GetUserLines: Unable to execute query: ", $statement); + $result = mysql_query($statement) + or DBError("GetUserLines: Unable to execute query: ", $statement); $row = mysql_fetch_array ($result); @@ -368,15 +368,15 @@ function GetUserLines () { return $lines; } // GetUserLines -function DisplayList ($type, $next, $lines) { +function DisplayList($type, $next, $lines) { global $userid; global $total; global $last; - $statement="select * from list where userid=\"$userid\" and type=\"$type\" order by sequence limit $next, $lines"; + $statement = "select * from list where userid=\"$userid\" and type=\"$type\" order by sequence limit $next, $lines"; - $result = mysql_query ($statement) - or DBError ("DisplayList: Unable to execute query: ", $statement); + $result = mysql_query($statement) + or DBError("DisplayList: Unable to execute query: ", $statement); for ($i = 0; $i < $lines; $i++) { $row = mysql_fetch_array ($result); @@ -385,40 +385,40 @@ function DisplayList ($type, $next, $lines) { break; } // if - $sequence = $row ["sequence"]; - $username = $row ["pattern"] == "" ? " " : $row ["pattern"]; - $domain = $row ["domain"] == "" ? " " : $row ["domain"]; - $hit_count = $row ["hit_count"] == "" ? " " : $row ["hit_count"]; - $last_hit = $row ["last_hit"] == "" ? " " : $row ["last_hit"]; - $comments = $row ["comment"] == "" ? " " : $row ["comment"]; + $sequence = $row["sequence"]; + $username = $row["pattern"] == "" ? " " : $row["pattern"]; + $domain = $row["domain"] == "" ? " " : $row["domain"]; + $hit_count = $row["hit_count"] == "" ? " " : $row["hit_count"]; + $last_hit = $row["last_hit"] == "" ? " " : $row["last_hit"]; + $comments = $row["comment"] == "" ? " " : $row["comment"]; // Remove time from last hit - $last_hit = substr ($last_hit, 0, (strlen ($last_hit) - strpos ($last_hit, " ")) + 1); + $last_hit = substr($last_hit, 0, (strlen($last_hit) - strpos($last_hit, " ")) + 1); // Reformat last_hit $last_hit = substr ($last_hit, 5, 2) . "/" . substr ($last_hit, 8, 2) . "/" . substr ($last_hit, 0, 4); - $leftclass = ($i == $lines || $sequence == $total || $sequence == $last) ? + $leftclass = ($i == $lines || $sequence == $total || $sequence == $last) ? "tablebottomleft" : "tableleftdata"; - $dataclass = ($i == $lines || $sequence == $total || $sequence == $last) ? + $dataclass = ($i == $lines || $sequence == $total || $sequence == $last) ? "tablebottomdata" : "tabledata"; $rightclass = ($i == $lines || $sequence == $total || $sequence == $last) ? "tablebottomright" : "tablerightdata"; - print "" . $sequence . ""; + print "" . $sequence . ""; print "\n"; - print "" . $username . ""; + print "" . $username . ""; print "@"; - print "" . $domain . ""; - print "" . $hit_count . ""; - print "" . $last_hit . ""; - print "" . $comments . ""; + print "$domain"; + print "" . $hit_count . ""; + print "" . $last_hit . ""; + print "" . $comments . ""; print ""; } // for } // DisplayList -function MAPSHeader () { +function MAPSHeader() { print << @@ -434,7 +434,7 @@ function MAPSHeader () { END; } // MAPSHeader -function ListDomains ($top = 10) { +function ListDomains($top = 10) { global $userid; // Generate a list of the top 10 spammers by domain @@ -447,8 +447,8 @@ function ListDomains ($top = 10) { $statement = $statement . "group by domain order by nbr desc"; // Do the query - $result = mysql_query ($statement) - or DBError ("ListDomains: Unable to execute query: ", $statement); + $result = mysql_query($statement) + or DBError("ListDomains: Unable to execute query: ", $statement); print << @@ -493,7 +493,7 @@ END; END; } // ListDomains -function Space () { +function Space() { global $userid; // Tally up space used by $userid @@ -501,16 +501,16 @@ function Space () { $statement = "select * from email where userid = \"$userid\""; - $result = mysql_query ($statement) - or DBError ("Space: Unable to execute query: ", $statement); + $result = mysql_query($statement) + or DBError("Space: Unable to execute query: ", $statement); while ($row = mysql_fetch_array ($result)) { $msg_space = - strlen ($row["userid"]) + - strlen ($row["sender"]) + - strlen ($row["subject"]) + - strlen ($row["timestamp"]) + - strlen ($row["data"]); + strlen($row["userid"]) + + strlen($row["sender"]) + + strlen($row["subject"]) + + strlen($row["timestamp"]) + + strlen($row["data"]); $space = $space + $msg_space; } // while -- 2.17.1