aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Downloads.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2015-05-02 16:13:53 +0200
committerfilip <filip.komar@gmail.com>2015-05-02 16:13:53 +0200
commite31ec4507c495254239f11841d81c865e80e41a9 (patch)
treee0c62b5c7cc2e0564e7ae13d6ce8e82a6058da78 /lib/Downloads.php
parentc2158bebcc570b4f1a573122a546310268434e9e (diff)
downloadwww-e31ec4507c495254239f11841d81c865e80e41a9.tar
www-e31ec4507c495254239f11841d81c865e80e41a9.tar.gz
www-e31ec4507c495254239f11841d81c865e80e41a9.tar.bz2
www-e31ec4507c495254239f11841d81c865e80e41a9.tar.xz
www-e31ec4507c495254239f11841d81c865e80e41a9.zip
adding download of pdf and epub file infrastructure
Diffstat (limited to 'lib/Downloads.php')
-rw-r--r--lib/Downloads.php47
1 files changed, 27 insertions, 20 deletions
diff --git a/lib/Downloads.php b/lib/Downloads.php
index a44404ea0..247cb5f50 100644
--- a/lib/Downloads.php
+++ b/lib/Downloads.php
@@ -96,56 +96,63 @@ class Downloads
*
* @return array
*/
- public static function get_all_mirrors($prod = true)
+ public static function get_all_mirrors($prod = true, $documentation = false)
{
- $cache_file = realpath(__DIR__ . '/cached.list.php');
+ if ($documentation) {
+ $cache_file = realpath(__DIR__ . '/cached.list_doc.php');
+ } else {
+ $cache_file = realpath(__DIR__ . '/cached.list.php');
+ }
if ($prod) {
require $cache_file;
} else {
- $data = file('http://mirrors.mageia.org/api/mageia.1.i586.list');
+ $data = file('http://mirrors.mageia.org/api/mageia.4.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];
+ if (!empty($val[1])) {
+ $m[$val[0]] = $val[1];
+ }
}
- $pu = parse_url($m['url']);
- if (in_array($pu['scheme'], array('http', 'ftp'))) {
-
+ $pu = parse_url($m['url']);
+ if (in_array($pu['scheme'], array('http', 'https', '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'])
+ 'url' => str_replace('/distrib/4/i586', '', $m['url'])
);
-
- $torrent =$item['url'].'/iso/3/torrents/Mageia-3-LiveDVD-KDE4-x86_64-DVD.torrent' ;
- if (false === file_get_contents($torrent)){
- echo "down $torrent \n";
- } else {
- echo "Up $torrent \n";
- $mirrors[$m['country']][] = $item;
- $mirrors['_C:' . $m['continent']][] = $item;
- }
+ if ($documentation) {
+ $test_file = $item['url'].'/people/marcom/doc/mga4/date.txt';
+ } else {
+ $test_file = $item['url'].'/iso/4.1/torrents/Mageia-4.1-LiveDVD-KDE4-x86_64-DVD.torrent';
+ }
+ if (false === file_get_contents($test_file)) {
+ echo "down $test_file \n";
+ } else {
+ echo "Up $test_file \n";
+ $mirrors[$m['country']][] = $item;
+ $mirrors['_C:' . $m['continent']][] = $item;
+ }
}
}
file_put_contents($cache_file,
- sprintf('<?php $mirrors = %s; ?>',
- var_export($mirrors, true)));
+ sprintf('<?php $mirrors = %s; ?>' . PHP_EOL, var_export($mirrors, true)));
}
return $mirrors;
}
/**
- * Get mirrors from stored dictionnary and find:
+ * Get mirrors from stored dictionary and find:
* - best matching country
* - or best matching continent
* - or random