Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-07-10 09:03:22 +0200
committerErich Eckner <git@eckner.net>2018-07-10 09:03:22 +0200
commit190727abb94c75911cf67624ee7020ff66a19451 (patch)
tree2d448cdd91318e09db1bb1d24836a77d202300d3
parent272bae0fa77072f4e6676bb49ce9ba815d93940c (diff)
mirrors/active.php new
-rw-r--r--mirrors/active.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/mirrors/active.php b/mirrors/active.php
new file mode 100644
index 0000000..2294fb4
--- /dev/null
+++ b/mirrors/active.php
@@ -0,0 +1,49 @@
+<?php
+require_once "../init.php";
+
+require_once BASE . "/lib/mysql.php";
+require_once BASE . "/lib/format.php";
+
+$result = mysql_run_query(
+ "SELECT " .
+ "`mirror_statuses`.`protocol`," .
+ "`mirror_statuses`.`url`," .
+ "`mirror_statuses`.`country`," .
+ "`mirror_statuses`.`country_code`," .
+ "`mirror_statuses`.`last_sync`," .
+ "`mirror_statuses`.`start`," .
+ "`mirror_statuses`.`isos`," .
+ "`mirror_statuses`.`ipv4`," .
+ "`mirror_statuses`.`ipv6`," .
+ "`mirror_statuses`.`active`," .
+ "(`mirror_statuses`.`active` AND (`mirror_statuses`.`start` > UNIX_TIMESTAMP(NOW()) - 3600)) AS `recently_active`" .
+ " FROM `mirror_statuses`" .
+ " JOIN (" .
+ "SELECT " .
+ "`mirror_statuses`.`url`," .
+ "MAX(`mirror_statuses`.`start`) AS `start`" .
+ " FROM `mirror_statuses` GROUP BY `url`" .
+ ") AS `max_mirror`" .
+ " ON `mirror_statuses`.`url`=`max_mirror`.`url`" .
+ " AND `mirror_statuses`.`start`=`max_mirror`.`start`" .
+ " ORDER BY `mirror_statuses`.`url`"
+);
+
+while($row = $result->fetch_assoc()) {
+ foreach (array(
+ "start",
+ "isos",
+ "ipv4",
+ "ipv6",
+ "active"
+ ) as $key)
+ $row[$key] = floatval($row[$key]);
+ foreach (array(
+ "start",
+ "last_sync"
+ ) as $key)
+ $row[$key] = gmdate("Y-m-d\TH:i:s\Z", $row[$key]);
+ $content[] = $row;
+}
+
+export_as_requested($content);