diff options
-rwxr-xr-x | check.php | 45 |
1 files changed, 33 insertions, 12 deletions
@@ -1,5 +1,9 @@ #!/usr/bin/env php <?php + +define('ERR_OFFLINE', -1); +define('ERR_CONTENT', -2); + $cli = (php_sapi_name()=="cli"); if ($cli) { chdir(__DIR__); @@ -10,7 +14,7 @@ if ($cli) { <head> <meta content="text/html; charset=utf-8" http-equiv="content-type" /> <title>Les RPM de Remi - Mirror check</title> - <link href="fedora/17/remi/i386/repoview/layout/repostyle.css" type="text/css" rel="stylesheet" /> + <link href="enterprise/8/remi/x86_64/repoview/layout/repostyle.css" type="text/css" rel="stylesheet" /> <meta content="index,follow" name="robots" /> <link rel="shortcut icon" href="/favicon.ico" /> </head> @@ -31,12 +35,12 @@ if ($cli) { <?php } $repos = array( + 'enterprise/8' => 'Enterprise Linux 8', 'enterprise/7' => 'Enterprise Linux 7', 'enterprise/6' => 'Enterprise Linux 6', - 'enterprise/5' => 'Enterprise Linux 5', - 'fedora/22' => 'Fedora 22', - 'fedora/21' => 'Fedora 21', - 'fedora/20' => 'Fedora 20', + 'fedora/31' => 'Fedora 31', + 'fedora/30' => 'Fedora 30', + 'fedora/29' => 'Fedora 29', ); $subs = array( 'remi', @@ -120,16 +124,25 @@ $deprecated = array( 'http://mirror.pw/remi/', ); function getRepoTime($uri) { - $xml = @simplexml_load_file($uri.'/repodata/repomd.xml'); - if ($xml && $xml->revision) { + $ctx = stream_context_create([ + 'http' => [ + 'timeout' => 1.5, + ] + ]); + $txt = @file_get_contents($uri . '/repodata/repomd.xml', false, $ctx); + if (!$txt) { + return ERR_OFFLINE; + } + $xml = @simplexml_load_string($txt); + if ($xml && $xml->revision>100000) { return intval($xml->revision); } - return 0; + return ERR_CONTENT; } if (isset($_GET['mirror']) && isset($repos[$_GET['mirror']])) { $path = $_GET['mirror']; } else { - $path = 'enterprise/7'; + $path = 'enterprise/8'; } if (isset($_GET['repo']) && in_array($_GET['repo'], $subs)) { $repo = $_GET['repo']; @@ -170,7 +183,11 @@ if ($ref) { } else { // Child $pids = array(); $loc = getRepoTime($mirror.$full); - if ($ref == $loc) { + if ($loc == ERR_OFFLINE) { + printf("%50.50s : ** Unreachable **\n", $mirror); + } else if ($loc == ERR_CONTENT) { + printf("%50.50s : ** Corrupted **\n", $mirror); + } else if ($ref == $loc) { printf("%50.50s : Ok\n", $mirror); } else if ($loc) { printf("%50.50s : %s\n", $mirror, date('r', $loc)); @@ -183,9 +200,13 @@ if ($ref) { } flush(); $host = parse_url($mirror, PHP_URL_HOST); - printf("<li><a href='%s'>%s</a> ", $mirror, $host); + //printf("<li><a href='%s'>%s</a> ", $mirror, $host); $loc = getRepoTime($mirror.$full); - if ($ref == $loc) { + if ($loc == ERR_OFFLINE) { + printf("<li><a href='%s'>%s</a> <b>Unreachable</b></li>\n", $mirror, $mirror); + } else if ($loc == ERR_CONTENT) { + printf("<li><a href='%s'>%s</a> <b>Corrupted</b></li>\n", $mirror, $mirror); + } else if ($ref == $loc) { printf("<li><a href='%s'>%s</a> Ok</li>\n", $mirror, $mirror); } else if ($loc) { printf("<li><a href='%s'>%s</a> %s</li>\n", $mirror, $mirror, date('r', $loc)); |