public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/bouncer:master commit in: php/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     a6b2a6f02cff02b0417ae10a7057ca3e87f337e6
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:41:36 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:41:36 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=a6b2a6f0

Remove old index backup

 php/index.php.orig | 79 ------------------------------------------------------
 1 file changed, 79 deletions(-)

diff --git a/php/index.php.orig b/php/index.php.orig
deleted file mode 100644
index 9cc7791..0000000
--- a/php/index.php.orig
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-/**
- *  Main handler.
- *  @package mirror
- *	@subpackage pub
- */
-error_reporting(0);  // hide all errors
-require_once('./cfg/config.php');  // config file that defines constants
-
-// if we don't have an os, make it windows, playing the odds
-if (empty($_GET['os'])) {
-    $_GET['os'] = 'Any';
-}
-
-// 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
-
-    // 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'])));
-    
-    printf("osname=%s<br />\nprname=%s<br />\n",$os_name,$product_name);
-
-    // 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);
-
-    printf("osid=%s<br />\nprid=%s<br />\n",$os_id,$product_id);
-
-    // 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}");
-
-        // 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)");
-
-            // 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}");
-                }
-                
-                // LANGUAGE HACK
-                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);
-				}
-
-                // if we are just testing, then just print and exit.
-                if (!empty($_GET['print'])) {
-                    print('Location: '.$mirror['mirror_baseurl'].$location['location_path']);
-                    exit;
-                }
-
-                // otherwise, by default, redirect them and exit
-                header('Location: '.$mirror['mirror_baseurl'].$location['location_path']);
-                exit;
-            }
-        }
-    }
-}
-
-// if we get here, the request was invalid; redirect to mozilla home
-header('Location: http://www.gentoo.org/');
-exit;
-?>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/
@ 2018-01-30 18:31 Brian Evans
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Evans @ 2018-01-30 18:31 UTC (permalink / raw
  To: gentoo-commits

commit:     e488c9e9fcea1caf476c2ddfb711b1244f64b8c9
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 18:30:50 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 18:30:50 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=e488c9e9

Remove a debugging statement from index

 php/index.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/php/index.php b/php/index.php
index aeb7128..b925502 100644
--- a/php/index.php
+++ b/php/index.php
@@ -62,7 +62,6 @@ if (!empty($_GET['os'])&&!empty($_GET['product'])) {
 
                 // otherwise, by default, redirect them and exit
                 header('Location: '.$mirror['mirror_baseurl'].$location['location_path']);
-		var_dump($mirror);
                 exit;
             }
         }


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/
@ 2018-12-10  6:57 Robin H. Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Robin H. Johnson @ 2018-12-10  6:57 UTC (permalink / raw
  To: gentoo-commits

commit:     bc71b364401e993934cbd167714eec8337ca156a
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 06:56:54 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Dec 10 06:56:54 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=bc71b364

index: do not downgrade to HTTP

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 php/index.php | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/php/index.php b/php/index.php
index abb9671..357e25d 100644
--- a/php/index.php
+++ b/php/index.php
@@ -25,13 +25,34 @@ if (!empty($_GET['os'])&&!empty($_GET['product'])) {
     $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);
 
+    // From pure HTTP request, you might get upgraded
+    // From HTTPS request, you should NOT be downgraded.
+    $baseurl_prefix = $_SERVER['HTTPS'] === 'on' ? 'https%' : 'http%';
+
     // 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=? AND os_id=?", PDO::FETCH_ASSOC, [$product_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",
+                                PDO::FETCH_ASSOC,
+                                array(':product_id' => $product_id, ':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 JOIN mirror_location_mirror_map ON mirror_mirrors.mirror_id = mirror_location_mirror_map.mirror_id WHERE mirror_location_mirror_map.location_id = ? AND mirror_active='1' AND location_active ='1' ORDER BY rand()*(1/mirror_rating)", PDO::FETCH_ASSOC, [$location['location_id']]);
+			$mirror = DB::get_one("SELECT
+				mirror_mirrors.mirror_id, mirror_baseurl
+                FROM mirror_mirrors
+                JOIN mirror_location_mirror_map ON mirror_mirrors.mirror_id = mirror_location_mirror_map.mirror_id
+                WHERE
+                    mirror_location_mirror_map.location_id = :location_id
+                    AND mirror_active='1'
+                    AND location_active ='1'
+                    AND mirror_baseurl LIKE :baseurl_prefix
+                ORDER BY
+                    rand()*(1.0/mirror_rating)",
+                PDO::FETCH_ASSOC,
+                array(
+                    ':location_id' => $location['location_id'],
+                    ':baseurl_prefix' => $baseurl_prefix,
+                ));
 
             // did we get a valid mirror?
             if (!empty($mirror)) {


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/
@ 2018-12-10  6:57 Robin H. Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Robin H. Johnson @ 2018-12-10  6:57 UTC (permalink / raw
  To: gentoo-commits

commit:     0bd5605997c5c45b631f75606cfe87544c5e3082
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 06:38:38 2018 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Dec 10 06:38:38 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=0bd56059

php: fix whitespace.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 php/index.php | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/php/index.php b/php/index.php
index d1d4733..abb9671 100644
--- a/php/index.php
+++ b/php/index.php
@@ -43,16 +43,16 @@ if (!empty($_GET['os'])&&!empty($_GET['product'])) {
                 }
 
                 // LANGUAGE HACK
-		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']);
-		}
+                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'] .= preg_replace('/\?.*|&.*/','',$extra);
-		}
+                // BitTorrent HACK - robbat2
+                if (!empty($_GET['extra'])) {
+                    $extra = $_GET['extra'];
+                    $location['location_path'] .= preg_replace('/\?.*|&.*/','',$extra);
+                }
 
                 // if we are just testing, then just print and exit.
                 if (!empty($_GET['print'])) {


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-10  6:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-30 18:31 [gentoo-commits] proj/bouncer:master commit in: php/ Brian Evans
  -- strict thread matches above, loose matches on Subject: below --
2018-12-10  6:57 Robin H. Johnson
2018-12-10  6:57 Robin H. Johnson
2018-01-30 18:16 Brian Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox