summaryrefslogtreecommitdiff
path: root/modules/statistics
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-05-19 19:05:27 +0000
committerDries Buytaert <dries@buytaert.net>2005-05-19 19:05:27 +0000
commite7b70296beed93c59f69fe1fc3181d2949c4765f (patch)
tree6ec502d7eac78f1f69cfc350b2e4d41d275bb7e9 /modules/statistics
parent5154c3aca4c9362cbd0fb236e0ea9dd5c7c0aa78 (diff)
downloadbrdo-e7b70296beed93c59f69fe1fc3181d2949c4765f.tar.gz
brdo-e7b70296beed93c59f69fe1fc3181d2949c4765f.tar.bz2
- Renamed "top users" page to "top visitors" and added some page generation times per user.
This make it trivial to spot evil crawlers.
Diffstat (limited to 'modules/statistics')
-rw-r--r--modules/statistics/statistics.module23
1 files changed, 12 insertions, 11 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 20bc687fb..62db34e55 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -114,8 +114,8 @@ function statistics_menu($may_cache) {
$items[] = array('path' => 'admin/logs/pages', 'title' => t('top pages'),
'callback' => 'statistics_top_pages', 'access' => $access,
'weight' => 1);
- $items[] = array('path' => 'admin/logs/users', 'title' => t('top users'),
- 'callback' => 'statistics_top_users', 'access' => $access,
+ $items[] = array('path' => 'admin/logs/visitors', 'title' => t('top visitors'),
+ 'callback' => 'statistics_top_visitors', 'access' => $access,
'weight' => 2);
$items[] = array('path' => 'admin/logs/referrers', 'title' => t('referrers'),
'callback' => 'statistics_top_referrers', 'access' => $access);
@@ -254,8 +254,8 @@ function statistics_top_pages() {
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'path'),
- array('data' => t('Average generation time'), 'field' => 'average_time'),
- array('data' => t('Total generation time'), 'field' => 'total_time')
+ array('data' => t('Average page generation time'), 'field' => 'average_time'),
+ array('data' => t('Total page generation time'), 'field' => 'total_time')
);
$sql .= tablesort_sql($header);
$result = pager_query($sql, 30, 0, $sql_cnt);
@@ -273,28 +273,29 @@ function statistics_top_pages() {
}
/**
- * Menu callback; presents the "top users" page.
+ * Menu callback; presents the "top visitors" page.
*/
-function statistics_top_users() {
+function statistics_top_visitors() {
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
- array('data' => t('User'), 'field' => 'u.name'),
+ array('data' => t('Visitor'), 'field' => 'u.name'),
+ array('data' => t('Total page generation time'), 'field' => 'total'),
);
- $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.uid, u.name". tablesort_sql($header);
+ $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname". tablesort_sql($header);
$sql_cnt = "SELECT COUNT(DISTINCT(uid)) FROM {accesslog}";
$result = pager_query($sql, 30, 0, $sql_cnt);
while ($account = db_fetch_object($result)) {
- $rows[] = array($account->hits, format_name($account));
+ $rows[] = array($account->hits, ($account->uid ? format_name($account) : $account->hostname), format_interval(round($account->total / 1000)));
}
if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
- $rows[] = array(array('data' => $pager, 'colspan' => '2'));
+ $rows[] = array(array('data' => $pager, 'colspan' => '3'));
}
- drupal_set_title(t('Top users in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
+ drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
return theme('table', $header, $rows);
}