Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I've added the IP and Hostname in the columns. Check the attached screenshot to see the result.
You just have to modifiy the file /modules/statistics/statistics.admin.inc and modify the function (statistics_recent_hits) as this:
function statistics_recent_hits() {
$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('IP')),
array('data' => t('Hostname ')),
array('data' => t('Operations'))
);
$sql = 'SELECT a.aid, a.path, a.title, a.uid, a.hostname, a.hostname2, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid'. tablesort_sql($header);
$result = pager_query($sql, 30);
$rows = array();
while ($log = db_fetch_object($result)) {
$hostname = gethostbyaddr($log->hostname);
$rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
_statistics_format_item($log->title, $log->path),
theme('username', $log),check_plain($log->hostname),check_plain($hostname),
l(t('details'), "admin/reports/access/$log->aid"));
}
if (empty($rows)) {
$rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
}
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 30, 0);
return $output;
}
Comments
Comment #1
attilahooper CreditAttribution: attilahooper commentedTried it. Got the following error;
Unknown column 'a.hostname2' in 'field list' query: SELECT a.aid, a.path, a.title, a.uid, a.hostname, a.hostname2, u.name, a.timestamp FROM accesslog a LEFT JOIN users u ON u.uid = a.uid ORDER BY a.timestamp DESC LIMIT 0, 30 in
edit: just noticed a possible typo:
array('data' => t('Hostname ')),
what's the space doing after the field name Hostname ?
Comment #2
PolHello Attilahooper,
I made a custom module for displaying this without altering core files.
Are you interested in it ?
Comment #3
attilahooper CreditAttribution: attilahooper commentedHey Pol. Yeah, I think I stumbled upon it doing some searches. I was using this original code of yours to get comfortable hacking (to learn) drupal core.
btw, I fixed that space after hostname and removed the a.hostname2 in the sql statement and 'recent hits' works on my Drupal 6 install.
And sure. If you'd like to post a link to your module I'd love to see it.
Regards,
AH