Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

User Tracking with Admin 1.31 Released


Druide

Recommended Posts

:oops:

 

my mistake

 

try this line of code.....

 

 

tep_db_query("delete from ' . TABLE_USER_TRACKING . ' where time_last_click < " . (time() - ($purge * 3600)));

Link to comment
Share on other sites

  • Replies 570
  • Created
  • Last Reply

Top Posters In This Topic

Thank you! It is working now.

 

Could you please tell me what I'm suppose to put in this area?

User Tracking (exclude this IP-Address)

I didn't understand it.

 

Also, could you please put these additional statements in your "how to install" file and fix that user_tracking.php page and upload it again so I can download a fresh copy?

 

== start ===========================

 

in your admin/includes/column_left.php file add

 

require(DIR_WS_BOXES . 'user_tracking.php');

====================================

 

and

 

== start ===========================

ADD TO admin/includes/languages/english.php and all other languages if needed...

 

define('BOX_USER_TRACKING', 'User Tracking');

 

in includes/application_top.php or languages/english.php you can add

define('TEXT_USERTRACK_CONFIG','User Track Config');

 

== end ===========================

 

I put this one in the english.php file to keep them together.

 

Thanks!

Link to comment
Share on other sites

Everybody happy ?

 

Gosh i didnt know it was THAT hard to make it so that everyone can implement it without any error

 

in about 1 hour from now i will upload version 1.32

 

changes:

- ready for multi language support

- added admin user tracking (for those who have multiple admins)

- ready for those who have set

define ('TIME', strtotime(gmstrftime("%Y-%m-%d %H:%M:%S", strtotime ("- 5 hour"))));

define ('NOW', gmdate ('Y-m-d H:i:s', time() - 5 *3600));

in their application_top.php (admin & catalog)

the '- 5' in both lines is the timezone difference on my server and my timezone

- and more changes

 

patience is a virtue ;)

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

Hi Steve,

 

Maybe try and start over is all I can suggest.

 

Here is a copy of the fixed page in admin/user_tracking.php if you need it.

 

<?php

/*

$Id: user_tracking.php,v 1.30 2003/03/10 10:20:11 robert Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

 

Modified by Andrew Edmond

Sept 14th, 2002

*/

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

$LIMIT_DISPLAY_SESSIONS = CONFIG_USER_TRACKING_SESSION_LIMIT; // SET to 999999 for unlimited per 24 hour period

 

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td class="smallText">

 

<?php

if ($purge == '72')

{

tep_db_query("delete from ' . TABLE_USER_TRACKING . ' where time_last_click < " . (time() - ($purge * 3600)));

echo "<font color=red>" . TEXT_HAS_BEEN_PURGED . "</font><p>";

}

 

if ($delip == '1')

{

tep_db_query("DELETE FROM " . TABLE_USER_TRACKING . " WHERE ip_address = '" . CONFIG_USER_TRACKING_EXCLUDED . "'");

echo "<font color=red>" . CONFIG_USER_TRACKING_EXCLUDED . ' has been deleted. </font><p>';

$delip='0';

}

if ($delsession)

{

tep_db_query("DELETE FROM " . TABLE_USER_TRACKING . " WHERE session_id = '" . $delsession . "'");

echo "<font color=red>" . $delsession . ' has been deleted. </font><p>';

}

 

echo EXPLAINATION, "<p>";

 

// some time routines

$time_frame = time();

if ($HTTP_GET_VARS['time'])

{

$time_frame = $HTTP_GET_VARS['time'];

}

 

echo '<b>' . TEXT_SELECT_VIEW .': </b>';

echo '<a href="' . FILENAME_USER_TRACKING . '?time=' ;

echo $time_frame - 86400 . '"><font color=blue>' . TEXT_BACK_TO . ' ' . date("M d, Y", $time_frame - 86400) . '</font></a> ' ;

 

if (time() > $time_frame + 86400)

{

echo '| <a href="' . FILENAME_USER_TRACKING . '?time=' ;

echo $time_frame + 86400 . '"><font color=blue>' . TEXT_FORWARD_TO . date("M d, Y", $time_frame + 86400) . '</font></a>';

} else { echo '';

}

 

echo "<p>" . TEXT_DISPLAY_START . $LIMIT_DISPLAY_SESSIONS . TEXT_DISPLAY_END;

echo TEXT_PURGE_START . ' <a href="user_tracking.php?purge=72"><font color=blue>'. TEXT_PURGE_RECORDS. '</font></a> ' . TEXT_PURGE_END. '</font><p>';

 

echo 'Delete all info from IP-Address ' . CONFIG_USER_TRACKING_EXCLUDED . ' <a href="user_tracking.php?delip=1"><font color=blue>'. TEXT_PURGE_RECORDS. '</font></a> </font><p>';

 

// we need to slurp all the customer tracking information out of the database

 

$whos_online_query =

tep_db_query("select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, page_desc," .

" session_id from " . TABLE_USER_TRACKING .

" where time_entry > " . ($time_frame - 86400) .

" and time_entry < " . $time_frame .

" order by time_last_click desc");

$results = 0;

while ($whos_online = tep_db_fetch_array($whos_online_query))

{

$user_tracking[$whos_online['session_id']]['session_id']=$whos_online['session_id'];

$user_tracking[$whos_online['session_id']]['ip_address']=$whos_online['ip_address'];

$user_tracking[$whos_online['session_id']]['customer_id']=$whos_online['customer_id'];

 

if ($whos_online['full_name'] != 'Guest')

$user_tracking[$whos_online['session_id']]['full_name']=$whos_online['full_name'];

 

$user_tracking[$whos_online['session_id']]['last_page_url'][$whos_online['time_last_click']] = $whos_online['last_page_url'];

$user_tracking[$whos_online['session_id']]['page_desc'][$whos_online['time_last_click']] = $whos_online['page_desc'];

 

if (($user_tracking[$whos_online['session_id']]['time_entry'] > $whos_online['time_entry']) ||

(!$user_tracking[$whos_online['session_id']]['time_entry']))

$user_tracking[$whos_online['session_id']]['time_entry'] = $whos_online['time_entry'];

if (($user_tracking[$whos_online['session_id']]['end_time'] < $whos_online['time_entry']) ||

(!$user_tracking[$whos_online['session_id']]['end_time']))

$user_tracking[$whos_online['session_id']]['end_time'] = $whos_online['time_entry'];

$results ++;

}

 

?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td valign="top" align=center><table border="0" width="95%" cellspacing="0" cellpadding="2">

 

<?php

 

// now let's display it

 

$listed=0;

if ($results)

while (($ut = each($user_tracking)) && ($listed++ < $LIMIT_DISPLAY_SESSIONS))

{

$time_online = (time() - $ut['value']['time_entry']);

if ( ((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $ut['value']['session_id'])) && (!$info) ) {

$info = $ut['value']['session_id'];

}

echo '

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent" colspan="5">'.TABLE_HEADING_SESSION_ID .' <a href="user_tracking.php?time=' . $time_frame . '&viewsession=All"><font color=purple>[show all tracked pages]</font></a></td>

<td class="dataTableHeadingContent" colspan="1 width="150">'.TEXT_USER_SHOPPING_CART.'</td>

</tr>';

 

 

echo ' <tr class="dataTableRowSelected">' . "n";

 

if ($ut['value']['full_name'] == "")

$ut['value']['full_name'] = "Guest";

?>

<td colspan = "5" class="dataTableContent" valign="top"></b><a name="<?php echo $ut['value']['session_id'];?>"><?php echo $ut['value']['full_name'] . '</b>, ' . $ut['value']['session_id'] . ", <a href="user_tracking.php?time=" . $time_frame . "&delsession=" . $ut['value']['session_id'] . ""><font color=red>[delete session]</font></a>" . ", <a href="user_tracking.php?time=" . $time_frame . "&viewsession=" . $ut['value']['session_id'] . "#" . $ut['value']['session_id'] . ""><font color=green>[view pages]</font></a>";?></td>

<?php

 

// shopping cart decoding

$session_data = tep_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $ut['value']['session_id'] . "'");

if (tep_db_num_rows($session_data)) {

$session_data = tep_db_fetch_array($session_data);

$session_data = trim($session_data['value']);

} else {

$session_data = @file(tep_session_save_path() . '/sess_' . $ut['value']['session_id']);

$session_data = trim($session_data[0]);

}

$cart = "";

$referer_url = "";

$num_sessions ++;

session_decode($session_data);

 

$contents = array();

if (is_object($cart)) {

$products = $cart->get_products();

for ($i=0; $i<sizeof($products); $i++) {

$contents[] = array('text' => $products[$i]['quantity'] . ' x ' . $products[$i]['name']);

}

if (sizeof($products) > 0) {

$contents[] = array('text' => tep_draw_separator('pixel_black.gif', '100%', '1'));

$contents[] = array('align' => 'right', 'text' => TEXT_SHOPPING_CART_SUBTOTAL . ' ' . $currencies->format($cart->show_total(), true, $currency));

} else {

$contents[] = array('text' => ' ');

}

}

 

$heading = array();

 

if (tep_not_null($contents))

{

 

echo ' <td rowspan="4" valign="top">' . "n";

 

$box = new box;

 

echo $box->infoBox($heading, $contents);

echo ' </td>' . "n";

}

else

{

echo ' <td rowspan="4" valign="top" class="dataTableContent" align="center">session expired' . "n";

echo ' </td>' . "n";

 

}

 

?>

 

</tr>

<tr>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TABLE_HEADING_IP_ADDRESS ?></b></td>

<td class="dataTableContent" valign="top"><a href="http://www.dnsstuff.com/tools/whois.ch?ip=<?php echo $ut['value']['ip_address'] ; ?>" target="_new"><?php echo $ut['value']['ip_address'] ; ?></a></td>

<td class="dataTableContent" colspan=2 rowspan=2 align="center">

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TABLE_HEADING_ENTRY_TIME; ?></b></td>

<td class="dataTableContent" colspan="2" valign="top"><?php echo date('H:i:s', $ut['value']['time_entry']); ?></td>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TEXT_IDLE_TIME ?></ b></td>

<td class="dataTableContent" colspan="2" valign="top"><?php echo date('H:i:s', (time() - $ut['value']['end_time']+ 28800)); ?></td>

</tr>

<tr>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TABLE_HEADING_END_TIME; ?></b></td>

<td class="dataTableContent" colspan="2" valign="top"><?php echo date('H:i:s', $ut['value']['end_time']); ?></td>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TEXT_TOTAL_TIME ?></b></td>

<td class="dataTableContent" colspan="2" valign="top"><?php echo date('H:i:s', ($ut['value']['end_time'] - $ut['value']['time_entry'] + 28800)); ?></td>

</table>

</td>

</tr>

<tr>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TABLE_HEADING_HOST ?></b></td>

<td class="dataTableContent" valign="top"><?php echo gethostbyaddr($ut['value']['ip_address']); ?></td>

</tr>

<tr>

<td class="dataTableContent" align="right" valign="top"><b><?php echo TEXT_ORIGINATING_URL ?></b></td>

<?php

$ref_name = chunk_split($referer_url,40,"<br>");

?>

<td class="dataTableContent" align="left" valign="top" colspan=3><?php echo '<a href="'.$referer_url.'" target="_new">'. $referer_url .'</a>' ; ?> </td>

</tr>

<tr>

<td class="dataTableContent"></td>

<td class="dataTableContent" colspan=3>

<table border="0" cellspacing="1" cellpadding="2" bgcolor=999999 width=100%>

<?php

// insert here

if ($viewsession == $ut['value']['session_id'] || $viewsession == 'All'){

while (($pu = each($ut['value']['last_page_url']))&&($du = each($ut['value']['page_desc'])))

{

 

?>

<tr bgcolor=ffffff>

<td class="dataTableContent" valign=top align="right"><?php echo date('H:i:s', $pu['key']); ?>:</td>

<td class="dataTableContent" nowrap valign=top align="left"> <a href="<?php echo $pu['value']; ?>" target="_new"><?php if ($du['value']!=''){ echo $du['value'];} ?></a> </td>

<td class="dataTableContent" width=100% align="left"><a href="<?php echo $pu['value']; ?>" target="_new"><?php echo chunk_split($pu['value'],40,"<br>"); ?></a></td>

</tr>

<?php

}

}

echo' </table>

</td>

</tr> ';

}

?>

<tr>

<td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, tep_db_num_rows($whos_online_query)); echo " Total number of customers: " . $num_sessions . "."; ?></td>

</tr>

</table></td>

</tr>

</table>

</td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Here is the how to install file after I added my problem areas:

 

OSC Commerce 2.2

User Tracking with Admin Area Modification v.1.30

 

modified by Robert Hellemans,

[email protected]

March 2003

added admin area for this mod ++ :)

 

 

Original written by Andrew Edmond

[email protected]

September, 2002

 

 

== start ===========================

 

import the included file:

User Tracking with Admin Area.sql

in your MySQL database with your favorite programm (phpMyAdmin or whatever you use)

 

===end==============================

 

== start ===========================

 

upload file admin/user_tracking.php

upload file admin/user_tracking_config.php

upload file admin/includes/boxes/user_tracking.php

upload file admin/includes/languages/english/user_tracking.php and all other languages if needed...

upload file admin/includes/languages/english/user_tracking_config.php and all other languages if needed...

 

upload file to catalog/includes/functions/user_tracking.php

 

===end==============================

 

 

== start ===========================

add to admin/includes/application_top.php

 

define('FILENAME_USER_TRACKING', 'user_tracking.php');

define('FILENAME_USER_TRACKING_CONFIG', 'user_tracking_config.php');

define('TABLE_USER_TRACKING', 'user_tracking');

 

== end ===========================

 

== start ===========================

ADD TO admin/includes/languages/english.php and all other languages if needed...

 

define('BOX_USER_TRACKING', 'User Tracking');

 

in includes/application_top.php or languages/english.php you can add

define('TEXT_USERTRACK_CONFIG','User Track Config');

 

== end ===========================

 

== start ===========================

add to catalog/includes/application_top.php

 

define('TABLE_USER_TRACKING', 'user_tracking');

 

find in same file:

 

tep_session_start();

 

add after:

// user_tracking modifications

if (!$referer_url) {

$referer_url = $HTTP_SERVER_VARS['HTTP_REFERER'];

if ($referer_url) {

tep_session_register('referer_url');

}

}

 

== end ===========================

This last bit allows us to track the originating URL (where the user came to your site from).

 

 

== start ===========================

Add to catalog/includes/footer.php (at the bottom):

 

<?php

require(DIR_WS_FUNCTIONS . 'user_tracking.php');

if ( CONFIG_USER_TRACKING == 'true') { tep_update_user_tracking(); }

?>

 

== end =============================

 

== start ===========================

 

in your admin/includes/column_left.php file add

 

require(DIR_WS_BOXES . 'user_tracking.php');

====================================

 

This makes it so that each time the user loads the page that the user tracking function

will operate. Rather than including in application_top, we're calling it from the footer so that

we can pass some definitions from the language file (which is called AFTER application_top).

 

I hope you get it working. I have added the new security code to my stores so the application_top.php doesn't look the same.

Link to comment
Share on other sites

>>>Everybody happy ?

 

Gosh i didnt know it was THAT hard to make it so that everyone can implement it without any error

>>>

 

Yes you gotta be very detailed for girls...especially me! :wink:

 

>>>in about 1 hour from now i will upload version 1.32

 

Thank you so much for all your hard work!

Link to comment
Share on other sites

@ modom

 

!!!!!! STRIKE !!!!!! that one did the job on the fly :roll:

 

@druide

 

this is really spectacular! thnx ever so much! :D

 

i gotto go & get some sleep folks,

 

cu

... in the end, it will work

Link to comment
Share on other sites

:o

 

i just installed the last revision

 

:lol: :lol:

 

at first it threw me because i forgot you put in the option to display the tracked pages instead of displaying them by default - nice touch! saves time - thats always appreciated.....

Link to comment
Share on other sites

ok, what did I miss?

 

I get the following

 

The requested URL /~xxxx/xxxxx/xxxxxx/USER_TRACKING_WHOIS_URL192.168.1.2 was not found on this server.

 

when clicking on the Who Is link :cry:

Link to comment
Share on other sites

Just installed it. Had to change a couple small things....

 

in your install file, you say to copy and paste the code provided. This works....but for the footer.php pages (in both catalog and admin) you have to remove the '}' from your code....

 

Also, I had to go into user_tracking.php page and uncomment the query you had commented out, and I had to comment out the following line.

 

All works great now though.

 

Thanks for the mod.

 

-Chris

Chris Sullivan

Link to comment
Share on other sites

Just installed it. Had to change a couple small things....

 

in your install file, you say to copy and paste the code provided. This works....but for the footer.php pages (in both catalog and admin) you have to remove the '}' from your code....

 

Also, I had to go into user_tracking.php page and uncomment the query you had commented out, and I had to comment out the following line.

 

All works great now though.

 

Thanks for the mod.

 

-Chris

 

copy/paste is still dangerous for programmers, even after YEARS of experience

 

I've updated the install file, thanks for your reply

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

ok, what did I miss?

 

I get the following

 

The requested URL /~xxxx/xxxxx/xxxxxx/USER_TRACKING_WHOIS_URL192.168.1.2 was not found on this server.

 

when clicking on the Who Is link :cry:

 

very weird

 

what kinda OS, browser do you use & serverinfo like unix, linux etc...

 

this code is correct if you ask me, works at my host

 

       <tr> 

       <td class="dataTableContent" align="right" valign="top"><b><?php echo TABLE_HEADING_IP_ADDRESS ?></b></td> 

       <td class="dataTableContent" valign="top"><?php echo $ut['value']['ip_address']; ?> <a href="<?php echo USER_TRACKING_WHOIS_URL . $ut['value']['ip_address']; ?>" target="_new" title="<?php echo TEXT_TITLE_WHOIS; ?>"><?php echo TEXT_WHOIS; ?></a></td> 

       <td class="dataTableContent" colspan=2 rowspan=2 align="center">

      </tr>

 

you know where to find it by now...lol

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

did you inserted this in you database (new line) ?

 

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'User Tracking (your favorite WHOIS URL)', 'USER_TRACKING_WHOIS_URL', 'http://www.dnsstuff.com/tools/whois.ch?ip=', 'Put here you favorite WHOIS tracking site<br>(the IP will follow automaticly after this url)', 999, 50, '2003-03-03 11:19:13', '2003-03-11 11:40:01', NULL, NULL);

 

that also make a lot of difference :)

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

everything 100% now (i hope)

 

my dog is jumping back and forth to go outside....lol

 

let me know if something is not clear

 

We need to make a TODO list:

write new ideas in this forum under devolopment area

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

Hi Robert,

 

I just installed your contribution again and IT IS WORKING!

:P

Gosh, thanks so much!

 

I do have one little, tiny question though... :)

 

What is the whois url link for exactly?

 

I see it will look up the dns numbers. I don't think I want my customers to see where I'm getting my server so can this be disconnected?

 

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...