aboutsummaryrefslogtreecommitdiffstats
path: root/mirrorlist/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'mirrorlist/index.php')
-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";