Commit e7b70296 authored by Dries's avatar Dries

- Renamed "top users" page to "top visitors" and added some page generation times per user.

  This make it trivial to spot evil crawlers.
parent 5154c3ac
......@@ -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);
}
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment