From 07d8c7a53af0b28aac542d5135cc63ad1a2a7b7b Mon Sep 17 00:00:00 2001
From: Andreas Baumann \n";
- print " " . $row["url"] . "\n";
- print " \n";
- print " \n";
- print " \n";
- print " \n";
- print " " . $row["country"] . "\n";
- print " \n";
- print " \n";
- if ($row["isos"])
- print " Yes\n";
- else
- print " No\n";
- print " \n";
- print " \n";
- print " " . $row["protocols"] . "\n";
- print " \n";
- print " \n";
- if ($oddity == "odd")
- $oddity = "even";
- else
- $oddity = "odd";
+ if (isset($rows)) {
+ foreach ($rows as $row) {
+ print " \n";
+ print " \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 <<\n";
+ print " " . $row["url"] . "\n";
+ print " \n";
+ print " \n";
+ print " \n";
+ print " \n";
+ print " " . $row["country"] . "\n";
+ print " \n";
+ print " \n";
+ if ($row["isos"])
+ print " Yes\n";
+ else
+ print " No\n";
+ print " \n";
+ print " \n";
+ print " " . $row["protocols"] . "\n";
+ print " \n";
+ print " Mirror Status
+EOF;
+ if ($max_count==0) {
+ print "No results as there was no mirror check running in the last " . $cutoff . " seconds.";
+ } else {
+ print <<
+ 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. +
++ This data is also available in JSON + or TSV format. The units of all + time/duration values are in seconds; date/time values are UTC. +
++EOF; + } + print json_encode($content, JSON_PRETTY_PRINT); + print <<+EOF; + exit( ); } // human readable if (!export_as_requested( -- cgit v1.2.3-70-g09d2