summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
Diffstat (limited to 'mirrors')
-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>