View Single Post
  #80  
Old 02-12-2010, 03:12 PM
  Dan.roh's Avatar 
Dan.roh Dan.roh is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 397
 

Default Re: IP Addresses in Users Online for all users

Works perfect for me in 4.1! I just added a <br/> before the "IP:" as I prefer the IP to display underneath customer in admin. Thanks for sharing!

Not sure if this already shows up in your admin area but it does not in mine and it was a bit frustrating for me as I also wanted to be able to see from my admin "users online" the actual amount of users on my site as well as the amount of adminastrators that is logged into admin so this is what I did

In xcart>skin1>modules>Users_online>stats.tpl

at the top line 2 right underneath {* $Id: stats.tpl............ I placed the following code

{if $users_online}
<div class="BottomDialogBox">
{$lng.lbl_users_online}:
{foreach from=$users_online item=v name="_users"}
<font class="VertMenuItems" style="WHITE-SPACE: nowrap;">{$v.count}
{strip}
{if $v.usertype eq 'A' || ($v.usertype eq 'P' && $active_modules.Simple_Mode)}
{$lng.lbl_admin_s}
{elseif $v.usertype eq 'P'}
{$lng.lbl_provider_s}
{elseif $v.usertype eq 'B'}
{$lng.lbl_partner_s}
{elseif $v.usertype eq 'C' && $v.is_registered eq 'Y'}
{$lng.lbl_registered_customer_s}
{elseif $v.usertype eq 'C' && $v.is_registered eq 'A'}
{$lng.lbl_anonymous_customer_s}
{elseif $v.usertype eq 'C' && $v.is_registered eq ''}
{$lng.lbl_unregistered_customer_s}
{/if}
{if not $smarty.foreach._users.last} {/if}
{/strip}
</font>
{/foreach}
</div>
{/if}


I also placed the same code right at the bottom of stats.tpl underneath all code as it makes that bit of a difference to me


Quote:
Originally Posted by hamid
With this mod you can see the IP Address of all users (including "Unregistered User") in the Users Online page.

I've only tested this mod with v4.0.14, but it should work just as well in 4.0.x.

It's really easy to implement this modification, but remember to backup your files before you make any changes.

What the following changes do is:

1. Creates a new entry in session data called session_ip
2. Saves users IP address in session_ip
3. Calls session_ip data in the .tpl file

You have to change 3 files:

1. auth.php
2. xcart>modules>Users_online>stats.php
3. xcart>skin1>modules>Users_online>stats.tpl

On (or around) line 64 in auth.php look for:


Code:
*********************************************** if(!empty($active_modules['Users_online'])) { 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(); } *********************************************** And change it to: *********************************************** 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'); } ***********************************************

Then on line 50 in xcart>modules>Users_online>stats.php look for:

Code:
*********************************************** $vars = array("login", "login_type", "cart", "current_date", "current_url_page", "session_create_date"); *********************************************** And change it to: *********************************************** $vars = array("login", "login_type", "cart", "current_date", "current_url_page", "session_create_date", "session_ip"); ***********************************************

In the same file (stats.php), look for the following on line 94:

Code:
*********************************************** $rec['session_create_date'] = $data['session_create_date']+$config["General"]["timezone_offset"]; $statistics[] = $rec; *********************************************** And change it to: *********************************************** $rec['session_create_date'] = $data['session_create_date']+$config["General"]["timezone_offset"]; $rec['session_ip'] = $data['session_ip']; $statistics[] = $rec; ***********************************************

And finally you have to put "IP: {$v.session_ip}" into xcart>skin1>modules>Users_online>stats.tpl

On line 20 look for:

Code:
*********************************************** <TD bgcolor="#FFFFFF" nowrap valign="top">{if $v.userinfo ne ''}{$v.userinfo.firstname} {$v.userinfo.firstname}{if $v.userinfo.status eq 'A'} ({$lng.lbl_anonymous_customer}){/if}{else}{$lng.lbl_unregistered_customer}{/if}</TD> *********************************************** And change it to: *********************************************** <TD bgcolor="#FFFFFF" nowrap valign="top">{if $v.userinfo ne ''}{$v.userinfo.firstname} {$v.userinfo.firstname}{if $v.userinfo.status eq 'A'}({$lng.lbl_anonymous_customer}){/if}{else}{$lng.lbl_unregistered_customer}{/if} IP: {$v.session_ip}</TD> ***********************************************

That's all the changes done, now go to the Users Online section [in Admin>Statistics>Users Online] and the IP Address of customers currently on your site should appear underneath their names.

If you reload your Users Online page at regular intervals you can watch how your customers navigate your site.
__________________
Regards

Dan


Xcart version:
4.1.10 GOLD
Reply With Quote