statistics_recent_hits

Versions
4.6
statistics_recent_hits($type = 'all', $id = 0)
4.7 – 7
statistics_recent_hits()

Menu callback; presents the "Recent hits" page.

Code

modules/statistics.module, line 224

<?php
function statistics_recent_hits($type = 'all', $id = 0) {
  $header = array(
    array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
    array('data' => t('Page'), 'field' => 'a.path'),
    array('data' => t('User'), 'field' => 'u.name'),
    array('data' => t('Operations'))
  );

  $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid' . tablesort_sql($header);

  $result = pager_query($sql, 30);
  while ($log = db_fetch_object($result)) {
    $rows[] = array(
      array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'),
      _statistics_format_item($log->title, $log->path),
      format_name($log),
      l(t('details'), "admin/logs/access/$log->aid"));
  }

  if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
    $rows[] = array(array('data' => $pager, 'colspan' => '4'));
  }

  print theme('page', theme('table', $header, $rows));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.