Commit d43655c9 authored by Dries's avatar Dries
Browse files

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

parent f906d2dd
......@@ -21,6 +21,7 @@ CREATE TABLE access (
CREATE TABLE accesslog (
aid int(10) NOT NULL auto_increment,
sid varchar(32) NOT NULL default '',
title varchar(255) default NULL,
path varchar(255) default NULL,
url varchar(255) default NULL,
......
......@@ -16,6 +16,7 @@ CREATE TABLE access (
CREATE TABLE accesslog (
aid SERIAL,
sid varchar(32) NOT NULL default '',
mask varchar(255) NOT NULL default '',
title varchar(255) default NULL,
path varchar(255) default NULL,
......
......@@ -66,7 +66,8 @@
"2005-08-08" => "update_144",
"2005-08-15" => "update_145",
"2005-08-25" => "update_146",
"2005-09-07" => "update_147"
"2005-09-07" => "update_147",
"2005-09-18" => "update_148"
);
function update_110() {
......@@ -811,6 +812,26 @@ function update_147() {
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) {
$edit = $_POST["edit"];
......
......@@ -74,7 +74,7 @@ function statistics_exit() {
}
if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
// 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());
}
}
......
......@@ -74,7 +74,7 @@ function statistics_exit() {
}
if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
// 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());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment