index : archweb32 | |
Archlinux32 website | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | mirrors.php | 116 |
diff --git a/mirrors.php b/mirrors.php index 0a57ce6..40a54f3 100644 --- a/mirrors.php +++ b/mirrors.php @@ -26,7 +26,7 @@ array_splice( if (count($uri_parts) == 0) { // index $cutoff = 3600; - + $sorts = array( "server" => array( "title" => "server", @@ -52,7 +52,7 @@ if (count($uri_parts) == 0) { // index $query = "SELECT " . - "GROUP_CONCAT(`l_ms`.`protocol`) AS `protocols`," . + "GROUP_CONCAT(DISTINCT `l_ms`.`protocol`) AS `protocols`," . "SUBSTRING(`l_ms`.`url`,LENGTH(`l_ms`.`protocol`)+4) AS `url`," . "`l_ms`.`country`," . "`l_ms`.`country_code`," . @@ -121,30 +121,34 @@ if (count($uri_parts) == 0) { // index <?php $oddity = "odd"; - foreach ($rows as $row) { - print " <tr class=\"" . $oddity ."\">\n"; - print " <td>\n"; - print " " . $row["url"] . "\n"; - print " </td>\n"; - print " <td class=\"country\">\n"; - print " <span class=\"fam-flag fam-flag-" . $row["country_code"] . "\" title=\"" . $row["country"] . "\">\n"; - print " </span>\n"; - print " " . $row["country"] . "\n"; - print " </td>\n"; - print " <td>\n"; - if ($row["isos"]) - print " Yes\n"; - else - print " No\n"; - print " </td>\n"; - print " <td class=\"wrap\">\n"; - print " " . $row["protocols"] . "\n"; - print " </td>\n"; - print " </tr>\n"; - if ($oddity == "odd") - $oddity = "even"; - else - $oddity = "odd"; + if (isset($rows)) { + foreach ($rows as $row) { + print " <tr class=\"" . $oddity ."\">\n"; + print " <td>\n"; + print " " . $row["url"] . "\n"; + print " </td>\n"; + print " <td class=\"country\">\n"; + print " <span class=\"fam-flag fam-flag-" . $row["country_code"] . "\" title=\"" . $row["country"] . "\">\n"; + print " </span>\n"; + print " " . $row["country"] . "\n"; + print " </td>\n"; + print " <td>\n"; + if ($row["isos"]) + print " Yes\n"; + else + print " No\n"; + print " </td>\n"; + print " <td class=\"wrap\">\n"; + print " " . $row["protocols"] . "\n"; + print " </td>\n"; + print " </tr>\n"; + if ($oddity == "odd") + $oddity = "even"; + else + $oddity = "odd"; + } + } else { + print "There is no data, as no mirror checks run in the last " . $cutoff . " seconds."; } ?> @@ -160,7 +164,8 @@ if (count($uri_parts) == 0) { // index if ($uri_parts[0] == 'status') { - $cutoff = 86400; +// $cutoff = 86400; + $cutoff = 120000; $result = mysql_run_query( "SELECT " . @@ -228,18 +233,63 @@ if ($uri_parts[0] == 'status') { $content = array( "cutoff" => $cutoff, - "check_frequency" => $cutoff/$max_count, + "check_frequency" => (($max_count!=0)?($cutoff/$max_count):0), "num_checks" => $max_count, "last_check" => gmdate("Y-m-d\TH:i:s.v\Z",$last_check), //"2018-06-15T07:25:06.741Z", // "version" => 3, - "urls" => $urls + "urls" => (isset($urls)?$urls:[]) ); if (count($uri_parts) == 1) { // human readable - // TODO - header('HTTP/1.1 303 See Other'); - header('Location: /mirrors/status/json/'); - die(); + print_header("Mirror Status"); + print <<<EOF + <div id="dev-mirrorlist" class="box"> + <h2>Mirror Status</h2> +EOF; + if ($max_count==0) { + print "No results as there was no mirror check running in the last " . $cutoff . " seconds."; + } else { + print <<<EOF + <p> + This page reports the status of all known, public, and active ArchLinux32 mirrors. + All data on this page reflects the status of the mirrors within the last $cutoff seconds. + All listed times are UTC. The check script runs on a regular basis and polls for + the lastsync file in the root of our repository layout. This file is regularly + updated on the central repository, so checking the value within allows one + to see if the mirror has synced recently. This page contains several pieces + of information about each mirror. + </p> + <p> + The last mirror check ran at ${content['last_check']} UTC. + Checks have ran ${content['num_checks']} times in the last + $cutoff seconds at an average interval of ${content['check_frequency']} seconds. + </p> + <p> + This data is also available in <a href="/mirrors/status/json/">JSON</a> + or <a href="/mirrors/status/tsv/">TSV</a> format. The units of all + time/duration values are in seconds; date/time values are UTC. + </p> + <h3>Successfully Syncing Mirrors</h3> + <table class="results"> + <thead> + <tr> +protocol url country country_code last_sync start delay duration_avg duration_stddev isos ipv4 ipv6 active recently_active completion_pct count score +EOF; + print <<<EOF + </tr> + </thead> + </table> +EOF; + print <<<EOF + </div> + <pre> +EOF; + } + print json_encode($content, JSON_PRETTY_PRINT); + print <<<EOF + </pre> +EOF; + exit( ); } // human readable if (!export_as_requested( |