summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-07-10 13:32:19 +0200
committerErich Eckner <git@eckner.net>2018-07-10 13:32:19 +0200
commitcf3d9db537f828b07f39abad77e35b51403746b3 (patch)
tree60e71400253c88a1818c3435627781f65337ceaa
parentfe4b8ae2af89ca33e5890c542b3121edcaeb19b5 (diff)
downloadarchweb32-cf3d9db537f828b07f39abad77e35b51403746b3.tar.xz
mirrors/index.php: make list sortable
-rw-r--r--mirrors/index.php59
1 files changed, 53 insertions, 6 deletions
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");
<table class="results">
<thead>
<tr>
- <th>Server</th>
- <th>Country</th>
- <th>ISOs</th>
- <th>Protocols</th>
+<?php
+ foreach ($sorts as $get => $sort) {
+ print " <th>\n";
+ print " <a href=\"/mirrors/?";
+ print substr(str_replace(
+ "&sort=".$_GET["sort"]."&",
+ "&",
+ "&".$_SERVER["QUERY_STRING"]."&"
+ ),1)."sort=";
+ if ($_GET["sort"] == $get)
+ print "-";
+ print $get."\" title=\"Sort package by ".$sort["title"]."\">".$sort["label"]."</a>\n";
+ print " </th>\n";
+ }
+?>
</tr>
</thead>
<tbody>