summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-09-18 17:09:56 +0000
committerDries Buytaert <dries@buytaert.net>2005-09-18 17:09:56 +0000
commitd43655c96286c92a74fc69461ecbe8e0796d332f (patch)
treeb5dc4d99c2abc977be85fda821d35426c30f7a5d
parentf906d2dd50d36d16a2c0e757b34476def84f19e5 (diff)
downloadbrdo-d43655c96286c92a74fc69461ecbe8e0796d332f.tar.gz
brdo-d43655c96286c92a74fc69461ecbe8e0796d332f.tar.bz2
- Patch #31449 by chx: store session IDs in the accesslog table.
-rw-r--r--database/database.mysql1
-rw-r--r--database/database.pgsql1
-rw-r--r--database/updates.inc23
-rw-r--r--modules/statistics.module2
-rw-r--r--modules/statistics/statistics.module2
5 files changed, 26 insertions, 3 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 8a6f8afa0..bd8af2646 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -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,
diff --git a/database/database.pgsql b/database/database.pgsql
index 367d98662..140e0cbc0 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -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,
diff --git a/database/updates.inc b/database/updates.inc
index 96d8da6fc..f3938a45f 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -66,7 +66,8 @@ $sql_updates = array(
"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"];
diff --git a/modules/statistics.module b/modules/statistics.module
index c51639267..6fc9be5b0 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -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());
}
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index c51639267..6fc9be5b0 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -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());
}
}