function statistics_advanced_boot in Statistics Advanced 6
Same name and namespace in other branches
- 5 statistics_advanced.module \statistics_advanced_boot()
Implementation of hook_boot().
Checks to see if this is a unique content view by checking the 'accesslog' table for anonymous views and the 'history' table for authenticated user views.
File
- ./
statistics_advanced.module, line 88 - Adds advanced settings and features for the core Statistics module.
Code
function statistics_advanced_boot() {
global $user;
// Load path handling.
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
if (_statistics_advanced_is_node_visit() && statistics_advanced_var('ignore_repeat_views')) {
// Save the current user's uid as we may find from the accesslog table that
// the user has logged out but has a record in the history table.
$uid = $user->uid;
if (!$uid && variable_get('statistics_enable_access_log', 0)) {
$accesslog = db_fetch_object(db_query_range("SELECT uid, timestamp FROM {accesslog} WHERE (path = '%s' OR uid > 0) AND sid = '%s' ORDER BY timestamp DESC", array(
':path' => $_GET['q'],
':sid' => session_id(),
), 0, 1));
if ($accesslog) {
if ($accesslog->uid) {
$uid = $accesslog->uid;
}
else {
_statistics_advanced_ignore('nodecounter', $accesslog->timestamp);
}
}
}
if ($uid) {
$historylog = db_result(db_query("SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d", array(
':uid' => $uid,
':nid' => arg(1),
)));
if ($historylog) {
// Repeat user visit (same user id and node id in history table)
_statistics_advanced_ignore('nodecounter', $historylog);
}
}
}
}