| 1 |
<?php |
<?php |
| 2 |
// $Id: statistics_advanced.module,v 1.1.2.22 2009/03/02 22:33:27 davereid Exp $ |
// $Id: statistics_advanced.module,v 1.1.2.23 2009/03/20 06:01:50 davereid Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 12 |
function statistics_advanced_perm() { |
function statistics_advanced_perm() { |
| 13 |
return array( |
return array( |
| 14 |
'exclude visits from the access log', |
'exclude visits from the access log', |
| 15 |
|
'exclude visits from counters', |
| 16 |
); |
); |
| 17 |
} |
} |
| 18 |
|
|
| 78 |
// Load path handling. |
// Load path handling. |
| 79 |
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); |
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); |
| 80 |
|
|
| 81 |
// Determine of this is a node page and will increment the statistics counter. |
if (_statistics_advanced_is_node_visit() && statistics_advanced_var('ignore_repeat_views')) { |
|
$is_node_visit = (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0)); |
|
|
|
|
|
if ($is_node_visit && statistics_advanced_var('ignore_repeat_views')) { |
|
| 82 |
// Save the current user's uid as we may find from the accesslog table that |
// Save the current user's uid as we may find from the accesslog table that |
| 83 |
// the user has logged out but has a record in the history table. |
// the user has logged out but has a record in the history table. |
| 84 |
$uid = $user->uid; |
$uid = $user->uid; |
| 123 |
} |
} |
| 124 |
|
|
| 125 |
/** |
/** |
| 126 |
|
* Determine if this page request is a node visit (e.g. node/x). |
| 127 |
|
*/ |
| 128 |
|
function _statistics_advanced_is_node_visit() { |
| 129 |
|
static $is_node_visit; |
| 130 |
|
if (!isset($is_node_visit)) { |
| 131 |
|
$is_node_visit = arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0); |
| 132 |
|
} |
| 133 |
|
return $is_node_visit; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
/** |
| 137 |
* Implementation of hook_exit(). |
* Implementation of hook_exit(). |
| 138 |
* |
* |
| 139 |
* Delete unwanted records. |
* Delete unwanted records. |
| 141 |
function statistics_advanced_exit() { |
function statistics_advanced_exit() { |
| 142 |
global $user; |
global $user; |
| 143 |
|
|
| 144 |
$is_node_visit = (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && variable_get('statistics_count_content_views', 0)); |
if (_statistics_advanced_is_node_visit()) { |
|
|
|
|
if ($is_node_visit) { |
|
| 145 |
if (_statistics_advanced_is_403_or_404()) { |
if (_statistics_advanced_is_403_or_404()) { |
| 146 |
// Ignore 404 and 403 node visits. |
// Ignore 404 and 403 node visits. |
| 147 |
_statistics_advanced_ignore('nodecounter', TRUE); |
_statistics_advanced_ignore('nodecounter', TRUE); |
| 148 |
} |
} |
| 149 |
|
elseif (user_access('exclude visits from counters')) { |
| 150 |
|
_statistics_advanced_ignore('nodecounter', TRUE); |
| 151 |
|
} |
| 152 |
/*else { |
/*else { |
| 153 |
// If the node has been previously read by the user and has changed since |
// If the node has been previously read by the user and has changed since |
| 154 |
// the last read, count it as a new read. |
// the last read, count it as a new read. |
| 172 |
$browser = browscap_get_browser(); |
$browser = browscap_get_browser(); |
| 173 |
if (!empty($browser['crawler'])) { |
if (!empty($browser['crawler'])) { |
| 174 |
_statistics_advanced_ignore('accesslog', TRUE); |
_statistics_advanced_ignore('accesslog', TRUE); |
| 175 |
if ($is_node_visit) { |
if (_statistics_advanced_is_node_visit()) { |
| 176 |
_statistics_advanced_ignore('nodecounter', TRUE); |
_statistics_advanced_ignore('nodecounter', TRUE); |
| 177 |
} |
} |
| 178 |
if (variable_get('browscap_monitor', 0) && function_exists('browscap_unmonitor')) { |
if (variable_get('browscap_monitor', 0) && function_exists('browscap_unmonitor')) { |