From cf3d9db537f828b07f39abad77e35b51403746b3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 10 Jul 2018 13:32:19 +0200 Subject: mirrors/index.php: make list sortable --- mirrors/index.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'mirrors') diff --git a/mirrors/index.php b/mirrors/index.php index 617967c..b74b25c 100644 --- a/mirrors/index.php +++ b/mirrors/index.php @@ -6,7 +6,30 @@ require_once BASE . "/lib/style.php"; $cutoff = 3600; -$result = mysql_run_query( +$sorts = array( + "server" => array( + "title" => "server", + "label" => "Server", + "mysql" => "`url`" + ), + "country" => array( + "title" => "country", + "label" => "Country", + "mysql" => "`l_ms`.`country_code`" + ), + "isos" => array( + "title" => "wether isos are available", + "label" => "ISOs", + "mysql" => "`l_ms`.`isos`" + ), + "protocols" => array( + "title" => "available protocols", + "label" => "Protocols", + "mysql" => "`protocols`" + ) +); + +$query = "SELECT " . "GROUP_CONCAT(`l_ms`.`protocol`) AS `protocols`," . "SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4) AS `url`," . @@ -26,7 +49,20 @@ $result = mysql_run_query( " JOIN `mirror_statuses` AS `l_ms`" . " ON `ls`.`url`=`l_ms`.`url`" . " AND `ls`.`start`=`l_ms`.`start`" . - " GROUP BY SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4)" + " GROUP BY `url`" . + " ORDER BY "; + +if (isset($_GET["sort"])) { + if (isset($sorts[$_GET["sort"]]["mysql"])) + $query .= $sorts[$_GET["sort"]]["mysql"] . ","; + elseif (isset($sorts[substr($_GET["sort"],1)]["mysql"])) + $query .= $sorts[substr($_GET["sort"],1)]["mysql"] . " DESC,"; +} + +$query .= "`url`"; + +$result = mysql_run_query( + $query ); $last_check = 0; @@ -43,10 +79,21 @@ print_header("Mirror Overview"); - - - - + $sort) { + print " \n"; + } +?> -- cgit v1.2.3
ServerCountryISOsProtocols\n"; + print " ".$sort["label"]."\n"; + print "