From 5a403f224741ddd159f6b89a94c35899a4e5a0c7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 14 Feb 2019 14:36:34 +0100 Subject: mirrorlist.php now in / --- mirrorlist.php | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 mirrorlist.php (limited to 'mirrorlist.php') diff --git a/mirrorlist.php b/mirrorlist.php new file mode 100644 index 0000000..c9df00d --- /dev/null +++ b/mirrorlist.php @@ -0,0 +1,221 @@ +UNIX_TIMESTAMP(NOW())-7*24*60*60'; + +$result = mysql_run_query( + 'SELECT DISTINCT ' . + '`mirror_statuses`.`country_code`,' . + '`mirror_statuses`.`country`' . + ' FROM `mirror_statuses`' . + ' WHERE ' . $filter . + ' ORDER BY `mirror_statuses`.`country`' +); +$countries = array( + array( + 'country_code' => 'all', + 'country' => 'All' + ) +); +while ($row = $result -> fetch_assoc()) + $countries[] = $row; + +$result = mysql_run_query( + 'SELECT DISTINCT ' . + '`mirror_statuses`.`protocol`' . + ' FROM `mirror_statuses`' . + ' WHERE ' . $filter . + ' ORDER BY `mirror_statuses`.`protocol`' +); +$protocols = array( +); +while ($row = $result -> fetch_assoc()) + $protocols[] = $row['protocol']; + +$ip_versions = array('4', '6'); + +if (array_key_exists('country', $_GET)) { + + if (array_key_exists('use_mirror_status', $_GET)) + $order = '(`mirror_statuses`.`start`-`mirror_statuses`.`last_sync`) DESC'; + else + $order = + '`mirror_statuses`.`country`,' . + 'SUBSTRING(' . + '`mirror_statuses`.`url`,' . + '1+CHAR_LENGTH(`mirror_statuses`.`protocol`)' . + '),' . + '`mirror_statuses`.`protocol`'; + + $request = '&' . preg_replace(',^.*\?,', '', $_SERVER['REQUEST_URI']) . '&'; + if (array_key_exists('protocol', $_GET)) { + $filter .= ' AND `mirror_statuses`.`protocol` IN ('; + foreach ($protocols as $protocol) + if (strpos($request, '&protocol=' . $protocol . '&') !== false) + $filter .= '"' . $protocol . '",'; + $filter .= '"")'; + } + + if (strpos($request, '&country=all&') === false) { + $filter .= ' AND `mirror_statuses`.`country_code` IN ('; + foreach ($countries as $country) + if (strpos($request, '&country=' . $country['country_code'] . '&') !== false) + $filter .= '"' . $country['country_code'] . '",'; + $filter .= '"")'; + } + + foreach ($ip_versions as $ip_version) + if (strpos($request, '&ip_version=' . $ip_version . '&') !== false) + $filter .= ' AND `mirror_statuses`.`ipv' . $ip_version . '`'; + + $result = mysql_run_query( + 'SELECT DISTINCT ' . + ' `mirror_statuses`.`country`,' . + ' `mirror_statuses`.`url`' . + ' FROM `mirror_statuses`' . + ' WHERE ' . $filter . + ' ORDER BY ' . $order + ); + while ($row = $result -> fetch_assoc()) + $mirrors[] = $row; + + header('Content-Type: text/plain'); + + print "##\n"; + print "## Arch Linux 32 repository mirrorlist\n"; + print "## Generated on " . date('Y-m-d') . "\n"; + print "##\n"; + + $last_country = 'Mordor'; + foreach ($mirrors as $mirror) { + if ($mirror['country'] != $last_country) { + print "\n"; + print "## " . $mirror['country'] . "\n"; + $last_country = $mirror['country']; + } + print "#Server = " . $mirror['url'] . '$arch/$repo/' . "\n"; + } + + die(); +} + +print_header('Pacman Mirrorlist Generator', 'home'); + +?> +
+

+ Pacman Mirrorlist Generator +

+

+ This page generates the most up-to-date mirrorlist possible for Arch Linux 32. + The data used here comes straight from the developers' internal mirror database used to track mirror availability and tiering. + There are two main options: + get a mirrorlist with every available mirror, or get a mirrorlist tailored to your geography. +

+

+ Mirrorlist with all available mirrors +

+

+ An up-to-date mirrorlist is available containing all currently active mirrors, optionally filtering by protocol. + These URLs requires no GET or POST parameters so they can be fetched from the command line if desired. +

+

+

+ Customized by country mirrorlist +

+

+ The following form can generate a custom up-to-date + pacman + mirrorlist based on geography and desired protocol(s). + Simply replace the contents of + /etc/pacman.d/mirrorlist + with your generated list. + Additionally, the mirror status data can be incorporated into the generated mirror list and used to only list up to date mirrors. +

+
+
+ + +
+
+ +
    +\n"; + print " \n"; + print " \n"; + $count ++; +} + +?> +
+
+
+ +
    +\n"; + print " \n"; + print " \n"; + $count ++; +} + +?> +
+
+
+ + +
+

+ + +

+
+
+