aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'php/index.php')
-rw-r--r--php/index.php43
1 files changed, 20 insertions, 23 deletions
diff --git a/php/index.php b/php/index.php
index eacb99e..28b29b8 100644
--- a/php/index.php
+++ b/php/index.php
@@ -15,45 +15,44 @@ if (empty($_GET['os'])) {
// do we even have an os or product?
if (!empty($_GET['os'])&&!empty($_GET['product'])) {
require_once(LIB.'/db.php'); // core mysql wrappers
- db_connect(DBHOST,DBUSER,DBPASS); // open persistent connection to db
- db_select(DBNAME); // select db
+ DB::connect(DBHOST,DBUSER,DBPASS,DBNAME); // open persistent connection to db
// 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'])));
+ $os_name = trim(strtolower($_GET['os']));
+ $product_name = 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);
+ $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);
// do we have a valid os and product?
if (!empty($os_id)&&!empty($product_id)) {
- $location = db_get_one("SELECT location_id,location_path FROM mirror_locations WHERE product_id={$product_id} AND os_id={$os_id}");
+ $location = DB::get_one("SELECT location_id,location_path FROM mirror_locations WHERE product_id={$product_id} AND os_id={$os_id}");
// did we get a valid location?
if (!empty($location)) {
- $mirror = db_get_one("SELECT mirror_mirrors.mirror_id,mirror_baseurl FROM mirror_mirrors, mirror_location_mirror_map WHERE mirror_mirrors.mirror_id = mirror_location_mirror_map.mirror_id AND mirror_location_mirror_map.location_id = {$location['location_id']} AND mirror_active='1' AND location_active ='1' ORDER BY rand()*(1/mirror_rating)");
+ $mirror = DB::get_one("SELECT mirror_mirrors.mirror_id,mirror_baseurl FROM mirror_mirrors, mirror_location_mirror_map WHERE mirror_mirrors.mirror_id = mirror_location_mirror_map.mirror_id AND mirror_location_mirror_map.location_id = {$location['location_id']} AND mirror_active='1' AND location_active ='1' ORDER BY rand()*(1/mirror_rating)");
// did we get a valid mirror?
if (!empty($mirror)) {
// if logging is enabled, insert log
if (LOGGING) {
- db_query("UPDATE mirror_mirrors SET mirror_count=mirror_count+1 WHERE mirror_id={$mirror['mirror_id']}");
- db_query("UPDATE mirror_products SET product_count=product_count+1 WHERE product_id={$product_id}");
+ DB::query("UPDATE mirror_mirrors SET mirror_count=mirror_count+1 WHERE mirror_id={$mirror['mirror_id']}");
+ DB::query("UPDATE mirror_products SET product_count=product_count+1 WHERE product_id={$product_id}");
}
-
+
// LANGUAGE HACK
- if (!empty($_GET['lang'])) {
+ if (!empty($_GET['lang'])) {
//// $location['location_path'] = str_replace('x86',$_GET['lang'],$location['location_path']);
- $location['location_path'] = str_replace('en-US',$_GET['lang'],$location['location_path']);
- }
-
- // BitTorrent HACK - robbat2
- if (!empty($_GET['extra'])) {
- $extra = $_GET['extra'];
- $location['location_path'] .= ereg_replace('\?.*|&.*','',$extra);
- }
+ $location['location_path'] = str_replace('en-US',$_GET['lang'],$location['location_path']);
+ }
+
+ // BitTorrent HACK - robbat2
+ if (!empty($_GET['extra'])) {
+ $extra = $_GET['extra'];
+ $location['location_path'] .= ereg_replace('\?.*|&.*','',$extra);
+ }
// if we are just testing, then just print and exit.
if (!empty($_GET['print'])) {
@@ -69,7 +68,5 @@ if (!empty($_GET['os'])&&!empty($_GET['product'])) {
}
}
-// if we get here, the request was invalid; redirect to mozilla home
+// if we get here, the request was invalid; redirect to Gentoo home
header('Location: http://www.gentoo.org/');
-exit;
-?>