From bf3e9aabef4e40c2b2b9931bc7252320205fb7b4 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Mon, 1 Jun 2015 12:15:56 +0200 Subject: [PATCH] [add] sort by service --- index.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/index.php b/index.php index 63d568c..11f27de 100644 --- a/index.php +++ b/index.php @@ -25,13 +25,13 @@ $database = $config['mysqldb']; $page = htmlspecialchars($_GET["page"]); $orderby = htmlspecialchars($_GET["orderby"]); // Connect to MySQL - if (!$db = mysqli_connect($db_host, $db_user, $db_pwd)) { - die("Can't connect to database"); - } - if (!mysqli_select_db($db,$database)) { - mysqli_close($db); - die("Can't select database"); - } +if (!$db = mysqli_connect($db_host, $db_user, $db_pwd)) { + die("Can't connect to database"); +} +if (!mysqli_select_db($db, $database)) { + mysqli_close($db); + die("Can't select database"); +} // Get some information from the database // Find IPs banned more than once $multiplebans = mysqli_query($db, "SELECT ip,COUNT(*) count,country FROM bans GROUP BY ip HAVING count > 1 ORDER BY count DESC"); @@ -71,22 +71,27 @@ if (!$multiplebans) { die("Query failed."); } // Order by IP -$allbans_ip = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ip"); +$allbans_ip = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ip, id"); if (!$multiplebans) { die("Query failed."); } // Order by Date -$allbans_date = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ban_date"); +$allbans_date = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ban_date, id"); if (!$multiplebans) { die("Query failed."); } // Order by Time -$allbans_time = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ban_time"); +$allbans_time = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY ban_time, id"); if (!$multiplebans) { die("Query failed."); } // Order by Country -$allbans_country = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY country"); +$allbans_country = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY country, id"); +if (!$multiplebans) { + die("Query failed."); +} +// Order by Service +$allbans_service = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country FROM bans ORDER BY service, id"); if (!$multiplebans) { die("Query failed."); } @@ -182,7 +187,7 @@ switch ($page) { echo "\t
\n"; echo "\t\t
\n"; echo "\t\t\t\n\t\t\t\t\n\t\t\t\n"; - echo "\t\t\t\n\t\t\t\tService\n\t\t\t\n"; + echo "\t\t\t\n\t\t\t\tService\n\t\t\t\n"; echo "\t\t\t\n\t\t\t\tIP\n\t\t\t\n"; echo "\t\t\t\n\t\t\t\tBan Date\n\t\t\t\n"; echo "\t\t\t\n\t\t\t\tBan Time\n\t\t\t\n"; @@ -229,6 +234,14 @@ switch ($page) { echo "\t\t
\n"; } break; + case "service" : + while ($row = mysqli_fetch_row($allbans_service)) { + echo "\t\t
\n"; + foreach ($row as $cell) + echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; + echo "\t\t
\n"; + } + break; } echo "\t
\n"; break; @@ -236,9 +249,9 @@ switch ($page) { echo "\n"; $stop = microtime(true); $total = round($stop - $start, 4); -echo $total, '
'; +echo 'Generate in ', $total, ' secondes
'; echo "\n"; echo "\n"; echo "\n";