aboutsummaryrefslogtreecommitdiffstats
path: root/mirrorlist/index.php
blob: dd8e3269b47c1c2107130cfed976879f1fe03b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

require realpath(__DIR__ . '/../lib/Downloads.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 = "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){
	
	$oute = check($arraycheck);
	$out= str_replace('MIRROR', $dl['mirror_url'], $link);
	//print_r($out);
}else{
	$out = "Invalid options";
}
if ($oute){
	echo $oute;}
else{
	echo $out;
}