Mirror repository metadata check
'Enterprise Linux 8',
'enterprise/7' => 'Enterprise Linux 7',
'enterprise/6' => 'Enterprise Linux 6',
'fedora/31' => 'Fedora 31',
'fedora/30' => 'Fedora 30',
'fedora/29' => 'Fedora 29',
];
$subs = [
'remi',
'test',
'php56',
];
$archs = [
'i386',
'x86_64',
];
$mirrors = [
'http://remi.mirrors.arminco.com/',
'http://remi.conetix.com.au/',
'http://mirrors.neterra.net/remi/',
'http://remi.schlundtech.de/',
'http://mirror.cedia.org.ec/remi/',
'http://mirror.uta.edu.ec/remi/',
'http://ftp.arnes.si/mirrors/remi/',
'http://mirrors.thzhost.com/remi/',
'http://fr2.rpmfind.net/linux/remi/',
'http://mirror.awanti.com/remi/',
'http://mirrors.netix.net/remi/',
'http://remi.mirrors.cu.be/',
'http://mirror.innosol.asia/remi/',
'http://mirror.neolabs.kz/remi/',
'http://mirror.veriteknik.net.tr/remi/',
'https://remi.mirror.ate.info/',
'https://mirrors.tuna.tsinghua.edu.cn/remi/',
'https://mirror.23m.com/remi/',
'http://repo1.dal.innoscale.net/remi/',
'http://repo1.sea.innoscale.net/remi/',
'http://repo1.ash.innoscale.net/remi/',
'http://mirror.bebout.net/remi/',
'https://mirror.oxilion.nl/remi/',
'https://remi.mirror.wearetriple.com/',
'http://mirror.upb.edu.co/remi/',
'https://mirrors.uni-ruse.bg/remi/',
'https://remi.mirror.karneval.cz/',
'https://mirror.netsite.dk/remi/',
'http://mirror.nsw.coloau.com.au/remi/',
'http://mirror.team-cymru.com/remi/',
'http://mirror.reconn.ru/remi/',
'http://mirrors.ukfast.co.uk/sites/remi/',
'https://mirror.netweaver.uk/remi/',
'http://mirror.xeonbd.com/remi/',
'http://ftp.riken.jp/Linux/remi/',
'https://mir01.syntis.net/remirepo/',
'http://mirrors.bytes.ua/remi/',
'https://mirror.hoster.kz/remi/',
'http://remirepo.reloumirrors.net/',
'https://mirror.pit.teraswitch.com/remi/',
'https://mirror.sjc02.svwh.net/remi/',
'https://mirror.serverion.com/remi/',
'http://remi.mirror.liteserver.nl/',
'https://mirror.marwan.ma/remi/',
'https://remi.mivzakim.net/',
'https://remi.mirror.digitalpacific.com.au/',
'https://remi.srv.magticom.ge/',
'http://merlin.fit.vutbr.cz/mirrors/remi/',
'https://mirror.telkomuniversity.ac.id/remi/',
'https://mirrors.ptisp.pt/remi/',
'https://mirrors.chroot.ro/remi/',
'https://mirrors.upr.edu/remi/',
'http://mirror.digitalnova.at/remi/',
'http://mirror.yer.az/remi/',
'https://mirror.dk.team.blue/remi/',
'https://mirror.dogado.de/remi/',
'https://mirror.docker.ru/remi/',
];
$deprecated = [
'http://mirrors.mediatemple.net/remi/',
'http://remi.xpg.com.br/',
'http://ap.stykers.moe/remi/',
'http://mirrors.mivocloud.com/remi/',
'http://nl.mirror.babylon.network/remi/',
'http://fr.mirror.babylon.network/remi/',
'http://ca.mirror.babylon.network/remi/',
'http://mirror.h1host.ru/remi/',
'http://mirror5.layerjet.com/remi/',
'http://mirror.smartmedia.net.id/remi/',
'http://remi.check-update.co.uk/',
'http://iut-info.univ-reims.fr/remirpms/',
'http://mirror.lablus.com/remi/',
'http://remi.kazukioishi.net/',
'http://remirpm.mirror.gymkl.ch/',
'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) {
$ctx = stream_context_create([
'http' => [
'timeout' => 4,
]
]);
$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 ERR_CONTENT;
}
if (isset($_GET['mirror']) && isset($repos[$_GET['mirror']])) {
$path = $_GET['mirror'];
} else {
$path = 'enterprise/8';
}
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 %d mirrors of %s (%s)\n" : "
%s - %s
\n"), count($mirrors), $name, date('r', $ref));
if (!$cli) echo "
\n";
foreach ($mirrors as $mirror) {
if ($_SERVER['argc']>1 && !strpos($mirror, $_SERVER['argv'][1])) {
continue;
}
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 ($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));
} 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 ($loc == ERR_OFFLINE) {
printf("
- %s Unreachable
\n", $mirror, $mirror);
} else if ($loc == ERR_CONTENT) {
printf("- %s Corrupted
\n", $mirror, $mirror);
} else 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) {
$nb=count($pids);
while (count($pids)) {
if (posix_isatty(STDOUT)) {
printf("Wait %d\r", count($pids));
}
$pid = pcntl_wait($status);
if ($pid<0) {
die("Cound not wait\n");
exit (1);
} else {
unset($pids[$pid]);
}
}
if ($nb) printf("%d mirrors checked.\n", $nb);
} else {
echo "
\n";
}
} else {
printf("
%s - not found
\n", $name);
}
if (!$cli) {
?>