function statistics_advanced_exit in Statistics Advanced 6
Same name and namespace in other branches
- 5 statistics_advanced.module \statistics_advanced_exit()
Implementation of hook_exit().
Delete unwanted records.
File
- ./
statistics_advanced.module, line 154 - Adds advanced settings and features for the core Statistics module.
Code
function statistics_advanced_exit() {
global $user;
if (_statistics_advanced_is_node_visit()) {
if (_statistics_advanced_is_403_or_404()) {
// Ignore 404 and 403 node visits.
_statistics_advanced_ignore('nodecounter', TRUE);
}
elseif (statistics_advanced_user_access('exclude visits from counters')) {
_statistics_advanced_ignore('nodecounter', TRUE);
}
//else {
// // If the node has been previously read by the user and has changed since
// // the last read, count it as a new read.
// $changed = db_result(db_query("SELECT changed FROM {node} WHERE nid = %d", array(':nid' => arg(1))));
// $last_read = _statistics_advanced_ignore('nodecounter');
// if ($last_read && $changed > $last_read) {
// _statistics_advanced_ignore('nodecounter', FALSE);
// }
//}
}
// Check if user's access log entry should be ignored based on user role.
if (statistics_advanced_user_access('exclude visits from the access log')) {
_statistics_advanced_ignore('accesslog', TRUE);
}
// Check if the user's browser is a crawler.
if (!$user->uid && statistics_advanced_var('ignore_crawlers') && module_exists('browscap') && function_exists('browscap_get_browser')) {
drupal_load('module', 'browscap');
$browser = browscap_get_browser();
if (!empty($browser['crawler'])) {
_statistics_advanced_ignore('accesslog', TRUE);
if (_statistics_advanced_is_node_visit()) {
_statistics_advanced_ignore('nodecounter', TRUE);
}
if (variable_get('browscap_monitor', 0) && function_exists('browscap_unmonitor')) {
browscap_unmonitor();
}
}
}
if (_statistics_advanced_ignore('nodecounter')) {
db_query("UPDATE {node_counter} SET daycount = daycount - 1, totalcount = totalcount - 1 WHERE nid = %d AND totalcount > 0 AND daycount > 0", array(
':nid' => arg(1),
));
}
if (_statistics_advanced_ignore('accesslog')) {
db_query("DELETE FROM {accesslog} WHERE (sid = '%s' AND uid = 0) OR (uid = %d AND uid > 0)", array(
':sid' => session_id(),
':uid' => $user->uid,
));
}
}