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

IP Addresses in Users Online for all users
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #111  
Old 07-11-2013, 03:13 PM
  MythNReality's Avatar 
MythNReality MythNReality is offline
 

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

Default Re: IP Addresses in Users Online for all users

Quote:
Originally Posted by elmirage001
For 4.5.5 (not tested in other versions)

I used the Smarty function {$smarty.server.REMOTE_ADDR} so I don't need to make any changes to postauth.php or stats.php anymore.

In store/skin/common_files/modules/Users_online/stats.tpl

Change From:
To:
Works with V4.6.0!
__________________
_____________
Capture Your Mini-Me Look!

- X-CART Gold (Current Version) V4.6
- Reboot
- CDSEO
Reply With Quote
  #112  
Old 12-14-2013, 02:25 PM
  hoosierglass's Avatar 
hoosierglass hoosierglass is offline
 

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

Default Re: IP Addresses in Users Online for all users

Quote:
Originally Posted by elmirage001
For 4.5.5 (not tested in other versions)

I used the Smarty function {$smarty.server.REMOTE_ADDR} so I don't need to make any changes to postauth.php or stats.php anymore.

In store/skin/common_files/modules/Users_online/stats.tpl

Change From:
To:

I have the same issue that it shows my IP address and not that of the person or machine browsing. Does anyone have and thoughts of work arounds for this?
__________________
X-Cart Gold 4.6.6
Custom Work from www.luminointernet.com
www.indy-pen-dance.com
Reply With Quote
  #113  
Old 12-15-2013, 12:24 PM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,590
 

Default Re: IP Addresses in Users Online for all users

Quote:
Originally Posted by hoosierglass
I have the same issue that it shows my IP address and not that of the person or machine browsing. Does anyone have and thoughts of work arounds for this?

Works fine on my live 4.45 site but on my 4.6.0 dev site I have the same problem of all IPs showing as mine. It's on my list to look at before I go live with 4.6.x but it will most likely be a couple of months.
__________________
X-Cart GoldPlus v4.7.11 | PHP 7.2.22
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • Total Server Solutions Hosting | Linux | PHP v7.2 | MySQL v5.6.40 |
Reply With Quote
  #114  
Old 12-19-2013, 11:20 PM
  Mish's Avatar 
Mish Mish is offline
 

Advanced Member
  
Join Date: Feb 2008
Posts: 92
 

Default Re: IP Addresses in Users Online for all users

Hi everyone - you may want to check out this thread on making the Users Online table sortable and look good
__________________
X-Cart Gold 4.6.1
Reply With Quote
  #115  
Old 12-20-2013, 06:57 AM
  hoosierglass's Avatar 
hoosierglass hoosierglass is offline
 

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

Default Re: IP Addresses in Users Online for all users

So has anyone been able to figure out why {$smarty.server.REMOTE_ADDR} shows your IP and not that of the people browsing the site?
__________________
X-Cart Gold 4.6.6
Custom Work from www.luminointernet.com
www.indy-pen-dance.com
Reply With Quote
  #116  
Old 12-22-2013, 10:18 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: IP Addresses in Users Online for all users

{$smarty.server.REMOTE_ADDR} shows IP of the user viewing the template. Since you are the user viewing the page (and template), it displays yours IP.

So, instead of retrieving the address when the template is rendered, you should collect it in a php script and store in the user's session (so every user will have its IP in his session data). And, when displaying the template listing online users, show addresses stored in users' sessions.

Unfortunately, I can't post code that will work for all XC versions, but the logic will be as I've described.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #117  
Old 12-22-2013, 11:31 PM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,590
 

Default Re: IP Addresses in Users Online for all users

Hi Alex,
Thank you for the information. Can you let us know why it worked in 4.4.5?
Thank you! Paul
__________________
X-Cart GoldPlus v4.7.11 | PHP 7.2.22
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • Total Server Solutions Hosting | Linux | PHP v7.2 | MySQL v5.6.40 |
Reply With Quote
  #118  
Old 12-23-2013, 06:21 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 912
 

Default Re: IP Addresses in Users Online for all users

Everyone wants this small feature in admin so I request QT that it should be added by default since it's very small but useful feature.
Infact I have got more custom coded by using country IP detection functionality of module multi currency module & now I can see visitor's country also next to the IP address.
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote

The following 3 users thank anandat for this useful post:
elmirage001 (12-23-2013), hawk (02-22-2014), hawk (02-22-2014)
  #119  
Old 12-24-2013, 02:13 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: IP Addresses in Users Online for all users

Quote:
Originally Posted by elmirage001
Thank you for the information. Can you let us know why it worked in 4.4.5?

Black magic, I guess

Using {$smarty.server.REMOTE_ADDR} in the template listing online users will display your IP address for each user in the list, not IPs of these users. However, code from earlier posts in this thread should work - I see it stores REMOTE_ADDR in the user session.

Quote:
Originally Posted by anandat
Everyone wants this small feature in admin so I request QT that it should be added by default since it's very small but useful feature.


I've added your request to the wish list, but can't say when developers can start working on it - there is a lot of work in the list.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote

The following user thanks qualiteam for this useful post:
hawk (02-22-2014)
  #120  
Old 12-27-2013, 10:26 AM
 
elmirage001 elmirage001 is offline
 

X-Wizard
  
Join Date: Apr 2007
Posts: 1,590
 

Default Re: IP Addresses in Users Online for all users

I have it working now in 4.6.1 using an edited version of post 105 by Mish and the edit done by denlem in 106. Below is the code that I'm using.

In postauth.php
PHP Code:
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'] : "");

    
$current_date XC_TIME;

    if (empty(
$session_create_date)) {
        
$session_create_date $current_date;
    }

    
$session_ip getenv('REMOTE_ADDR');


In modules/Users_online/stats.php
PHP Code:
$rec['session_create_date'] = $data['session_create_date'] + $config["Appearance"]["timezone_offset"];
    
    
//if (!empty($data['session_ip']))
    //{
    //    if ($HTTP_SERVER_VARS['REMOTE_ADDR'] != $data['session_ip'])
    //       $rec['session_ip'] = gethostbyaddr($data['session_ip']);
    //    else
    //       $rec['session_ip'] = "Admin";
    // }
    // else
     
     
$rec['session_ip'] = $data['session_ip'];
    
    
$statistics[] = $rec

In skin/common_files/modules/Users_online/stats.tpl (denlem edit)
Replace
Code:
<td bgcolor="#FFFFFF" nowrap="nowrap" valign="top">{if $v.userinfo ne ''}<a href="{$catalogs.admin}/user_modify.php?user={$v.userinfo.id}&amp;usertype=C">{$v.userinfo.firstname} {$v.userinfo.lastname}</a>{if $v.userinfo.status eq 'A'}<br /><i>({$lng.lbl_anonymous_customer})</i>{/if}{else}{$lng.lbl_unregistered_customer}{/if}</td>

With
Code:
<td bgcolor="#FFFFFF" nowrap="nowrap" valign="top">{if $v.userinfo ne ''}<a href="{$catalogs.admin}/user_modify.php?user={$v.userinfo.id}&usertype=C">{$v.userinfo.firstname} {$v.userinfo.lastname}</a>{if $v.userinfo.status eq 'A'}<br /><i>({$lng.lbl_anonymous_customer})</i>{/if}{else}{$lng.lbl_unregistered_customer}{/if}</br>IP: <a href="http://cqcounter.com/whois/?query={$v.session_ip}" target="_blank">{$v.session_ip}</a> </td>

The only change I made was to comment out some of the added PHP code in stats.php. With that change it's working fine for me. Somebody else can play with the other PHP code if they want.
__________________
X-Cart GoldPlus v4.7.11 | PHP 7.2.22
  • XCARTMODS.CO.UK | reBOOT Template |
  • Smack Digital | CDSEO Pro 2.0 + Custom Replacements | Category SEO Map |
  • Total Server Solutions Hosting | Linux | PHP v7.2 | MySQL v5.6.40 |
Reply With Quote

The following 4 users thank elmirage001 for this useful post:
CB Tan (01-08-2016), josebueso (12-02-2016), PhilJ (04-24-2017), qualiteam (01-04-2014)
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:15 PM.

   

 
X-Cart forums © 2001-2018