Jump to content
Sign in to follow this  
Druide

User Tracking with Admin 1.31 Released

Recommended Posts

straider , could u explain us what u did for the configuration in admin rather than in user tracking config.php ?

any screenshot would be maybe quicker than any explanation ;)


MS2

Share this post


Link to post
Share on other sites

azer,

 

I dunno how to show images on a post. But I can explain it easily.

 

By setting the configuration group of all variables to a new group ID, such as 100, and then inserting this new group ID on configuration_group table, all is left to do is go to Configuration, and see on the bottom part of the list of options all the User Tracking related settings. For those of you that know Browse by Categories, it was done the same way. I prefer this way, because it doesn't clutter my choices on the left column with yet another section, and keeps all setting variables in the same place, where I think it's best: configuration section.

 

User Tracking Config seems to be just another configuration.php, which led me to set the variables on a new group ID. By not needing yet another new file, I keep my osCommerce more easier to maintain, IMHO. I would only use User Tracking Config is was very different from the default configuration.php code, which is not the case. If you don't use a new group ID then all user tracking variables should fall under group ID 1, which is the My Store configuration group. But I don't like it this way because it fills the list of variables to display, and doesn't quite relate to the store configuration.

 

Is this clear, azer?


Contributions:

. Browse by Categories

-----------------------------------------------------------

Jos? Carlos Monteiro - DoWeDo-IT

Share this post


Link to post
Share on other sites

When I click on User Tracking (sessions limit), there is a note to "watch your space." What is this referring to? When I first opened my shop, this value was set to 50. But now, I have to run it at 7 in order to get the page to display. Is there a buffer value that I can change to increase how much can be displayed?

 

Jack

Share this post


Link to post
Share on other sites

straider : yes i understood

 

spaceboys said

1.

I do not display sessions with a clickcount=1. I my case too many people just read the mainpage and go away. I do not count them as "interesting" visitors

 

it s very interisting , as we could even in the admion confoiguration add a number of minimum click to monitor before adding it to to user tracking

could u give us some code ?

 

2.could people tell for the added 28800 or 82800 or removal like did straider , wich one works well for them


MS2

Share this post


Link to post
Share on other sites

No matter what I try, I can't get the total time and idle time to work. I have tried deleting the numbers, adding the numbers, subtracting the numbers.....

 

As an example with no 28800 or 82800 or whatever I get this:

Start Time: 14:08:47

End Time: 14:10:05

 

Idle Time: 12:11:27

Total Time: 10:01:18

Now to me I would think it should show something like this

Start Time: 14:08:47

End Time: 14:10:05

 

Idle Time: 00:00:58

Total Time: 00:01:18

Share this post


Link to post
Share on other sites

Does anyone have a list of pending feature requests or bugs available for User Tracking?

 

In my case, running v1.35, I get these bugs, which I'm trying to fix:

  • Bug #1 - View Session from Previous Dates. When I backtrack to a previous date and then click on view session I get the current date page again, instead of the page for that previous date with the details of the session I've just clicked on.
  • Bug #2 - When I activate User Tracking for admins I get an error stating that a tep function is not available.

In my case, I've added these fixes or features:

  • Fix #1 - The links for back to date and forward to date are now aligned with each other. Before, I had the forward link on top of the page title, then the page title and then the Select View to back date.
  • Fix #2 - The idle time and total time were giving me values I couldn't rely on, because the values 28800 or 82800 were being added to both calculations. Now, it gives me proper idle and total times, as john_t_h expects.
  • Fix #3 - Joe Schlaf fix to use admin/includes/footer.php with DIR_FS_CATALOG.
  • Fix #4 - Matthias Fahrig patch to delete entries without session IDs and delete a specified IP address.

Some features I've collected from this topic and/or I'm interested in collaborating in the development are:

  • Feature #1 - Portuguese translation.
  • Feature #2 - Minimum click count to monitor, by setting database variables.
  • Feature #3 - Use of Group ID for User Tracking variables, replacing the former user_tracking_config.php.
  • Feature #4 - Exclude range of IPs, or multiple IPs. I think this can be done by using a SQL WHERE IN statement, if the Excluded IP has more than one IP or uses wildcards.
  • Feature #5 - Use language dependant GeoIP country list, which could be shared with other contributions such as Visitor Stats.

I expect some of you to add to this list and if possible I'd like to see some of us picking up on these fixes or requests and end up coding what may be User Tracking 1.36. This is a great contribution to osCommerce, and I agree with everyone that have stated this should be added to the official osCommerce releases.

 

Many thanks to all.

Edited by straider

Contributions:

. Browse by Categories

-----------------------------------------------------------

Jos? Carlos Monteiro - DoWeDo-IT

Share this post


Link to post
Share on other sites

my friend straider , on this i can offer my beta testing , but for this contrib , i have to admit my level in php won't help you ...

the 1.35 is getting old and it s good that u release a new one fixing and adding features ..

for the geoip ... it s a good idea that would be profitable to any contibution related to ip ... i m also upgrading whos online with flags with flags , so any improvement in the using of geoip tools would be more than welcome


MS2

Share this post


Link to post
Share on other sites

Here's a fix for the 28800 idle time bug.

 

The problem with the code in v1.35 is that the time calculations are carried out with unix timestamps, which are in GMT. When the date() function is used to display them, they're converted to the local timezone, even though they're relative times. For date('H:i:s') to work, the timestamp has to be relative to midnight.

 

In admin/user_tracking.php, change this block of code, around line 219:

 

  <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>

 

..to this:

 

  <?php

      $today = getdate();

      $midnight = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);

  ?>

    <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', ($midnight + time() - $ut['value']['end_time'])); ?></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', ($midnight + $ut['value']['end_time'] - $ut['value']['time_entry'])); ?></td>

 

Here's a unified diff, for those who know what that is:

 

--- ../User Tracking with Admin 1.35/admin/user_tracking.php    Wed Mar 26 10:31:12 2003

+++ admin/user_tracking.php    Tue Feb 10 22:06:06 2004

@@ -216,16 +216,20 @@

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

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

  <tr>

+      <?php

+              $today = getdate();

+              $midnight = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);

+      ?>

    <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>

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

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

</table>

        </td>

                          </tr>

 

Hope this helps. Apologies if it's already been fixed - a 36 page thread is longer than my patience.

Share this post


Link to post
Share on other sites
Hi

 

i live in the uk

 

when i track my self with this addon is comes up with that i am

from Bulgaria

 

if i go to http://www.dnsstuff.com/ and input my ip it comes back that

i am from uk

 

why does it come up with the Bulgaria flag any clues

are you or your ISP using a proxy ?

that would explain it


Robert

 

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

Share this post


Link to post
Share on other sites

Hi,

Here's a fix for the 28800 idle time bug. 

 

The problem with the code in v1.35 is that the time calculations are carried out with unix timestamps, which are in GMT.  When the date() function is used to display them, they're converted to the local timezone, even though they're relative times.  For date('H:i:s') to work, the timestamp has to be relative to midnight.

 

In admin/user_tracking.php, change this block of code, around line 219:

 

? <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>

 

..to this:

 

?  <?php

? ? ? $today = getdate();

? ? ? $midnight = mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']);

?  ?>

? ? <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', ($midnight + time() - $ut['value']['end_time'])); ?></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', ($midnight + $ut['value']['end_time'] - $ut['value']['time_entry'])); ?></td>

 

 

 

Hope this helps. Apologies if it's already been fixed - a 36 page thread is longer than my patience.

 

First of all i wanted to thank the original author and everybody who did enhancements to this wonderful contribution. I just came across one question:

Could somebody of you please explain to me what 'idle time' exactly means? Even with the fix that zem posted above, i do not get any reasonable results concerning the idle time. To me, idle time means, what time did a visitor spend on the webiste without doing anything (and i have no clue how this figure could be calculated). By adding time() to the calculation like in the fix above, the idle time shown in the admin is (obviously) changing everytime you look at your sessions.

 

That means, either i am misinterpreting the meaning of 'idle time' (then i do not understand what idle time here means) or, if my understanding of idle time is correct, then this fix does not help to show the correct idle time.

 

I hope somebody of you can enlighten me on this subject. Thanks in advance and best regards,

Marcus

Share this post


Link to post
Share on other sites

Hey all,

I need to expand the excluded feature of this contrib. Was wondering if anyone had a bit of code they could share so I could simply place a comma seperated list of IPs in catalog/includes/functions/user_tracking.php to be ignored. There are a growing number of IPs I'd like to start blocking so I dont have to view them. As an example.. google.com!!! I love that I'm hit constantly but I dont wish to see each session it starts here. We still see the access data via our webstats.

 

Actually.. a better solution would be someway to filter the IPs out from even being recorded!

 

Any help would be greatly appreciated!

Thanks,

Rob

Share this post


Link to post
Share on other sites

I saw a post earlier - somebody wanted to know some code for click count.

 

Have a simple one ready to go.

 

SQL

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 (Min Click Count)', 'MIN_CLICK_COUNT', '1', 'Minimum 

click count to display<br>(SET to 0 for all)', 999, 15, '2003-03-03 11:19:13', '2003-02-09 21:20:07', NULL, NULL);

 

Changes to admin/user_tracking.php:

 

Look for (line 140):

 $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'];

 

Change to:

  $listed=0;
 if ($results)
 while (($ut = each($user_tracking)) && ($listed++ < $LIMIT_DISPLAY_SESSIONS)) 
 {

	 if (count($ut['value']['last_page_url']) > MIN_CLICK_COUNT) {

   $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'];

 

Look for (line 272):

 } 
?>

 

Change to:

 } 
}
?>

 

Thats it, admin settings are defaulted to clicks greater than 1.

 

Not pretty, but it works. Did I mention to back up?


9 times out of 10 its a PEBCAK Error (Problem exists between chair and keyboard)

 

Replace that and you're fine...

Share this post


Link to post
Share on other sites

When a visitor looks at my advanced_search page, the title displayed in the User Tracking listing is HEADING_TITLE. This is the only page I've seen this happen on. I can't see any difference between this page and all of my others as far as setup. I have Header Tags installed and the heading works as expected. Does anyone know what might be causing this or how to isolate the cause?

 

Jack

Share this post


Link to post
Share on other sites

Okay, I now have the below problem and I read through all the solutions in this thread but I had already made any corrections and it was working beautifully...until

 

I changed hosting companies so now my paths are changed. I miss this contribution terribly.

 

Fatal error: error traversing database - perhaps it is corrupt? mypath/catalog/admin/includes/geoip.inc on line 220

 

I'v reinstalled the .dat file the .inc file, dropped the database an re-installed the .sql file. I uploaded a fresh copy of all the user_tracking additional files and then went through the files that needed coded added and they are the same as before. I even replaced all the flags files--just in case.

 

What else can I check to see why this isn't working with my new host, any ideas? A permission problem??? Is it my path problem??? It's the same in my config files.

 

Ideas??? TIA

Share this post


Link to post
Share on other sites

Can someone please tell if the option in User Tracking Config which says "User Tracking (your favorite WHOIS URL)" works. In my shop it is not functional and if you look in user_tracking.php, the code for where you click on the ip address in hard coded to http://www.dnsstuff.com/tools/whois.ch?ip=<?. I'm assuming this is a coding mistake but I want to be sure it is not just my installation that has the problem. I see on in this thread that others are using different WHOIS url's. Are you doing this by changing the code?

 

Jack

Share this post


Link to post
Share on other sites

Hello All,

 

Thanks for this great contribution and all efforts to make it better.

I use a contribution SHOP BY PRICE and i can see now that customers use it very frequently.

 

User tracking works great for me.

But I still have a minor problem.

When someone visits my site a unique ID is created. But when some spiders visits my site i can only read "GUEST" without an ID number. When that happens I cannot delete this session and it will remain in my list. I now have to go to my PHPADMIN and delete all entries in TABLE_USER_TRACKING to have a clean page.

 

Is there a fix for this?

 

Also it would be great if this spider sessions where excluded from the listing.

Is it also possible to delete all sessions from admin by just one click?

Edited by Noutje

Share this post


Link to post
Share on other sites
Can someone please tell if the option in User Tracking Config which says "User Tracking (your favorite WHOIS URL)" works. In my shop it is not functional and if you look in user_tracking.php, the code for where you click on the ip address in hard coded to http://www.dnsstuff.com/tools/whois.ch?ip=<?. I'm assuming this is a coding mistake but I want to be sure it is not just my installation that has the problem. I see on in this thread that others are using different WHOIS url's. Are you doing this by changing the code?

 

Jack

Take off that last <? so its like this:

 

http://www.dnsstuff.com/tools/whois.ch?ip=

 

I did notice that someimes they don't accept queries, has anybody else had that problem?

 

Noel


9 times out of 10 its a PEBCAK Error (Problem exists between chair and keyboard)

 

Replace that and you're fine...

Share this post


Link to post
Share on other sites
Take off that last <? so its like this:

 

http://www.dnsstuff.com/tools/whois.ch?ip=

Thanks for the suggestion Noel but I probably didn't make my question clear. It works fine when I click on the url. The problem is that I cannot change the WHOIS service in admin. Or rather, I can change it but the code doesn't recognize the change. It keeps on using http://www.dnsstuff.com/tools/whois.ch?ip=<?.

 

Jack

Share this post


Link to post
Share on other sites

You're right, it is hard coded in there. I might have changed it when I installed it a while back, I don't remember.

 

Look for Line 244 on my version, but I made some mods to it though, I think... 237 on the orig download I had...

<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>

 

*NOTE - You'll probably have an extra <? after the ip= or there isn't a ' somewhere, anyway...

 

Replace with:

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

 

Then it should pull from the database.

 

Like I said, I don't know if mine was hardcoded, and I haven't checked to see if the latest version does.

 

This is a great contrib, should be core.


9 times out of 10 its a PEBCAK Error (Problem exists between chair and keyboard)

 

Replace that and you're fine...

Share this post


Link to post
Share on other sites

I've made a few changes to user_tracking.php which allows you see the customer count message before the tables are displayed and adds a table of the visited links and the number of times each of those links were visited. I found this was one of the main uses I had for user_tracking and it allows me to see at a glance which pages are getting hit the most. If anyone is interested, the code is below.

 

I use the url to control showing the table. The same method is used when you view an older page with the Select View button so my show/hide switch doesn't work properly in this case. You can get around this by setting the defaut view to always show the summary table. There may be another way around this but I couldn't find it.

<?php
/*
 $Id$

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License

 Modified by Robert Hellemans
 Sept 14th, 2002
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 require(DIR_WS_INCLUDES . 'geoip.inc');
 $gi = geoip_open(DIR_WS_INCLUDES . 'GeoIP.dat',GEOIP_STANDARD);

 $LIMIT_DISPLAY_SESSIONS = CONFIG_USER_TRACKING_SESSION_LIMIT; 

//BEGIN SUMMARY CHECK
 if (isset($HTTP_GET_VARS['show'])) {
  $display_mode = 'showit';
  } elseif (isset($HTTP_GET_VARS['hide'])) {
  $display_mode = 'hideit';   
  } else {
  $display_mode = 'showit';
  }
  //END SUMMARY CHECK
?>
<!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 CONFIG_USER_TRACKING_EXCLUDED . ' has been deleted. <p>';
   $delip='0';
 }
 if ($delsession)
 {
   tep_db_query("DELETE FROM " . TABLE_USER_TRACKING . " WHERE session_id = '" . $delsession . "'");
   echo $delsession . ' has been deleted. <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 . '">' . TEXT_BACK_TO . ' ' . date("M d, Y", $time_frame - 86400) . '</a> ';

 echo "<p>" . TEXT_DISPLAY_START . $LIMIT_DISPLAY_SESSIONS . TEXT_DISPLAY_END;
 echo TEXT_PURGE_START . ' <a href="' . FILENAME_USER_TRACKING . '?purge=72">'. TEXT_PURGE_RECORDS. '</a> ' . TEXT_PURGE_END. '</font><p>';

 echo TEXT_DELETE_IP . CONFIG_USER_TRACKING_EXCLUDED . ' <a href="' . FILENAME_USER_TRACKING . '?delip=1">'. TEXT_PURGE_RECORDS. '</a> </font><p>';
 
 if (time() > $time_frame + 86400)
 {
   echo '| <a href="' . FILENAME_USER_TRACKING . '?time=';
   echo $time_frame + 86400 . '">' . TEXT_FORWARD_TO . date("M d, Y", $time_frame + 86400) . '</a>';
 }
 // 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;
$idx = 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'] = '<font color="0000ff"><b>' . $whos_online['full_name'] . '</b></font>';

    $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']; 
  
  //BEGIN SUMMARY  
  if (sizeof($tmp_array) == 0 || false === ($found = array_search($whos_online['page_desc'],$tmp_array))) {    
   $tmp_array[$idx] = $whos_online['page_desc'];
	 $sum_array[$idx][0] = $whos_online['page_desc'];
	 $sum_array[$idx][1]++; 
   $idx++;
  } else {
	 $sum_array[$found][1]++;
  }
  //END SUMMARY  
  
    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 ++;
 }

 foreach ($sum_array as $key => $row) {
  $sumDesc[$key] = $row[0];
  $sumCount[$key] = $row[1];
 }

 array_multisort($sumCount, SORT_DESC, SORT_NUMERIC, $sumDesc, SORT_DESC,SORT_STRING, $sum_array);

?>
	 
<?php   
 //BEGIN SUMMARY 
 $listed=0;    
 if ($results) {
   while ((each($user_tracking)) && ($listed++ < $LIMIT_DISPLAY_SESSIONS)) {
   $topnum_sessions++;
   }
reset($user_tracking);
}
//END SUMMARY
?>   	 

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
   <?php if ($display_mode == showit) { ?>
  <td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, tep_db_num_rows($whos_online_query)); echo " Total number of customers: " . $topnum_sessions . "."; ?> <a href='user_tracking.php?hide=hidesummary'>Hide the summary</a></td>
    <tr>
    <td align="right"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
    </tr>
  
   <table border="1" cellpadding="3">
     <tr>      
      <td class="smallText" align="center" width="80%"><?php echo "URL"; ?></td>
   <td class="smallText" align="center" width="20%"><?php echo "COUNT"; ?></td>     
     </tr>
   
     <?php for($i = 0; $i < count($sum_array); $i++) { ?>
      <tr>
       <td class="smallText" align="center"><?php echo $sum_array[$i][0]; ?></td>
    <td class="smallText" align="center"><?php echo $sum_array[$i][1]; ?></td>  
     </tr>
   <?php } ?>    
   </table>
  <?php  } else { ?>
   <td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, tep_db_num_rows($whos_online_query)); echo " Total number of customers: " . $topnum_sessions . "."; ?> <a href='user_tracking.php?show=showsummary'>Show the summary</a></td>
   <?php } ?>

  <tr>
   <td align="right"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
   </tr>
 </tr>
</table>

  <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 .'</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?delsession=" . $ut['value']['session_id'] . "\"><font color=red>[delete session]</font></a>" . ", <a href=\"user_tracking.php?viewsession=" . $ut['value']['session_id'] . "#" . $ut['value']['session_id'] . "\"><font color=green>[view session]</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>Click Count:</b></td> 
       <td class="dataTableContent" valign="top"><font color=FF0000><b><?php echo count($ut['value']['last_page_url']);?></b></font></td>
       <td class="dataTableContent" colspan=2 rowspan=4 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_COUNTRY ?></b></td> 
       <td class="dataTableContent" valign="top"><?php echo tep_image(DIR_WS_FLAGS . strtolower(geoip_country_code_by_addr($gi, $ut['value']['ip_address'])) . '.gif', geoip_country_name_by_addr($gi, $ut['value']['ip_address'])); ?> <?php echo geoip_country_name_by_addr($gi, $ut['value']['ip_address']); ?></td> 
      </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> 
      </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 
if ($viewsession == $ut['value']['session_id']){ 
 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'); ?>

 

Jack

Share this post


Link to post
Share on other sites

I asked twice about a problem I was having where only part of the page was displayed if I had my session limit set to high. I've finally figured out that the problem had to do with timeouts. I solved the problem by placing this command near the top of the admin->user_tracking.php file:

set_time_limit(180);

Just thought I would post it here in case others are having a similar problem.

 

Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×