| Versionen | |
|---|---|
| drupal6 – drupal7 | statistics_exit() |
Implementation of hook_exit().
This is where statistics are gathered on page accesses.
modules/
<?php
function statistics_exit() {
global $user;
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
if (variable_get('statistics_count_content_views', 0)) {
// We are counting content views.
if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
// A node has been viewed, so update the node's counters.
db_merge('node_counter')
->key(array('nid' => arg(1)))
->fields(array(
'daycount' => 1,
'totalcount' => 1,
'timestamp' => REQUEST_TIME,
))
->expression('daycount', 'daycount + 1')
->expression('totalcount', 'totalcount + 1')
->execute();
}
}
if (variable_get('statistics_enable_access_log', 0)) {
// Log this page access.
db_insert('accesslog')
->fields(array(
'title' => strip_tags(drupal_get_title()),
'path' => $_GET['q'],
'url' => $_SERVER['HTTP_REFERER'],
'hostname' => ip_address(),
'uid' => $user->uid,
'sid' => session_id(),
'timer' => (int) timer_read('page'),
'timestamp' => REQUEST_TIME,
))
->execute();
}
}
?>
Kommentare
Kommentar hinzufügen