aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mirrorlist/index.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/mirrorlist/index.php b/mirrorlist/index.php
new file mode 100644
index 000000000..69614a769
--- /dev/null
+++ b/mirrorlist/index.php
@@ -0,0 +1,65 @@
+<?php
+
+require realpath(__DIR__ . '/../lib/Downloads.php');
+require realpath(__DIR__ . '/../lib/mga_geoip.php');
+
+function get($s){
+ return $string_var = (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 = array("Error" => "Error $key: $getvar - not in list - $list");
+ break;
+ }
+}
+ return $out;
+}
+
+
+
+$source = $debug = false;
+
+$release = get('release');
+$arch = get('arch');
+$section = get('section');
+$repo = get('repo');
+$debug = get('debug');
+$source = get('source');
+
+$wsd = new Downloads();
+$dl = $wsd->prepare_download(true, null);
+
+$arraycheck =array(
+'release' => array('5', '6', 'cauldron'),
+'arch' => array('i586', 'x86_64', 'SRPMS', 'armv5tl', 'armv7hl'),
+'section' => array('core', 'nonfree', 'tainted'),
+'repo' => array('release', 'updates', 'updates_testing', 'backports', 'backports_testing'),
+);
+
+if ($source){
+ $link = "MIRROR/distrib/$release/SRPMS/media/$section/$repo/";
+}elseif ($debug){
+ $link = "MIRROR/distrib/$release/$arch/media/debug/$section/$repo/";
+}else{
+ $link = "MIRROR/distrib/$release/$arch/media/$section/$repo/";
+}
+
+
+if ($release && $arch && $section && $repo){
+
+ $out = str_replace('MIRROR', $dl['mirror_url'], $link);
+ //$out = check($arraycheck);
+ //print_r($out);
+}else{
+ $out = "Invalid options";
+}
+echo $out;
+