[xiph-commits] r14853 - branches/dir.xiph.org/inc
balbinus at svn.xiph.org
balbinus at svn.xiph.org
Sat May 10 11:20:50 PDT 2008
Author: balbinus
Date: 2008-05-10 11:20:49 -0700 (Sat, 10 May 2008)
New Revision: 14853
Modified:
branches/dir.xiph.org/inc/inc.db.php
branches/dir.xiph.org/inc/lib.apilog.php
Log:
Trying to log on a secondary server, less IO-bound.
Modified: branches/dir.xiph.org/inc/inc.db.php
===================================================================
--- branches/dir.xiph.org/inc/inc.db.php 2008-05-10 17:16:37 UTC (rev 14852)
+++ branches/dir.xiph.org/inc/inc.db.php 2008-05-10 18:20:49 UTC (rev 14853)
@@ -6,25 +6,40 @@
if (ENVIRONMENT == 'preprod')
{
- define('CP_DB_HOST', 'localhost');
- define('CP_DB_USER', 'dir_xiph_org_t');
- define('CP_DB_PASS', '6.NvxjR7B5j3Q');
- define('CP_DB_NAME', 'dir_xiph_org_test');
+ define('DATA_DB_HOST', 'localhost');
+ define('DATA_DB_USER', 'dir_xiph_org_t');
+ define('DATA_DB_PASS', '6.NvxjR7B5j3Q');
+ define('DATA_DB_NAME', 'dir_xiph_org_test');
+
+ define('LOG_DB_HOST', 'theetete.radiopytagor.org');
+ define('LOG_DB_USER', 'dir_xiph_org_t');
+ define('LOG_DB_PASS', 'y2V1ydXuXwLKg');
+ define('LOG_DB_NAME', 'dir_xiph_org_test');
}
elseif (ENVIRONMENT == 'prod')
{
- define('CP_DB_HOST', 'localhost');
- define('CP_DB_USER', 'dir_xiph_org');
- define('CP_DB_PASS', '5wCjLEVmAJnmM');
- define('CP_DB_NAME', 'dir_xiph_org');
+ 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('LOG_DB_HOST', 'theetete.radiopytagor.org');
+ define('LOG_DB_USER', 'dir_xiph_org');
+ define('LOG_DB_PASS', 'xf0M1E1cup0FM');
+ define('LOG_DB_NAME', 'dir_xiph_org');
}
else
{
// die("Unable to do this on test atm.\n");
- define('CP_DB_HOST', 'localhost');
- define('CP_DB_USER', 'dir_xiph_org_t');
- define('CP_DB_PASS', 'pSqvUfzxL5qXz.UH');
- define('CP_DB_NAME', 'dir_xiph_org_test');
+ define('DATA_DB_HOST', 'localhost');
+ define('DATA_DB_USER', 'dir_xiph_org_t');
+ define('DATA_DB_PASS', 'pSqvUfzxL5qXz.UH');
+ define('DATA_DB_NAME', 'dir_xiph_org_test');
+
+ define('LOG_DB_HOST', 'localhost');
+ define('LOG_DB_USER', 'dir_xiph_org_t');
+ define('LOG_DB_PASS', 'pSqvUfzxL5qXz.UH');
+ define('LOG_DB_NAME', 'dir_xiph_org_test');
}
/**
@@ -41,7 +56,7 @@
*/
protected function __construct()
{
- parent::__construct(CP_DB_HOST, CP_DB_USER, CP_DB_PASS, CP_DB_NAME);
+ parent::__construct(DATA_DB_HOST, DATA_DB_USER, DATA_DB_PASS, DATA_DB_NAME);
}
public function query($sql)
@@ -79,4 +94,15 @@
}
}
+class DirXiphOrgLogDBC extends DirXiphOrgDBC
+{
+ /**
+ * Constructor.
+ */
+ protected function __construct()
+ {
+ parent::__construct(LOG_DB_HOST, LOG_DB_USER, LOG_DB_PASS, LOG_DB_NAME);
+ }
+}
+
?>
Modified: branches/dir.xiph.org/inc/lib.apilog.php
===================================================================
--- branches/dir.xiph.org/inc/lib.apilog.php 2008-05-10 17:16:37 UTC (rev 14852)
+++ branches/dir.xiph.org/inc/lib.apilog.php 2008-05-10 18:20:49 UTC (rev 14853)
@@ -81,27 +81,27 @@
{
$db = DirXiphOrgDBC::getInstance();
- try
+/* try
{
$db->noReturnQuery('SELECT 0 INTO @prev_id;');
$db->noReturnQuery('UPDATE refused_log_cpt SET `id_log` = ((`id_log` MOD 5000) + 1) WHERE @prev_id := `id_log`;');
$res = $db->singleQuery('SELECT @prev_id AS id;');
- $id = $res->current('id');
+ $id = $res->current('id');*/
- $sql = 'REPLACE INTO `refused_log` (`id`, `reason`, `remote_ip`, `listen_url`, `listen_url_hash`) '
- .'VALUES (%d, %d, INET_ATON("%s"), "%s", %u);';
- $sql = sprintf($sql, $id,
+ $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',
$listen_url != false ? mysql_real_escape_string($listen_url) : '',
$listen_url != false ? sprintf('%u', crc32($listen_url)) : 0);
$db->noReturnQuery($sql);
- }
+/* }
catch (SQLNoResultException $e)
{
throw new APIException("Unable to get a new api_log id.");
- }
+ }*/
}
}
More information about the commits
mailing list