aboutsummaryrefslogtreecommitdiffstats
path: root/en/downloads/get/lib.php
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2011-11-23 22:53:13 +0000
committerRomain d'Alverny <rda@mageia.org>2011-11-23 22:53:13 +0000
commit66875da97b0db2fcb9431e78bd102e92eeb5bb33 (patch)
tree6286f7ae6c5568c5e59988b3b458f78570b39a5e /en/downloads/get/lib.php
parent48631ff7ba2b341e01b453aa9051c32dcaca0f67 (diff)
downloadwww-66875da97b0db2fcb9431e78bd102e92eeb5bb33.tar
www-66875da97b0db2fcb9431e78bd102e92eeb5bb33.tar.gz
www-66875da97b0db2fcb9431e78bd102e92eeb5bb33.tar.bz2
www-66875da97b0db2fcb9431e78bd102e92eeb5bb33.tar.xz
www-66875da97b0db2fcb9431e78bd102e92eeb5bb33.zip
next download redirector - not to be used yet
Diffstat (limited to 'en/downloads/get/lib.php')
-rw-r--r--en/downloads/get/lib.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/en/downloads/get/lib.php b/en/downloads/get/lib.php
new file mode 100644
index 000000000..527675d81
--- /dev/null
+++ b/en/downloads/get/lib.php
@@ -0,0 +1,72 @@
+<?php
+/**
+*/
+
+$countries = array(
+ 'AU' => 'Australia',
+ 'BE' => 'Belgium',
+ 'BR' => 'Brasil',
+ 'CA' => 'Canada',
+ 'CH' => 'Switzerland',
+ 'CN' => 'China',
+ 'CZ' => 'Czechia',
+ 'DE' => 'Deutschland',
+ 'FR' => 'France',
+ 'GR' => 'Greece',
+ 'GT' => 'Guatemala',
+ 'JP' => 'Japan',
+ 'NC' => 'Nouvelle-Calédonie',
+ 'NL' => 'Nederlands',
+ 'TW' => 'Taiwan',
+ 'UK' => 'the UK',
+ 'US' => 'the USA',
+);
+
+function get($s) {
+ return isset($_GET[$s]) ? trim($_GET[$s]) : null;
+}
+
+class NoProductFoundError extends Exception {}
+class NoMirrorFoundError extends Exception {}
+
+/**
+*/
+function get_info_for_product($product)
+{
+ $defs = parse_ini_file('definitions.ini', true);
+
+ if (array_key_exists($product, $defs)) {
+ return $defs[$product];
+ }
+
+ throw new NoProductFoundError;
+}
+
+/**
+ * Return mirrors for $file.
+ * First mirror returned is the preferred one for auto redirection.
+ *
+ * @param string $file id of the file to download/find a mirror for
+ * @param string $locale hint for selecting a mirror
+ * @param string $country hint for selecting a mirror
+ *
+ * @return array
+ * mirror(product):
+ * name
+ * host
+ * country
+ * city
+ * speed
+ * link
+*/
+function get_mirrors_for($file,
+ $locale = null, $country = null)
+{
+ include '../../../lib/Downloads.php';
+
+ $mirrors = Downloads::get_all_mirrors();
+ $wsd = new Downloads();
+ $one = $wsd->prepare_download(true, $country);
+
+ return array($one, $mirrors);
+} \ No newline at end of file