[xiph-commits] r14903 - in branches/dir.xiph.org: cgi-bin inc
balbinus at svn.xiph.org
balbinus at svn.xiph.org
Sat May 17 03:12:21 PDT 2008
Author: balbinus
Date: 2008-05-17 03:12:20 -0700 (Sat, 17 May 2008)
New Revision: 14903
Modified:
branches/dir.xiph.org/cgi-bin/yp.php
branches/dir.xiph.org/inc/lib.apilog.php
Log:
Cleaning + escaping in apilog, and new function to log the SIDs issued.
Modified: branches/dir.xiph.org/cgi-bin/yp.php
===================================================================
--- branches/dir.xiph.org/cgi-bin/yp.php 2008-05-17 10:10:57 UTC (rev 14902)
+++ branches/dir.xiph.org/cgi-bin/yp.php 2008-05-17 10:12:20 UTC (rev 14903)
@@ -172,6 +172,7 @@
{
// Log
APILog::serverAdded(true, $server_id, $mp_id, $listen_url);
+ APILog::sidIssued($sid, $server_id, $mp->getId(), $listen_url);
}
else
{
Modified: branches/dir.xiph.org/inc/lib.apilog.php
===================================================================
--- branches/dir.xiph.org/inc/lib.apilog.php 2008-05-17 10:10:57 UTC (rev 14902)
+++ branches/dir.xiph.org/inc/lib.apilog.php 2008-05-17 10:12:20 UTC (rev 14903)
@@ -7,32 +7,17 @@
{
$db = DirXiphOrgLogDBC::getInstance();
-/* try
- {
- $db->noReturnQuery('SELECT 0 INTO @prev_id;');
- $db->noReturnQuery('UPDATE api_log_cpt SET `id_log` = ((`id_log` MOD 10000) + 1) WHERE @prev_id := `id_log`;');
- $res = $db->singleQuery('SELECT @prev_id AS id;');
- $id = $res->current('id');*/
- $ip = utils::getRealIp();
- $ip = $ip !== false ? $ip : '127.0.0.1';
-
- $sql = 'INSERT INTO `api_log_%s` (`message`, `remote_ip`, `listen_url_hash`, `server_id`, `mountpoint_id`) '
- .'VALUES ("%s", INET_ATON("%s"), "%s", %d, %d);';
- $sql = sprintf($sql, date('Ymd'),
- mysql_real_escape_string($result),
-/* 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',*/
- $ip,
- $listen_url !== null ? md5($listen_url) : 0,
- $server_id, $mountpoint_id);
- $db->noReturnQuery($sql);
-/* }
- catch (SQLNoResultException $e)
- {
- throw new APIException("Unable to get a new api_log id.");
- }*/
+ $ip = utils::getRealIp();
+ $ip = $ip !== false ? $ip : '127.0.0.1';
+
+ $sql = 'INSERT INTO `api_log_%s` (`message`, `remote_ip`, `listen_url_hash`, `server_id`, `mountpoint_id`) '
+ .'VALUES ("%s", INET_ATON("%s"), "%s", %d, %d);';
+ $sql = sprintf($sql, date('Ymd'),
+ $db->escape($result),
+ $ip,
+ $listen_url !== null ? hash('md5', $listen_url) : 0,
+ $server_id, $mountpoint_id);
+ $db->noReturnQuery($sql);
}
public static function serverAdded($ok, $server_id, $mountpoint_id,
@@ -86,34 +71,37 @@
{
$db = DirXiphOrgLogDBC::getInstance();
-/* 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');*/
- $ip = utils::getRealIp();
- $ip = $ip !== false ? $ip : '127.0.0.1';
-
-
- $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('HTTP_X_FORWARDED_FOR', $_SERVER)
- ? $_SERVER['HTTP_X_FORWARDED_FOR']
- : array_key_exists('REMOTE_ADDR', $_SERVER)
- ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1',*/
- $ip,
- $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.");
- }*/
+ $ip = utils::getRealIp();
+ $ip = $ip !== false ? $ip : '127.0.0.1';
+
+ $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),
+ $ip,
+ $listen_url != false ? $db->escape($listen_url) : '',
+ $listen_url != false ? sprintf('%u', crc32($listen_url)) : 0);
+ $db->noReturnQuery($sql);
}
+
+ public static function sidIssued($sid, $server_id, $mountpoint_id, $listen_url)
+ {
+ $db = DirXiphOrgLogDBC::getInstance();
+
+ $ip = utils::getRealIp();
+ $ip = $ip !== false ? $ip : '127.0.0.1';
+
+ $sql = 'INSERT INTO `sid_log_%s` (`sid`, `server_id`, `mountpoint_id`, `listen_url`, `listen_url_hash`, `issed_for`) '
+ .'VALUES (%d, %d, "%s", "%s", INET_ATON("%s"));';
+ $sql = sprintf($sql, date('Ymd'),
+ $db->escape($sid),
+ intval($server_id),
+ intval($mountpoint_id),
+ $listen_url != false ? $db->escape($listen_url) : '',
+ $listen_url != false ? hash('md5', $listen_url) : '',
+ $db->escape($ip));
+ $db->noReturnQuery($sql);
+ }
}
?>
More information about the commits
mailing list