aboutsummaryrefslogtreecommitdiffstats
path: root/mirrorlist
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2016-06-05 14:48:24 +0200
committerfilip <filip.komar@gmail.com>2016-06-05 14:48:24 +0200
commit5552b0c89cf71b9b847f9c424255255c40c59877 (patch)
treef77a599a033829f826399d90817759f2b8a94512 /mirrorlist
parent7907ddd13e53da6b7b064ea4c9462520d2143437 (diff)
downloadwww-5552b0c89cf71b9b847f9c424255255c40c59877.tar
www-5552b0c89cf71b9b847f9c424255255c40c59877.tar.gz
www-5552b0c89cf71b9b847f9c424255255c40c59877.tar.bz2
www-5552b0c89cf71b9b847f9c424255255c40c59877.tar.xz
www-5552b0c89cf71b9b847f9c424255255c40c59877.zip
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
Diffstat (limited to 'mirrorlist')
-rw-r--r--mirrorlist/index.php52
1 files changed, 22 insertions, 30 deletions
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 @@
<?php
-
require realpath(__DIR__ . '/../lib/Downloads.php');
function get($s){
- return $string_var = (string) filter_input(INPUT_GET, $s, FILTER_SANITIZE_STRING);
+ return (string) filter_input(INPUT_GET, $s, FILTER_SANITIZE_STRING);
}
-//TODO
function check($array){
-foreach ($array as $key => $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";