| 5 statistics.module | statistics_exit() |
| 6 statistics.module | statistics_exit() |
| 7 statistics.module | statistics_exit() |
| 8 statistics.module | statistics_exit() |
Implements hook_exit().
Gathers statistics for page accesses.
File
- core/
modules/ statistics/ statistics.module, line 51 - Logs and displays access statistics for a site.
Code
function statistics_exit() {
global $user;
// When serving cached pages with the 'page_cache_without_database'
// configuration, system variables need to be loaded. This is a major
// performance decrease for non-database page caches, but with Statistics
// module, it is likely to also have 'statistics_enable_access_log' enabled,
// in which case we need to bootstrap to the session phase anyway.
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
if (variable_get('statistics_enable_access_log', 0)) {
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
// For anonymous users unicode.inc will not have been loaded.
include_once DRUPAL_ROOT . '/core/includes/unicode.inc';
// Log this page access.
db_insert('accesslog')
->fields(array(
'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
// @todo The public function current_path() is not available on a cache
// hit.
'path' => truncate_utf8(_current_path(), 255),
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
'hostname' => ip_address(),
'uid' => $user->uid,
'sid' => session_id(),
'timer' => (int) timer_read('page'),
'timestamp' => REQUEST_TIME,
))
->execute();
}
}
Login or register to post comments