Drupal statistics logs every access to a page. It is kind-of useful when the user is logged in, but there are times when you want to see where the user physically comes from. For this situation you can just go into "details" and see his ip address. Copy and paste it into some kind of online ip2location service and see the results.
This code allows you to shorten that cycle to just one click.
Here we will enhance the statistics page, providing link to a ip2location free service
open the statistics.module and find the statistics_recent_hits function. The changes in code are marked bold
function statistics_recent_hits() {
....
$sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp, a.hostname 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'), 'class' => 'nowrap'),
_statistics_format_item($log->title, $log->path),
theme('username', $log).", ". l(check_plain($log->hostname), "http://www.ip2location.com/$log->hostname"),
l(t('details'), "admin/logs/access/$log->aid"));
}
...
after that you will have clickable ip address in the username column.
ip geolocation
Will this snippet work with Drupal 4.7.0
Thanx
Probably, yes
I think that will work in previous versions of Drupal, as it hasn't improved far in statistics.
Great example
Thanks. This worked very well and was easy to implement.
Rogue character issue?
There is a slight problem with this I found out. It is adding something at the top of the page before any of my html that is causing it to push down my html about 20px or so. My guess is a space or something but I sure can't find it or figure out exactly what is causing it.
It's definitely threre though in IE, Firefox and Chrome.
Thanks alot for this snippet
Thanks alot for this snippet !
I am going to give it a try
I am going to give it a try thanks!