Drupal API

statistics_exit

  • Drupal 5
  • Drupal 6

modules/statistics/statistics.module, строка 44

Версии
5 – 6
statistics_exit()

Implementation of hook_exit().

This is where statistics are gathered on page accesses.

Код

<?php
function statistics_exit() {
  global $user, $recent_activity;
  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_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
      // If we affected 0 rows, this is the first time viewing the node.
      if (!db_affected_rows()) {
        // We must create a new row to store counters for the new node.
        db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', arg(1), time());
      }
    }
  }
  if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
    // Log this page access.
    db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", strip_tags(drupal_get_title()), $_GET['q'], referer_uri(), ip_address(), $user->uid, session_id(), timer_read('page'), time());
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему

Что такое OpenID?
  • Регистрация
  • Забыли пароль?

Документация

  • Drupal 6
  • Константы
  • Файлы
  • Функции
  • Глобальные переменные
  • Разделы