aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Downloads.php
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-08-23 10:50:04 +0000
committerRomain d'Alverny <rda@mageia.org>2012-08-23 10:50:04 +0000
commit698c021e5b3a16863cfce4e2b8f4a6f78db63e4f (patch)
tree92d7e2ba027de0031a713a9572994be2277f175e /lib/Downloads.php
parentc8270f2d1966a6f67a3588513e1aef79402df82d (diff)
downloadwww-698c021e5b3a16863cfce4e2b8f4a6f78db63e4f.tar
www-698c021e5b3a16863cfce4e2b8f4a6f78db63e4f.tar.gz
www-698c021e5b3a16863cfce4e2b8f4a6f78db63e4f.tar.bz2
www-698c021e5b3a16863cfce4e2b8f4a6f78db63e4f.tar.xz
www-698c021e5b3a16863cfce4e2b8f4a6f78db63e4f.zip
cleaner reorg of get_all_mirrors()
Diffstat (limited to 'lib/Downloads.php')
-rw-r--r--lib/Downloads.php62
1 files changed, 31 insertions, 31 deletions
diff --git a/lib/Downloads.php b/lib/Downloads.php
index 1a31c8082..7d8026aa2 100644
--- a/lib/Downloads.php
+++ b/lib/Downloads.php
@@ -91,51 +91,51 @@ class Downloads
* (keys are: "$country" and "_C:$continent"),
* and return it.
*
+ * Note that the mirrors list doesn't change with versions, for now;
+ * it's a full or nothing list.
+ *
* @return array
*/
public static function get_all_mirrors()
{
- $prod = true;
+ $prod = true;
$cache_file = realpath(__DIR__ . '/cached.list.php');
if ($prod) {
require $cache_file;
- return $mirrors;
- }
- // @todo cache this!
- $data = file('http://mirrors.mageia.org/api/mageia.1.i586.list');
- $mirrors3 = array();
- foreach ($data as $line) {
- $line = explode(',', trim($line));
- $m = array();
- foreach ($line as $val) {
- $val = explode('=', trim($val));
- $m[$val[0]] = $val[1];
- }
- $pu = parse_url($m['url']);
- if (in_array($pu['scheme'], array('http', 'ftp'))) {
+ } else {
+ $data = file('http://mirrors.mageia.org/api/mageia.1.i586.list');
+ $mirrors = array();
+ foreach ($data as $line) {
+ $line = explode(',', trim($line));
+ $m = array();
+ foreach ($line as $val) {
+ $val = explode('=', trim($val));
+ $m[$val[0]] = $val[1];
+ }
+ $pu = parse_url($m['url']);
+ if (in_array($pu['scheme'], array('http', 'ftp'))) {
- $item = array(
- 'city' => isset($m['city']) ? $m['city'] : '?',
- 'continent' => isset($m['continent']) ? $m['continent'] : '?',
- 'zone' => $m['zone'],
- // BEWARE of the path substitution here. Must match.
- 'url' => str_replace('/distrib/1/i586', '', $m['url'])
- );
+ $item = array(
+ 'city' => isset($m['city']) ? $m['city'] : '?',
+ 'continent' => isset($m['continent']) ? $m['continent'] : '?',
+ 'zone' => $m['zone'],
+ // BEWARE of the path substitution here. Must match.
+ 'url' => str_replace('/distrib/1/i586', '', $m['url'])
+ );
- $mirrors3[$m['country']][] = $item;
- $mirrors3['_C:' . $m['continent']][] = $item;
+ $mirrors[$m['country']][] = $item;
+ $mirrors['_C:' . $m['continent']][] = $item;
+ }
}
- }
- /*
- file_put_contents($cache_file,
- sprintf('<?php $mirrors = %s; ?>',
- var_export($mirrors3, true)));
- //*/
+ file_put_contents($cache_file,
+ sprintf('<?php $mirrors = %s; ?>',
+ var_export($mirrors, true)));
+ }
- return $mirrors3;
+ return $mirrors;
}
/**