X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   IP Addresses in Users Online for all users (https://forum.x-cart.com/showthread.php?t=16571)

denlem 06-19-2009 04:43 PM

Re: IP Addresses in Users Online for all users
 
Quote:

Originally Posted by gary02140
In case that this dnsstuff is not available in the future, http://www.netip.de/ can be a good option. But I just don't know how to code it into the mod. Can someone here figure it out?


A little different change for this one... Find:

Code:

http://www.dnsstuff.com/tools/whois.ch?ip={$v.session_ip}&cache=off" target="_blank">{$v.session_ip}</a>


And change to:

Code:

http://www.netip.de/search?query={$v.session_ip}" target=_blank">{$v.session_ip}</a>


donmck 06-19-2009 06:33 PM

Re: IP Addresses in Users Online for all users
 
thanks, that link looks a much better proposition.

Cheers Don...

denlem 06-20-2009 06:08 AM

Re: IP Addresses in Users Online for all users
 
I like that one better myself, but don't know how accurate it will be. I just checked one that should be from Florida (USA), but it shows it's location as in the water, on the equator, off the coast of Africa.

gary02140 07-03-2009 12:51 PM

Re: IP Addresses in Users Online for all users
 
Quote:

Originally Posted by denlem
I like that one better myself, but don't know how accurate it will be. I just checked one that should be from Florida (USA), but it shows it's location as in the water, on the equator, off the coast of Africa.



http://phpweby.com/services/iplocation?ip={$v.session_ip}" target=_blank">{$v.session_ip}</a>

This one is more accurate and free.

toolauthority 07-10-2009 05:23 AM

Re: IP Addresses in Users Online for all users
 
I have run into that problem when I worked with the Google Maps API, that location is 0,0. Basically, it couldn't locate it.

gary02140 07-11-2009 06:24 PM

Re: IP Addresses in Users Online for all users
 
Quote:

Originally Posted by toolauthority
I have run into that problem when I worked with the Google Maps API, that location is 0,0. Basically, it couldn't locate it.


I haven't got the same problem yet after switch. And the new one works well for me.

William Lam 09-05-2009 01:36 AM

Re: IP Addresses in Users Online for all users
 
Neorag,

I followed your exact steps, all seems ok, but the IP address is not showing up.

Im using 4.2.2

dwpers 02-04-2010 10:28 AM

Re: IP Addresses in Users Online for all users
 
I see some are using this with 4.2, but when I look for auth.php I only see auth.tpl and I don't see the users online code.

This is what I have:

Code:

{*
$Id: auth.tpl,v 1.51 2008/12/08 08:40:11 svowl Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $main ne "login_incorrect" and $main ne "antibot_error" and $main ne "disabled" or $config.Security.use_secure_login_page eq "Y"}
{capture name=menu}
{if $config.Security.use_https_login eq "Y"}
{assign var="form_url" value=$https_location}
{else}
{assign var="form_url" value=$current_location}
{/if}
<form action="{$form_url}/include/login.php" method="post" name="authform" onsubmit="javascript: return lockForm(this);">
<input type="hidden" name="{$XCARTSESSNAME}" value="{$XCARTSESSID}" />
<table cellpadding="0" cellspacing="0" class="AuthBox" align="center">
{if $config.Security.use_secure_login_page eq "Y"} {* use_secure_login_page *}
<tr>
<td>
{assign var="slogin_url_add" value=""}
{if $usertype eq "C"}
{assign var="slogin_url" value=$catalogs_secure.customer}
{if $catalogs_secure.customer ne $catalogs.customer}
{assign var="slogin_url_add" value="?`$XCARTSESSNAME`=`$XCARTSESSID`"}
{/if}
{elseif $usertype eq "P" and $active_modules.Simple_Mode eq "Y" or $usertype eq "A"}
{assign var="slogin_url" value=$catalogs_secure.admin}
{elseif $usertype eq "P"}
{assign var="slogin_url" value=$catalogs_secure.provider}
{elseif $usertype eq "B"}
{assign var="slogin_url" value=$catalogs_secure.partner}
{/if}
{include file="buttons/secure_login.tpl"}
</td>
</tr>
{else} {* use_secure_login_page *}
<tr>
<td class="VertMenuItems">
<font class="VertMenuItems">{$lng.lbl_username}</font><br />
<input type="text" name="username" size="17" value="{#default_login#|default:$username}" /><br />
<font class="VertMenuItems">{$lng.lbl_password}</font><br />
<input type="password" name="password" size="17" maxlength="64" value="{#default_password#}" /><br />
<input type="hidden" name="mode" value="login" />
{if $active_modules.Simple_Mode ne "" and $usertype ne "C" and $usertype ne "B"}
<input type="hidden" name="usertype" value="P" />
{else}
<input type="hidden" name="usertype" value="{$usertype|escape}" />
{/if}
<input type="hidden" name="redirect" value="{$redirect|amp}" />
</td></tr>
{if $active_modules.Image_Verification and $show_antibot.on_login eq 'Y' && $login_antibot_on}
<tr>
<td class="VertMenuItems">
{include file="modules/Image_Verification/spambot_arrest.tpl" mode="simple_column" id=$antibot_sections.on_login}
</td>
</tr>
{/if}
{if $usertype ne "C" and ($usertype ne "B" or $config.XAffiliate.partner_register ne "Y")}
<tr>
<td align="center" height="24" class="VertMenuItems"><br />{include file="buttons/login_menu.tpl" style="button" button_style="menu"}</td>
</tr>
{/if}
{/if} {* use_secure_login_page *}
{if $usertype eq "C" or ($usertype eq "B" and $config.XAffiliate.partner_register eq "Y")}
<tr>
<td align="center" height="24" nowrap="nowrap" class="VertMenuItems">
<br />
<table cellpadding="0" cellspacing="0">
<tr>
{if $config.Security.use_secure_login_page ne "Y"}
<td height="24" class="VertMenuItems">{include file="buttons/login_menu.tpl" style="button" button_style="menu"}</td>
<td><img src="{$ImagesDir}/spacer.gif" width="10" height="1" alt="" /></td>
{/if}
<td>{include file="buttons/create_profile_menu.tpl" style="button" button_style="menu"}</td>
</tr>
</table>
</td>
</tr>
{/if}
{if $login eq ""}
<tr>
<td align="center" height="24" nowrap="nowrap" class="VertMenuItems"><a href="help.php?section=Password_Recovery" class="VertMenuItems" style="text-decoration: underline;">{$lng.lbl_recover_password}</a></td>
</tr>
{/if}
{if $is_https_zone && (($usertype eq "P" && $active_modules.Simple_Mode) || $usertype eq "A")}
<!-- insecure login form link -->
<tr>
<td class="VertMenuItems">
<br />
<div align="center"><a href="insecure_login.php" class="SmallNote">{$lng.lbl_insecure_login}</a></div>
</td>
</tr>
<!-- insecure login form link -->
{/if}
</table>
</form>
{/capture}
{ include file="menu.tpl" dingbats="dingbats_authentification.gif" menu_title=$lng.lbl_authentication menu_content=$smarty.capture.menu }
{/if}


A1Gifts 02-04-2010 01:48 PM

Re: IP Addresses in Users Online for all users
 
I know this is an old thread but I have 4.2.2 and my postauth.php is different than the example given on any page. My postauth.php looks like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?php
/************************************************** ***************************\
#
# $Id: postauth.php,v 1.6.2.2 2009/06/18 07:34:23 aim Exp $
#

if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }
# Prevent double inclusion.
if (defined('INCLUDED_POSTAUTH_PHP')) {
return;
}

define('INCLUDED_POSTAUTH_PHP', 1);
x_session_register("logout_user");
x_session_register("session_failed_transaction");
x_session_register("add_to_cart_time");

x_session_register("always_allow_shop");
x_session_register("search_data");

if (!empty($_GET["shopkey"]))
$always_allow_shop = (!empty($config["General"]["shop_closed_key"]) && $_GET["shopkey"] == $config["General"]["shop_closed_key"]);

if ($config["General"]["shop_closed"] == "Y" && !$always_allow_shop){
#
# Close store front
# Thanks to rubyaryat for the Shop Closed mod
#
if (!func_readfile($xcart_dir.DIRECTORY_SEPARATOR.$sh op_closed_file, true))
echo func_get_langvar_by_name("txt_shop_temporarily_una ccessible",false,false,true);
exit();
}

require $xcart_dir."/include/nocookie_warning.php";
if (!defined('HTTPS_CHECK_SKIP')) {
@include $xcart_dir.DIR_CUSTOMER."/https.php";
}

if (!empty($active_modules['Users_online']) || !empty($active_modules["Greet_Visitor"])) {
x_session_register("session_create_date");
if (empty($session_create_date))
$session_create_date = time();
}

if (!empty($active_modules['Users_online'])) {
x_session_register("current_url_page");
x_session_register("current_date");
$current_url_page = $php_url['url'].($php_url['query_string']?"?".$php_url['query_string']:"");

$current_date = time();
}

#
# Display
#
x_session_register("wlid");
if (isset($_GET["wlid"]) and $_GET["wlid"])
$wlid = $_GET["wlid"];

$smarty->assign("wlid", $wlid);
#
# Browser have disabled/enabled javasript switching
#
x_session_register("js_enabled", "Y");

if (!isset($js_enabled)) $js_enabled="Y";
if (isset($_GET["js"])) {
if ($_GET["js"]=="y") {
$js_enabled = "Y";
$config['Adaptives']['isJS'] = "Y";
$adaptives['isJS'] = "Y";
}
elseif ($_GET["js"]=="n") {
$js_enabled = "";
}
}

$qry_string = func_qs_remove($php_url['query_string'], 'js');
$js_update_link = $php_url['url'].'?'.(!empty($qry_string) ? $qry_string."&" : "");
if ($js_enabled == "Y") {
$js_update_link .= "js=n";
} else {
$js_update_link .= "js=y";
}
unset($qry_string);

$smarty->assign("js_update_link", $js_update_link);
$smarty->assign("js_enabled", $js_enabled);

x_session_register("top_message");
if (!empty($top_message)) {
$top_message['type'] = !empty($top_message['type']) ? $top_message['type'] : "I";
switch ($top_message['type']) {
case "E":
$top_message['title'] = func_get_langvar_by_name("lbl_error", array(), false, true);
break;

case "W":
$top_message['title'] = func_get_langvar_by_name("lbl_warning", array(), false, true);
break;

default:
$top_message['title'] = func_get_langvar_by_name("lbl_information", array(), false, true);
}
$smarty->assign("top_message", $top_message);
if ($config['Adaptives']['is_first_start'] != 'Y')
$top_message = "";

x_session_save("top_message");
}

$cat = intval(@$cat);
$page = intval(@$page);

if (!empty($active_modules['XAffiliate'])) {
include $xcart_dir."/include/partner_info.php";
include $xcart_dir."/include/adv_info.php";
}

include $xcart_dir.DIR_CUSTOMER."/referer.php";
include $xcart_dir."/include/check_useraccount.php";
include $xcart_dir."/include/get_language.php";
$lbl_site_name = strip_tags(func_get_langvar_by_name("lbl_site_titl e", "", false, true));
$location = array();
$location[] = array((!empty($lbl_site_name) ? $lbl_site_name : $config["Company"]["company_name"]), "home.php");

include $xcart_dir.DIR_CUSTOMER."/minicart.php";
if (!empty($active_modules["Interneka"])) {
include $xcart_dir."/modules/Interneka/interneka.php";
}

if (!empty($active_modules["Subscriptions"])) {
if ($login) {
include $xcart_dir."/modules/Subscriptions/get_subscription_info.php";
$smarty->assign("user_subscription", is_user_subscribed($login));
}
}

$pages_menu = func_query("SELECT * FROM $sql_tbl[pages] WHERE language='$store_language' AND active='Y' AND level='E' AND show_in_menu='Y' ORDER BY orderby, title");
$smarty->assign("pages_menu", $pages_menu);

$speed_bar = unserialize($config["speed_bar"]);
if (!empty($speed_bar)) {
$tmp_labels = array();

foreach ($speed_bar as $k => $v) {
if ($v["active"] != "Y") {
unset($speed_bar[$k]);
continue;
}

$speed_bar[$k] = func_array_map("stripslashes", $v);
$tmp_labels[] = "speed_bar_".$v['id'];
}

if (!empty($speed_bar)) {
$tmp = func_get_languages_alt($tmp_labels);
foreach ($speed_bar as $k => $v) {
if (isset($tmp['speed_bar_'.$v['id']]))
$speed_bar[$k]['title'] = $tmp['speed_bar_'.$v['id']];
}

$smarty->assign("speed_bar", array_reverse($speed_bar));
}
}

unset($speed_bar);
$smarty->assign("redirect", "customer");
if (!empty($active_modules["News_Management"]))
include $xcart_dir."/modules/News_Management/news_last.php";

if (!empty($active_modules["Feature_Comparison"])) {
include $xcart_dir."/modules/Feature_Comparison/comparison_products.php";

if ($config['Feature_Comparison']['fcomparison_show_product_list'] == 'Y') {
$comparison_list = func_get_comparison_list();
$smarty->assign("comparison_list",$comparison_list);
}
}

if (!empty($active_modules["Survey"])) {
include_once $xcart_dir."/modules/Survey/surveys_list.php";
}

if (!empty($active_modules['Special_Offers'])) {
include_once $xcart_dir."/modules/Special_Offers/check_new_offers.php";
}

if (isset($printable))
$smarty->assign("printable", $printable);
$smarty->assign("logout_user", $logout_user);

?>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I hate to just assume I can change anything even if it doesn't like the examples given.

Anyone able to help??

Thank you!

A1Gifts
www.A1DiscountGifts.com

Dan.roh 02-12-2010 03:12 PM

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.



All times are GMT -8. The time now is 12:44 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.