Jump to content

How to Show ( add) IP address to Last Connections (under admin view)


Recommended Posts

Hello again,

It would be good to include this change in the next release!

I have done a change that i thought might be usefull to some othe people as well... so i will share it.

It is about showing an ip address column in the "last connection" view .

Here are the steps:

1- under /classes
Edit customer.php find this function and change it to be like this :

       public function getLastConnections()
   {
       return Db::getInstance()->ExecuteS('
       SELECT c.date_add, COUNT(cp.id_page) AS pages, TIMEDIFF(MAX(cp.time_end), c.date_add) as time, http_referer,INET_NTOA(ip_address) as ipaddress
       FROM `'._DB_PREFIX_.'guest` g
       LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_guest = g.id_guest
       LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
       WHERE g.`id_customer` = '.intval($this->id).'
       GROUP BY c.`id_connections`
       ORDER BY c.date_add DESC
       LIMIT 10');
   }



as you can see that i have added the ip_address and used INET_NTOA to decript the IP to 4 bits again.

2- under /admin/tabs/ find admincustomers.php and change the following section :

>/* Last connections */
       $connections = $customer->getLastConnections();
       if (sizeof($connections))    
       {
           echo ''.$this->l('Last connections').'
</pre>
<table cellspacing="0" cellpadding="0">'.$this->l('Date').''.$this->l('Pages viewed').''.$this->l('Total time').''.$this->l('Origin').''.$this->l('IP Address').''.Tools::displayDate($connection['date_add'], intval($cookie->id_lang), true).''.intval($connection['pages']).''.$connection['time'].''.($connection['http_referer'] ? preg_replace('/^www./', '', parse_url($connection['http_referer'], PHP_URL_HOST)) : $this->l('Direct link')).''.$connection['ipaddress'].'</table>
<div> </div>';<br>       }<br><br>       echo '<a rel="">token.'"> '.$this->l('Back to customer list').'</a><br>';<b




Please Note, I have done these changes and they worked for me, but i have not done any further testing. make sure you a back up first, and on your own responsibility.

cheers.

PS: I hope someone replies to my previous post.

Link to comment
Share on other sites

×
×
  • Create New...