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

attilahooper’s picture

Tried 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 ?

Pol’s picture

Hello Attilahooper,

I made a custom module for displaying this without altering core files.

Are you interested in it ?

attilahooper’s picture

Hey 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

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.