From 4638f990ceb4b314ce15ddfcfeeb638432273c95 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 18 Dec 2015 10:33:16 +0100 Subject: initial import --- check.php | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 check.php (limited to 'check.php') diff --git a/check.php b/check.php new file mode 100644 index 00000000..d45ea3e0 --- /dev/null +++ b/check.php @@ -0,0 +1,207 @@ + + + + + + Les RPM de Remi - Mirror check + + + + + +
+ +

+ Blog | + Forums | + Repository +

+
+
+
+

Mirror repository metadata check

+ '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', +); +$subs = array( + 'remi', + 'test', + 'php56', +); +$archs = array( + 'i386', + 'x86_64', +); + +$mirrors = array( + 'http://remi.mirrors.arminco.com/', + 'http://remi.conetix.com.au/', + 'http://mirrors.neterra.net/remi/', + 'http://remi.xpg.com.br/', + 'http://remirpm.mirror.gymkl.ch/', + 'http://mirror5.layerjet.com/remi/', + 'http://remi.schlundtech.de/', + 'http://mirror.cedia.org.ec/remi/', + 'http://mirror.uta.edu.ec/remi/', + 'http://iut-info.univ-reims.fr/remirpms/', + 'http://mirror.smartmedia.net.id/remi/', + 'http://remi.kazukioishi.net/', + 'http://ftp.arnes.si/mirrors/remi/', + 'http://mirrors.thzhost.com/remi/', + 'http://remi.check-update.co.uk/', + 'http://mirrors.mediatemple.net/remi/', + 'http://fr2.rpmfind.net/linux/remi/', + 'http://mirror.awanti.com/remi/', + 'http://mirrors.netix.net/remi/', + 'http://mirror.h1host.ru/remi/', + 'http://remi.mirrors.cu.be/', + 'http://mirror.innosol.asia/remi/', +); +$deprecated = array( + 'http://remi.mirror.net.in/', + 'http://remi-mirror.dedipower.com/', + 'http://mirror.beyondhosting.net/Remi/', + 'http://mirrors.cicku.me/remi/', + 'http://remi.mirrors.hostinginnederland.nl/', + 'http://mirror.1000mbps.com/remi/', + 'http://mirrors.hustunique.com/remi/', + 'http://mirror.pw/remi/', +); +function getRepoTime($uri) { + $xml = simplexml_load_file($uri.'/repodata/repomd.xml'); + if ($xml && $xml->revision) { + return intval($xml->revision); + } + return 0; +} +if (isset($_GET['mirror']) && isset($repos[$_GET['mirror']])) { + $path = $_GET['mirror']; +} else { + $path = 'enterprise/7'; +} +if (isset($_GET['repo']) && in_array($_GET['repo'], $subs)) { + $repo = $_GET['repo']; +} else { + $repo = 'remi'; +} +if (isset($_GET['arch']) && in_array($_GET['arch'], $archs)) { + $arch = $_GET['arch']; +} else { + $arch = 'x86_64'; +} +$name = $repos[$path]; +$full = "$path/$repo/$arch"; + +if (!$cli) { + echo "
    \n"; + foreach ($repos as $rpath => $rname) { + if ($path == $rpath) { + printf("
  • %s
  • \n", $rname); + } else { + printf("
  • %s
  • ", $rpath, $rname); + } + } + echo "
\n"; +} +$pids = array(); +$ref = getRepoTime($full); +if ($ref) { + printf(($cli ? "Check of %s (%s)\n" : "

%s - %s

\n"), $name, date('r', $ref)); + if (!$cli) echo "
    \n"; + foreach ($mirrors as $mirror) { + if ($cli) { + $pid = pcntl_fork(); + if ($pid<0) { + die("Can't fork\n"); + } else if ($pid) { + $pids[$pid] = $pid; + } else { // Child + $pids = array(); + $loc = getRepoTime($mirror.$full); + if ($ref == $loc) { + printf("%50.50s: Ok\n", $mirror); + } else if ($loc) { + printf("%50.50s: %s\n", $mirror, date('r', $loc)); + } else { + printf("%50.50s: N/A\n", $mirror); + } + break; + } + continue; + } + flush(); + $host = parse_url($mirror, PHP_URL_HOST); + printf("
  • %s ", $mirror, $host); + $loc = getRepoTime($mirror.$full); + if ($ref == $loc) { + printf("
  • %s Ok
  • \n", $mirror, $mirror); + } else if ($loc) { + printf("
  • %s %s
  • \n", $mirror, $mirror, date('r', $loc)); + } else { + printf("
  • %s N/A
  • \n", $mirror, $mirror); + } + } + if ($cli) { + while (count($pids)) { + //printf("Wait %d\r", count($pids)); + $pid = pcntl_wait($status); + if ($pid<0) { + die("Cound not wait\n"); + exit (1); + } else { + unset($pids[$pid]); + } + } + } else { + echo "
\n"; + } +} else { + printf("

%s - not found

\n", $name); +} + +if (!$cli) { +?> +
+
+ +
+
+
+ + + +