- Patch #31449 by chx: store session IDs in the accesslog table.

4.7.x
Dries Buytaert 2005-09-18 17:09:56 +00:00
parent f906d2dd50
commit d43655c962
5 changed files with 26 additions and 3 deletions

View File

@ -21,6 +21,7 @@ CREATE TABLE access (
CREATE TABLE accesslog ( CREATE TABLE accesslog (
aid int(10) NOT NULL auto_increment, aid int(10) NOT NULL auto_increment,
sid varchar(32) NOT NULL default '',
title varchar(255) default NULL, title varchar(255) default NULL,
path varchar(255) default NULL, path varchar(255) default NULL,
url varchar(255) default NULL, url varchar(255) default NULL,

View File

@ -16,6 +16,7 @@ CREATE TABLE access (
CREATE TABLE accesslog ( CREATE TABLE accesslog (
aid SERIAL, aid SERIAL,
sid varchar(32) NOT NULL default '',
mask varchar(255) NOT NULL default '', mask varchar(255) NOT NULL default '',
title varchar(255) default NULL, title varchar(255) default NULL,
path varchar(255) default NULL, path varchar(255) default NULL,

View File

@ -66,7 +66,8 @@ $sql_updates = array(
"2005-08-08" => "update_144", "2005-08-08" => "update_144",
"2005-08-15" => "update_145", "2005-08-15" => "update_145",
"2005-08-25" => "update_146", "2005-08-25" => "update_146",
"2005-09-07" => "update_147" "2005-09-07" => "update_147",
"2005-09-18" => "update_148"
); );
function update_110() { function update_110() {
@ -811,6 +812,26 @@ function update_147() {
return $ret; return $ret;
} }
function update_148() {
$ret = array();
// Add support for tracking users' session ids (useful for tracking anon users)
switch ($GLOBALS['db_type']) {
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {accesslog} ADD sid varchar(32)");
$ret[] = update_sql("ALTER TABLE {accesslog} ALTER sid SET NOT NULL");
$ret[] = update_sql("ALTER TABLE {accesslog} ALTER sid SET DEFAULT ''");
break;
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {accesslog} ADD sid varchar(32) NOT NULL default ''");
break;
default:
break;
}
return $ret;
}
function update_sql($sql) { function update_sql($sql) {
$edit = $_POST["edit"]; $edit = $_POST["edit"];

View File

@ -74,7 +74,7 @@ function statistics_exit() {
} }
if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) { if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
// Log this page access. // Log this page access.
db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, %d, %d)", drupal_get_title(), $_GET['q'], referer_uri(), $_SERVER['REMOTE_ADDR'], $user->uid, timer_read('page'), time()); db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", drupal_get_title(), $_GET['q'], referer_uri(), $_SERVER['REMOTE_ADDR'], $user->uid, session_id(), timer_read('page'), time());
} }
} }

View File

@ -74,7 +74,7 @@ function statistics_exit() {
} }
if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) { if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
// Log this page access. // Log this page access.
db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, %d, %d)", drupal_get_title(), $_GET['q'], referer_uri(), $_SERVER['REMOTE_ADDR'], $user->uid, timer_read('page'), time()); db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", drupal_get_title(), $_GET['q'], referer_uri(), $_SERVER['REMOTE_ADDR'], $user->uid, session_id(), timer_read('page'), time());
} }
} }