aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Downloads.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Downloads.php')
-rw-r--r--lib/Downloads.php48
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/Downloads.php b/lib/Downloads.php
index fc8305c06..5d1e676f8 100644
--- a/lib/Downloads.php
+++ b/lib/Downloads.php
@@ -153,6 +153,14 @@ class Downloads
$mirrors = array();
$num_up = 0;
$num_dn = 0;
+ $mirror_cities = array();
+ $mirror_countries = array();
+ $refresh_country_and_city_arrays = false;
+ if ($prod == false && $documentation == false && $mirrorlist == false) {
+ function _r($passthru) {return '_r("' . $passthru . '")';};
+ include_once(realpath(__DIR__) . '/../en/downloads/get/lib.php');
+ $refresh_country_and_city_arrays = true;
+ }
foreach ($data as $line) {
$line = explode(',', trim($line));
$m = array();
@@ -167,10 +175,25 @@ class Downloads
$item = array(
'zone' => isset($m['zone']) ? $m['zone'] : '?',
'country' => isset($m['country']) ? $m['country'] : '?',
- 'city' => isset($m['city']) ? utf8_encode($m['city']) : '-',
+ 'city' => isset($m['city']) ? $m['city'] : '-',
// BEWARE of the path substitution here. Must match.
'url' => str_replace('/distrib/7/i586', '', $m['url'])
);
+ if ($refresh_country_and_city_arrays == true) {
+ // prepare details for i18n
+ if (isset($m['city'])) {
+ if (isset($cities_i18n[$m['city']])) {
+ $mirror_cities[$m['city']] = $cities_i18n[$m['city']];
+ } else {
+ $mirror_cities[$m['city']] = '_r("' . $m['city'] . '") // new city (not yet in /en/downloads/get/lib.php)';
+ }
+ }
+ if (isset($countries[$item['country']])) {
+ $mirror_countries[$item['country']] = $countries[$item['country']];
+ } else if (isset($item['country'])) {
+ $mirror_countries[$item['country']] = " // new country (not yet in /en/downloads/get/lib.php)";
+ }
+ }
if ($documentation) {
$test_file = $item['url'].'/doc/mga7/date.txt';
@@ -199,6 +222,29 @@ class Downloads
echo "\nThere are $num_up servers with the file and $num_dn with some kind of issue.\n";
file_put_contents($cache_file,
sprintf('<?php $mirrors = %s; ?>' . PHP_EOL, var_export($mirrors, true)));
+
+ if ($refresh_country_and_city_arrays == true) {
+ foreach ($countries as $ISO_3166_country_code => $lib_country) {
+ if (!isset($mirror_countries[$ISO_3166_country_code])) {
+ $mirror_countries[$ISO_3166_country_code] = $lib_country;
+ }
+ }
+ foreach ($cities_i18n as $english_name => $translated_name) {
+ if (!isset($mirror_cities[$english_name])) {
+ $mirror_cities[$english_name] = '_r("' . $english_name . '")';
+ }
+ }
+ ksort($mirror_cities);
+ $countries_u = array_unique($mirror_countries);
+ ksort($countries_u);
+ echo "\nArray of cities for i18n: ";
+ var_export($mirror_cities);
+ echo ";\nArray of countries for i18n: ";
+ var_export($countries_u);
+ echo ";\n";
+ }
+ echo "\nRemove char ' at each value on both arrays for cities and countries above : replace '_r(\" with just _r( and also behind \")', with \"),\n";
+ echo "and update arrays in file /en/downloads/get/lib.php with that.\n";
}
return $mirrors;
}