aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'php/index-list.php')
-rw-r--r--php/index-list.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/php/index-list.php b/php/index-list.php
new file mode 100644
index 0000000..1705ee6
--- /dev/null
+++ b/php/index-list.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Regions.
+ * @package mirror
+ * @subpackage admin
+ */
+require_once('./cfg/init.php');
+require_once(LIB.'/auth.php'); // auth functions
+require_once(LIB.'/forms.php'); // form library
+require_once(LIB.'/list.php'); // list library
+error_reporting(E_GET);
+
+if (!empty($_GET['os'])&&!empty($_GET['product'])) {
+ // clean in os and product strings
+ $os_name = mysql_real_escape_string(trim(strtolower($_GET['os'])));
+ $product_name = mysql_real_escape_string(trim(strtolower($_GET['product'])));
+ // get os and product IDs
+ $os_id = db_name_to_id('mirror_os','os_id','os_name',$os_name);
+ $product_id = db_name_to_id('mirror_products','product_id','product_name',$product_name);
+}
+if (!empty($_GET['os_id'])&&!empty($_GET['product_id'])) {
+ $os_id = intval($_GET['os_id']);
+ $product_id = intval($_GET['product_id']);
+}
+
+if (!empty($os_id)&&!empty($product_id)) {
+
+ $mirrors = db_get("
+ SELECT DISTINCT
+ mirror_baseurl, location_path
+ FROM
+ mirror_mirrors
+ INNER JOIN
+ mirror_location_mirror_map
+ ON
+ mirror_location_mirror_map.mirror_id = mirror_mirrors.mirror_id
+ INNER JOIN
+ mirror_locations
+ ON
+ mirror_location_mirror_map.location_id = mirror_locations.location_id
+ WHERE
+ mirror_locations.os_id = {$os_id} AND
+ mirror_locations.product_id = {$product_id} AND
+ mirror_location_mirror_map.location_active = '1' AND
+ mirror_mirrors.mirror_active = '1'
+ ORDER BY
+ mirror_rating DESC, mirror_baseurl
+ ");
+
+ header("Content-type: text/plain;");
+ foreach ($mirrors as $mirror) {
+ $b = $mirror['mirror_baseurl'];
+ $l = $mirror['location_path'];
+ if($l[0] == '/' && substr($b,-1) == '/') {
+ $b = substr($b, 0, -1);
+ }
+ echo $b.$l."\n";
+ }
+ exit;
+
+} else {
+
+ $title = 'Mirror Listing';
+ require_once(HEADER);
+ echo '<h1>Mirror List</h1>';
+ echo '<p>Use this form to get a list of all mirrors serving up active files
+ for the selected Product/OS.</p>';
+ form_start('list','list','get','./index-list.php');
+ echo '<div>';
+ form_label('Product', 'product','label-small');
+ form_select('product_id','product','',mirror_get_products_select(),$_GET['product_id']);
+ echo ' [<a href="./products.php">edit products</a>]';
+ echo '</div><br />';
+
+ echo '<div>';
+ form_label('OS', 'os','label-small');
+ form_select('os_id','os','',mirror_get_oss_select(),$_GET['os_id']);
+ echo ' [<a href="./os.php">edit operating systems</a>]';
+ echo '</div><br />';
+ form_submit('submit','','button1','Update');
+ form_end();
+ require_once(FOOTER);
+}