From 5552b0c89cf71b9b847f9c424255255c40c59877 Mon Sep 17 00:00:00 2001 From: filip Date: Sun, 5 Jun 2016 14:48:24 +0200 Subject: improve mirrorlist function + it now returns a shuffled list of ten mirrors with priority: within the country, then continent and others + exclude source server (distrib-coffee.ipsl.jussieu.fr) to drop it's DL load as a first choice in ISO and doc DL page and entirely from mirrorlist + some small bugfixes noted during testing + added some small code doc parts + some small code style polish --- mirrorlist/index.php | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'mirrorlist') diff --git a/mirrorlist/index.php b/mirrorlist/index.php index 082b8ce3a..2960a107a 100644 --- a/mirrorlist/index.php +++ b/mirrorlist/index.php @@ -1,27 +1,19 @@ $v) { -$getvar = get("$key"); - -$list = implode(", ", $v); - if (in_array($getvar, $v)) { - //$out = array($key => $getvar); - }else{ - $out = "Error $key: $getvar - not in list - $list"; - return $out; - } + foreach ($array as $key => $v) { + $getvar = get("$key"); + if (!in_array($getvar, $v)) { + $out = "Error $key: $getvar - not in list - " . implode(", ", $v); + return $out; + } + } } -} - - $source = $debug = false; @@ -41,24 +33,24 @@ $arraycheck =array( ); if ($source){ - $link = "MIRROR/distrib/$release/SRPMS/media/$section/$repo/"; + $link = "MIRROR/distrib/$release/SRPMS/media/$section/$repo/"; }elseif ($debug){ - $link = "MIRROR/distrib/$release/$arch/media/debug/$section/$repo/"; + $link = "MIRROR/distrib/$release/$arch/media/debug/$section/$repo/"; }else{ - $link = "MIRROR/distrib/$release/$arch/media/$section/$repo/"; + $link = "MIRROR/distrib/$release/$arch/media/$section/$repo/"; } - if ($release && $arch && $section && $repo){ - - $out = check($arraycheck); - if (empty($out)){ - $wsd = new Downloads(); - $dl = $wsd->prepare_download(true, null); - $out= str_replace('MIRROR', $dl['mirror_url'], $link); - //print_r($out); - } + $out = check($arraycheck); + if (empty($out)){ + $wsd = new Downloads(); + $dl = $wsd->prepare_download(true, null, true, false, true); + foreach ($dl['mirrors_list'] as $one_mirror) { + $out .= str_replace('MIRROR', $one_mirror, $link) . "\n"; + } + } }else{ - $out = "Invalid options"; + $out = "Invalid options"; } -echo $out; +header('Content-Type: text/plain'); +echo "$out\n"; -- cgit v1.2.1