diff options
-rw-r--r-- | database/database.mysql | 1 | ||||
-rw-r--r-- | database/database.pgsql | 1 | ||||
-rw-r--r-- | database/updates.inc | 23 | ||||
-rw-r--r-- | modules/statistics.module | 2 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 2 |
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()); } } |