[xiph-commits] r14855 - in branches/dir.xiph.org: cgi-bin inc

balbinus at svn.xiph.org balbinus at svn.xiph.org
Sat May 10 11:37:13 PDT 2008


Author: balbinus
Date: 2008-05-10 11:37:12 -0700 (Sat, 10 May 2008)
New Revision: 14855

Modified:
   branches/dir.xiph.org/cgi-bin/yp.php
   branches/dir.xiph.org/inc/inc.db.php
   branches/dir.xiph.org/inc/lib.apilog.php
Log:
Use X-Forwarded-For in logging too, use the correct dbc to log on a remote server, and correct a syntax error.

Modified: branches/dir.xiph.org/cgi-bin/yp.php
===================================================================
--- branches/dir.xiph.org/cgi-bin/yp.php	2008-05-10 18:32:19 UTC (rev 14854)
+++ branches/dir.xiph.org/cgi-bin/yp.php	2008-05-10 18:37:12 UTC (rev 14855)
@@ -52,8 +52,8 @@
 		        }
 		    }
 		    // Remote IP
-                    $ip = array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
-			   ? $_SERVER['HTTP_X_FORWARDED_FOR']
+            $ip = array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
+				   ? $_SERVER['HTTP_X_FORWARDED_FOR']
                            : array_key_exists('REMOTE_ADDR', $_SERVER)
 		              ? $_SERVER['REMOTE_ADDR'] : null;
 		    // Stream name
@@ -248,8 +248,10 @@
 		        throw new NoSuchSIDAPIException();
 		    }
 		    // Remote IP
-		    $ip = array_key_exists('REMOTE_ADDR', $_SERVER)
-		            ? $_SERVER['REMOTE_ADDR'] : null;
+            $ip = array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
+				   ? $_SERVER['HTTP_X_FORWARDED_FOR']
+                           : array_key_exists('REMOTE_ADDR', $_SERVER)
+		              ? $_SERVER['REMOTE_ADDR'] : null;
 		    // Song title
 		    $current_song = array_key_exists('st', $_REQUEST)
 		                        ? clean_string($_REQUEST['st'])

Modified: branches/dir.xiph.org/inc/inc.db.php
===================================================================
--- branches/dir.xiph.org/inc/inc.db.php	2008-05-10 18:32:19 UTC (rev 14854)
+++ branches/dir.xiph.org/inc/inc.db.php	2008-05-10 18:37:12 UTC (rev 14855)
@@ -21,7 +21,7 @@
 	define('DATA_DB_HOST', 'localhost');
 	define('DATA_DB_USER', 'dir_xiph_org');
 	define('DATA_DB_PASS', '5wCjLEVmAJnmM');
-	define('DATA_DB_NAME', 'dir_xiph_org';
+	define('DATA_DB_NAME', 'dir_xiph_org');
 	
 	define('LOG_DB_HOST', 'theetete.radiopytagor.org');
 	define('LOG_DB_USER', 'dir_xiph_org');

Modified: branches/dir.xiph.org/inc/lib.apilog.php
===================================================================
--- branches/dir.xiph.org/inc/lib.apilog.php	2008-05-10 18:32:19 UTC (rev 14854)
+++ branches/dir.xiph.org/inc/lib.apilog.php	2008-05-10 18:37:12 UTC (rev 14855)
@@ -18,8 +18,10 @@
                   .'VALUES (%d, "%s", INET_ATON("%s"), "%s", %d, %d);';
             $sql = sprintf($sql, $id,
                                  mysql_real_escape_string($result),
-                                 array_key_exists('REMOTE_ADDR', $_SERVER)
-                                    ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',
+                                 array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
+								   ? $_SERVER['HTTP_X_FORWARDED_FOR']
+								           : array_key_exists('REMOTE_ADDR', $_SERVER)
+									  ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',
                                  $listen_url !== null ? md5($listen_url) : 0,
                                  $server_id, $mountpoint_id);
             $db->noReturnQuery($sql);
@@ -79,7 +81,7 @@
     
     public static function serverRefused($reason, $listen_url = false)
     {
-        $db = DirXiphOrgDBC::getInstance();
+        $db = DirXiphOrgLogDBC::getInstance();
         
 /*        try
         {
@@ -90,10 +92,12 @@
             
             $sql = 'INSERT INTO `refused_log_%s` (`reason`, `remote_ip`, `listen_url`, `listen_url_hash`) '
               .'VALUES (%d, INET_ATON("%s"), "%s", %u);';
-             $sql = sprintf($sql, date('Ymd'),
-                                  intval($reason),
-                                  array_key_exists('REMOTE_ADDR', $_SERVER)
-                                   ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',
+            $sql = sprintf($sql, date('Ymd'),
+                                 intval($reason),
+                                 array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)
+								   ? $_SERVER['HTTP_X_FORWARDED_FOR']
+								           : array_key_exists('REMOTE_ADDR', $_SERVER)
+									  ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',
                                  $listen_url != false ? mysql_real_escape_string($listen_url) : '',
                                  $listen_url != false ? sprintf('%u', crc32($listen_url)) : 0);
             $db->noReturnQuery($sql);



More information about the commits mailing list