Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

IP In Admin Users Online for 4.3

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 08-04-2010, 07:52 AM
 
Torres Torres is offline
 

Member
  
Join Date: Apr 2010
Posts: 26
 

Default Re: IP In Admin Users Online for 4.3

If you'd like to use your own geo location table instead. You can download the SQL script from http://ipinfodb.com/ip_database.php. The advantage is speed and less code. The disadvantage is that you'll be responsible to update it.

I use the complete single city one.

In \modules\Users_online\stats.php, change:
$rec['session_ip'] = $data['session_ip'];

to this:

PHP Code:
/************* BEGIN Hack: Show IP Address in "Users Online" **********/

  
if ($data['session_ip']) {
    
$rec['session_ip'] = $data['session_ip'];

    
$ipQuery db_query("Select * from `ip_group_city` where `ip_start` <= INET_ATON('".$data['session_ip']."') order by ip_start desc limit 1;");
    if (
$ipQuery) {
      while (
$ipInfo mysql_fetch_assoc($ipQuery)) {
        
$rec['country'] = $ipInfo['country_name'];
        
$rec['region'] = $ipInfo['region_name'];
        
$rec['city'] = $ipInfo['city'];
        
$rec['flag'] = str_replace(" ","_",strtolower($ipInfo['country_name']));
      }
    }
  }
  
/************* END Hack ***********************************************/ 


Use the same template changes (to stats.tpl) shown in the previous above.

That's it. Like the previous post, this will also show you the IP Address, flag of the visitor's country, and their city. Hover the city shows the province/state.
__________________
X-Cart 4.3.2
X-SpecialOffers
Reply With Quote
  #12  
Old 08-04-2010, 09:08 AM
 
bionicfish bionicfish is offline
 

Member
  
Join Date: Jun 2006
Posts: 10
 

Default Re: IP In Admin Users Online for 4.3

I have actually put together a simliar bit of code, have been working on it for a while actually, just havent gotten around to posting yet as working on making it a bit more than just a hack but a proper solution.

A couple of chanllenges that I have had:
- Retrieving from an online database can be slow (as you have seen) so I have done this with Ajax instead, loading the flags and geolocation, after the initial page load.
- Most online services have a limit on the number of requests, so I cached the last 60 days ip geolocations locally, to reduce the lookups.
- Lots of bots / spiders show up as "active users" therefore I have built some additional filters around these to remove them from the list

Anyway... am happy to see others are thinking in the same way... when i get around to it I will post up the code for everybody, am thinking about doing this as an add-on module to make it more accessible to people who are not complete code monkeys!

If anybody is interested in doing some beta testing PM me and once I have done the code a bit cleaner, I will send you a copy.
__________________
Xcart 4.3.1
Reply With Quote
  #13  
Old 08-05-2010, 06:54 PM
 
SID357 SID357 is offline
 

eXpert
  
Join Date: May 2010
Posts: 205
 

Default Re: IP In Admin Users Online for 4.3

Any idea if this works on Pro? Tried Hoosiers original post, but couldn't get it to work.

thnx
Reply With Quote
  #14  
Old 12-22-2010, 01:26 PM
  MythNReality's Avatar 
MythNReality MythNReality is offline
 

X-Adept
  
Join Date: Mar 2005
Location: S. Cali
Posts: 403
 

Thumbs up Re: IP In Admin Users Online for 4.3

Thank you, hoosierglass, for sharing this code.

Post #1 works for V4.4.1 (except you need to remove one "}" after
the:

if (!empty($active_modules['Users_online'])) {
x_session_register("session_ip");

x_session_register("current_url_page");
x_session_register("current_date");
x_session_register("session_create_date");
$current_url_page = $php_url['url'].($php_url['query_string']?"?".$php_url['query_string']:"");
if (empty($session_create_date))
$session_create_date = time();
$current_date = time();
$session_ip = getenv('REMOTE_ADDR');
}
} <---- remove !!!
__________________
_____________
Capture Your Mini-Me Look!

- X-CART Gold (Current Version) V4.6
- Reboot
- CDSEO
Reply With Quote
  #15  
Old 12-22-2010, 09:17 PM
  MythNReality's Avatar 
MythNReality MythNReality is offline
 

X-Adept
  
Join Date: Mar 2005
Location: S. Cali
Posts: 403
 

Default Re: IP In Admin Users Online for 4.3

would someone please help...where shall I place the downloaded "SQL script" file?
__________________
_____________
Capture Your Mini-Me Look!

- X-CART Gold (Current Version) V4.6
- Reboot
- CDSEO
Reply With Quote
  #16  
Old 06-05-2011, 08:36 AM
  hoosierglass's Avatar 
hoosierglass hoosierglass is offline
 

X-Adept
  
Join Date: Aug 2006
Location: Zionsville, IN
Posts: 974
 

Default Re: IP In Admin Users Online for 4.3

If anyone has a work around for this in version 4.4.3 I would love to hear about it. Everything I have tried crashes the site.
__________________
X-Cart Gold 4.7.7
Custom Work from www.luminointernet.com
www.indy-pen-dance.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:15 PM.

   

 
X-Cart forums © 2001-2020