Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Who's Online Enhancement 1.4


Guest

Recommended Posts

Link to comment
Share on other sites

I've just spotted something. From reading post #443, it seems we should just got away and forget about it and when we come back in the morning magically it will start to work!

David,

 

It's not quite magic. For some of the problems people face with WOE, even after they fix the problem, it still appears broken until all of the old sessions are gone and you have new data to work with. Sessions stick around for at least 15 minutes after the last click. A bot can intermittantly click on links for hours. So, it may take until the next day for the old sessions to disappear.

 

ed

Link to comment
Share on other sites

Woah, ok.  I turned off force cookie usage because of a seperate problem that I'm having with my SSL (with ssl and force cookie usage on it sends me to the cookie usage page) and now it shows my user agent.  I haven't seen it with a bot on the site yet, but i assume that if it shows MY user agent, it will show the user agent of the bot.  How can we fix this so we can have force cookie usage on AND have the user agent work?

Jason,

 

The reason I asked about Force Cookie Usage is because of some code I was looking at in applications_top.php. Specifically starting around line 164:

// start the session
 $session_started = false;
 if (SESSION_FORCE_COOKIE_USE == 'True') {
   tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

   if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
     tep_session_start();
     $session_started = true;
   }
 } elseif (SESSION_BLOCK_SPIDERS == 'True') {
   $user_agent = strtolower(getenv('HTTP_USER_AGENT'));
   $spider_flag = false;

   if (tep_not_null($user_agent)) {
     $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

     for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
       if (tep_not_null($spiders[$i])) {
         if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
           $spider_flag = true;
           break;
         }
       }
     }
   }

   if ($spider_flag == false) {
     tep_session_start();
     $session_started = true;
   }
 } else {
   tep_session_start();
   $session_started = true;
 }

 

Essentially, the code is trusting that Bots don't allow cookies. If you are forcing cookies, you don't care if Prevent Spider Sessions are turned on because the spiders won't accept the cookie so won't get a session. If you aren't worried about a Bot, you don't need to get the user agent for Bot detection or set the spider flag. Nice logic.

 

Except WOE relies on the user agent and the spider flag for part of its logic. So, with Force Cookie Use turned on, the spider code for Prevent Spider Sessions isn't executed and WOE is missing some important info.

 

If someone has a better understanding, feel free to chime in ;)

 

I might suggest trying this this. Turn line 173:

  } elseif (SESSION_BLOCK_SPIDERS == 'True') {

into 2 lines:

  } 
if (SESSION_BLOCK_SPIDERS == 'True') {

That is, after your SSL issue is over and you can turn Force Cookie Usage back on. It should then check for the user agent and set the spider session whether you are forcing cookies or not.

 

No guarentees on the tweak above and back up your code first! :D

 

ed

Link to comment
Share on other sites

OK I have been working on this contribution and you are more than welcome to include my contribution. Basically I have changed the LAST URL column so that it displays useful information about there on the site the user is.

 

Now I can see what category or product they are looking at etc... quite useful.

 

OK here is the code to show the product they are looking at.

 

STEP ONE

 

REPLACE:

 ? ? ? ? ? ? ? ? ? ?<font color="<?php echo $fg_color; ?>">
? ? ? ? ? ? ? ? ? ? ?<?php 
? ? ? ? ? ? ? ? ? ? ? ?echo $temp_url_link;
? ? ? ? ? ? ? ? ? ? ??>
? ? ? ? ? ? ? ? ? ?</font>

 

WITH:

 ? ? ? ? ? ? ? ? ? ?<font color="<?php echo $fg_color; ?>">
? ? ? ? ? ? ? ? ? ? ?<?php 
? ? ? ? ? ? ? ? ? ? ? ?echo $display_link;
? ? ? ? ? ? ? ? ? ? ??>
? ? ? ? ? ? ? ? ? ?</font>

 

 

 

STEP TWO:

After this block of code:

// WOL 1.6 - Removes osCid from the Last Click URL and the link
? ? ? ? ? ? ? ?if ( $osCsid_position = strpos($temp_url_display, "osCsid") )
? ? ? ? ? ? ? ? ?$temp_url_display = substr_replace($temp_url_display, "", $osCsid_position - 1 );
? ? ? ? ? ? ? ?if ( $osCsid_position = strpos($temp_url_link, "osCsid") )
? ? ? ? ? ? ? ? ?$temp_url_link = substr_replace($temp_url_link, "", $osCsid_position - 1 );

 

INSERT:

if (strpos($temp_url_link,'product_info.php')) {
$temp=str_replace('product_info.php','',$temp_url_link);
$temp=str_replace('/?','',$temp);
$temp=str_replace('?','',$temp);
$parameters=split("&",$temp);

$i=0;
while($i < count($parameters)) {
 $a=split("=",$parameters[$i]);
 if ($a[0]="products_id") { $products_id=$a[1]; }
 $i++;
}
$product_query=tep_db_query("select products_name from products_description where products_id='" . $products_id . "' and language_id=1");
$product = tep_db_fetch_array($product_query);                           

$display_link = $product['products_name'].' <I>(Product)</I>';
}elseif (strpos($temp_url_link,'?cPath=')) {
$temp=str_replace('index.php?','',$temp_url_link);
$temp=str_replace('?','',$temp);
$parameters=split("&",$temp);
$parameters=split("/",$temp);

$i=0;
while($i < count($parameters)) {
 $a=split("=",$parameters[$i]);
 if ($a[0]="cPath") { $cat=$a[1]; }
 $i++;
}


$parameters=split("_",$cat);

//$cat_list='';
$i=0;
while($i < count($parameters)) {
 $category_query=tep_db_query("select categories_name from categories_description where categories_id='" . $parameters[$i] . "' and language_id=1");
 $category = tep_db_fetch_array($category_query);                           
 if ($i>0) { $cat_list.=' / '.$category['categories_name']; } else { $cat_list=$category['categories_name']; }

 $i++;
}
$display_link = $cat_list.' <I>(Category)</I>';
} else {
$display_link = $temp_url_display;
}

 

 

 

 

OK look this can probably coded in a MUCH better way so if anyone can fine tune that then let me know so I can update my code. I have also added other sections but with that block you should be able to work out how to do other pages etc...

Edited by ModYourCar

Dan

Link to comment
Share on other sites

So mine looks something like this:

 

 

Dan I have added your mod and it's a great idea and one I and many others have wanted and has been asked about.

 

However there must be something missing with the code you have supplied.

 

On mine I have pretty much nothing showing the way yours does in the above picture.

 

EG: I now get this sort of info displaying

/shop/specials.php

(products)

/shop/index.php/cPath/50

/shop/product_reviews.php/products_id/573

 

Thats better than before but still not very usefull yet.

Can you have another look at things please.

 

John

Link to comment
Share on other sites

Sorry... try this code:

 

                if (strpos($temp_url_link,'product_info.php')) {
              	 $temp=str_replace('product_info.php','',$temp_url_link);
              	 $temp=str_replace('/?','',$temp);
              	 $temp=str_replace('?','',$temp);
              	 $parameters=split("&",$temp);
              	 
              	 $i=0;
  	 while($i < count($parameters)) {
      	 $a=split("=",$parameters[$i]);
      	 if ($a[0]="products_id") { $products_id=$a[1]; }
      	 $i++;
       }
    	 $product_query=tep_db_query("select products_name from products_description where products_id='" . $products_id . "' and language_id=1");
    	 $product = tep_db_fetch_array($product_query);                           
              	 
              	 $display_link = $product['products_name'].' <I>(Product)</I>';
               }elseif (strpos($temp_url_link,'?cPath=')) {
              	 $temp=str_replace('index.php?','',$temp_url_link);
              	 $temp=str_replace('?','',$temp);
              	 $temp=str_replace('/','',$temp);
              	 $parameters=split("&",$temp);

              	 $i=0;
  	 while($i < count($parameters)) {
      	 $a=split("=",$parameters[$i]);
      	 if ($a[0]=="cPath") { $cat=$a[1]; }
      	 $i++;
       }
       
              	 $parameters=split("_",$cat);

  	 //$cat_list='';
              	 $i=0;
  	 while($i < count($parameters)) {
     $category_query=tep_db_query("select categories_name from categories_description where categories_id='" . $parameters[$i] . "' and language_id=1");
       $category = tep_db_fetch_array($category_query);                           
     if ($i>0) { $cat_list.=' / '.$category['categories_name']; } else { $cat_list=$category['categories_name']; }

      	 $i++;
       }
              	 $display_link = $cat_list.' <I>(Category)</I>';
               } else {
              	 $display_link = $temp_url_display;
               }

Dan

Link to comment
Share on other sites

Also I just noticed your shop is within the /shop/ directory whereas mine sits in the root dir. You might need to strip that out using lines like:

 

$temp=str_replace('shop/','',$temp);

 

Get me?

Dan

Link to comment
Share on other sites

Also I just noticed your shop is within the /shop/ directory whereas mine sits in the root dir. You might need to strip that out using lines like:

 

$temp=str_replace('shop/','',$temp);

 

Get me?

 

Dan

Tried the new code, No change.

 

Added the extra bit as above, still now change but also I could not seem to get/see any difference in adding it. I tried a couple of variations and two I correct positions but no difference.

 

Any other ideas.

 

John

Link to comment
Share on other sites

Well I removed all the sessions and there is nothing there less than 8 hours old but still the new fields I set up in the database are not being populated.

Any other ideas as to what it could be? Was I supposed to do anything to get information into those fields or should it just happen?

Link to comment
Share on other sites

Jason,

 

The reason I asked about Force Cookie Usage is because of some code I was looking at in applications_top.php.  Specifically starting around line 164:

// start the session
?$session_started = false;
?if (SESSION_FORCE_COOKIE_USE == 'True') {
? ?tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

? ?if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
? ? ?tep_session_start();
? ? ?$session_started = true;
? ?}
?} elseif (SESSION_BLOCK_SPIDERS == 'True') {
? ?$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
? ?$spider_flag = false;

? ?if (tep_not_null($user_agent)) {
? ? ?$spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

? ? ?for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
? ? ? ?if (tep_not_null($spiders[$i])) {
? ? ? ? ?if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
? ? ? ? ? ?$spider_flag = true;
? ? ? ? ? ?break;
? ? ? ? ?}
? ? ? ?}
? ? ?}
? ?}

? ?if ($spider_flag == false) {
? ? ?tep_session_start();
? ? ?$session_started = true;
? ?}
?} else {
? ?tep_session_start();
? ?$session_started = true;
?}

 

Essentially, the code is trusting that Bots don't allow cookies.  If you are forcing cookies, you don't care if Prevent Spider Sessions are turned on because the spiders won't accept the cookie so won't get a session.  If you aren't worried about a Bot, you don't need to get the user agent for Bot detection or set the spider flag.  Nice logic.

 

Except WOE relies on the user agent and the spider flag for part of its logic.  So, with Force Cookie Use turned on, the spider code for Prevent Spider Sessions isn't executed and WOE is missing some important info.

 

If someone has a better understanding, feel free to chime in  ;)

 

I might suggest trying this this.  Turn line 173:

 ?} elseif (SESSION_BLOCK_SPIDERS == 'True') {

into 2 lines:

 ?} 
if (SESSION_BLOCK_SPIDERS == 'True') {

  That is, after your SSL issue is over and you can turn Force Cookie Usage back on.  It should then check for the user agent and set the spider session whether you are forcing cookies or not.

 

No guarentees on the tweak above and back up your code first!  :D

 

ed

Ok, I modified my code into 2 lines like it says above and I have 'Force Cookie Use' and 'Prevent Spider Sessions' set to True. Now bots are recognized along with 'User Agent' and 'osCid'. The problem is when a spider visits my store it gets a session. So, I guess 'Prevent Spider Sessions' or 'Force Cookie Use' doesn't work properly.

 

Any ideas?

Thanks,

Irina.

Link to comment
Share on other sites

Ok, I modified my code into 2 lines like it says above and I have 'Force Cookie Use' and 'Prevent Spider Sessions' set to True. Now bots are recognized along with 'User Agent' and 'osCid'. The problem is when a spider visits my store it gets a session. So, I guess 'Prevent Spider Sessions' or 'Force Cookie Use' doesn't work properly.

 

Any ideas?

Thanks,

Irina.

Irina,

Can you give us a sample of a spider that is recognized but is still getting a session id? Just cut and paste from the WOE admin screen. Block out IPs/domains/etc.

 

ed

Link to comment
Share on other sites

Irina,

Can you give us a sample of a spider that is recognized but is still getting a session id?? Just cut and paste from the WOE admin screen.? Block out IPs/domains/etc.

 

ed

Here is a fresh bot to start day with:

 

Who's Online

 

Set Refresh Rate: None ? :30 ? 1:00 ? 2:00 ? 3:00? -? Last Refresh: 8/16/2005? 8:48 a.m.

 

Online? ? ? Full Name? ? IP Address? ? ? ? Country? ? ??    Entry Time? ?Last Click?? Last URL? ? ? ? ? ?  Session?? ?? Referer URL?

00:00:08? googlebot? ?66.249.65.104??United States? ?06:50:26? ?06:50:34? ?/osCommerce/cookie_usage.php?? ?Y? ??

 

Name: mozilla/5.0 (compatible; googlebot/2.1; +http://www.google.com/b

 

IP Address: 66.249.65.104

 

User Agent: mozilla/5.0 (compatible; googlebot/2.1; +http://www.google.com/bot.html)

 

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

Currently there are 1 customers online

Duplicate IPs:0

Bots: 1

Me!: 0

Real Customers: 0

 

Your IP Address: 00.00.00.00

Currently there are 1 customers online

Regards,

Irina.

Edited by Irin
Link to comment
Share on other sites

John (Gob),  what does your WHOS ONLINE look like? Can you post your code here I'll have a look.

 

Dan

Is this what you wanted catalog(shop)/admin/who_online.php

This is including your code supplied except the last alteration lines.

<?php
/*
 $Id: whos_online.php,v 1.32 2003/06/29 22:50:52 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

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


/*
 Configuration Values
   Set these to easily personalize your Whos Online
*/

// Seconds that a visitor is considered "active"
 $active_time = 300;
// Seconds before visitor is removed from display
 $track_time = 900;

// Automatic refresh times in seconds and display names
//   Time and Display Text order must match between the arrays
//   "None" is handled separately in the code
 $refresh_time = array(     30,    120,     300,    600 );
 $refresh_display = array( ':30', '2:00', '5:00', '10:00' );

// Images used for status lights
 $status_active_cart = 'icon_status_green.gif';
 $status_inactive_cart = 'icon_status_red.gif';
 $status_active_nocart = 'icon_status_green_light.gif';
 $status_inactive_nocart = 'icon_status_red_light.gif';
 $status_active_bot = 'icon_status_green_border_light.gif';
 $status_inactive_bot = 'icon_status_red_border_light.gif';

// Text color used for table entries
//   Different colored text for different users
//   Named colors and Hex values should work fine here
 $fg_color_bot = 'maroon';
 $fg_color_admin = 'darkblue';
 $fg_color_guest = 'green';
 $fg_color_account = 'blue'; // '#000000'; // Black

/*
 Determines status and cart of visitor and displays appropriate icon.
*/
function tep_check_cart($which, $customer_id, $session_id) {
 global $cart, $status_active_cart, $status_inactive_cart, $status_active_nocart, $status_inactive_nocart, $status_inactive_bot, $status_active_bot, $active_time;

  // Pull Session data from the correct source.
   if (STORE_SESSIONS == 'mysql') {
     $session_data = tep_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $session_id . "'");
     $session_data = tep_db_fetch_array($session_data);
     $session_data = trim($session_data['value']);
   } else {
     if ( (file_exists(tep_session_save_path() . '/sess_' . $session_id)) && (filesize(tep_session_save_path() . '/sess_' . $session_id) > 0) ) {
       $session_data = file(tep_session_save_path() . '/sess_' . $session_id);
       $session_data = trim(implode('', $session_data));
     }
   }

   if ($length = strlen($session_data)) {
     if (PHP_VERSION < 4) {
       $start_id = strpos($session_data, 'customer_id[==]s');
       $start_cart = strpos($session_data, 'cart[==]o');
       $start_currency = strpos($session_data, 'currency[==]s');
       $start_country = strpos($session_data, 'customer_country_id[==]s');
       $start_zone = strpos($session_data, 'customer_zone_id[==]s');
     } else {
       $start_id = strpos($session_data, 'customer_id|s');
       $start_cart = strpos($session_data, 'cart|O');
       $start_currency = strpos($session_data, 'currency|s');
       $start_country = strpos($session_data, 'customer_country_id|s');
       $start_zone = strpos($session_data, 'customer_zone_id|s');
     }

     for ($i=$start_cart; $i<$length; $i++) {
       if ($session_data[$i] == '{') {
         if (isset($tag)) {
           $tag++;
         } else {
           $tag = 1;
         }
       } elseif ($session_data[$i] == '}') {
         $tag--;
       } elseif ( (isset($tag)) && ($tag < 1) ) {
         break;
       }
     }

     $session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));
     $session_data_cart = substr($session_data, $start_cart, $i);
     $session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));
     $session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));
     $session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));

     session_decode($session_data_id);
     session_decode($session_data_currency);
     session_decode($session_data_country);
     session_decode($session_data_zone);
     session_decode($session_data_cart);

     if (PHP_VERSION < 4) {
       $broken_cart = $cart;
       $cart = new shoppingCart;
       $cart->unserialize($broken_cart);
     }

     if (is_object($cart)) {
       $products = $cart->get_products();
   }
 }
 
 $which_query = $session_data;                               
 $who_data =   tep_db_query("select time_entry, time_last_click
                                from " . TABLE_WHOS_ONLINE . "
                                where session_id='" . $session_id . "'");
 $who_query = tep_db_fetch_array($who_data);                           
 
 // Determine if visitor active/inactive
 $xx_mins_ago_long = (time() - $active_time);

 // Determine Bot active/inactive
 if( $customer_id < 0 ) {
   // inactive 
   if ($who_query['time_last_click'] < $xx_mins_ago_long) {
     return tep_image(DIR_WS_IMAGES . $status_inactive_bot, TEXT_STATUS_INACTIVE_BOT);
   // active 
   } else {
     return tep_image(DIR_WS_IMAGES . $status_active_bot, TEXT_STATUS_ACTIVE_BOT);
   }
}	

 // Determine active/inactive and cart/no cart status
 // no cart
 if ( sizeof($products) == 0 ) {
   // inactive 
   if ($who_query['time_last_click'] < $xx_mins_ago_long) {
     return tep_image(DIR_WS_IMAGES . $status_inactive_nocart, TEXT_STATUS_INACTIVE_NOCART);
   // active 
   } else {
     return tep_image(DIR_WS_IMAGES . $status_active_nocart, TEXT_STATUS_ACTIVE_NOCART);
   }
 // cart
} else { 
   // inactive
   if ($who_query['time_last_click'] < $xx_mins_ago_long) {
     return tep_image(DIR_WS_IMAGES . $status_inactive_cart, TEXT_STATUS_INACTIVE_CART);
   // active
   } else {
     return tep_image(DIR_WS_IMAGES . $status_active_cart, TEXT_STATUS_ACTIVE_CART);
   }
 }
}
// WOL 1.5 EOF

/* Display the details about a visitor */
function display_details() {
  global $whos_online, $is_bot, $is_admin, $is_guest, $is_account;
 
// Display Name
  echo '<b>' . TABLE_HEADING_FULL_NAME . ':</b> ' . $whos_online['full_name'];
  echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
 // Display Customer ID for non-bots
  if ( !$is_bot ){
     echo '<b>' . TABLE_HEADING_CUSTOMER_ID . ':</b> ' . $whos_online['customer_id'];
     echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
  } 
// Display IP Address
  echo '<b>' . TABLE_HEADING_IP_ADDRESS . ':</b> ' . $whos_online['ip_address'];
  echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
// Display User Agent
  echo '<b>' . TEXT_USER_AGENT . ':</b> ' . $whos_online['user_agent'];
  echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
// Display Session ID.  Bots with no Session ID, have it set to their IP address.  Don't display these.
  if ( $whos_online['session_id'] != $whos_online['ip_address'] ) {
     echo '<b>' . TEXT_OSCID . ':</b> ' . $whos_online['session_id'];
     echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
  }
// Display Referer if available
  if($whos_online['http_referer'] != "" ) {
     echo '<b>' . TABLE_HEADING_HTTP_REFERER . ':</b> ' . $whos_online['http_referer']; 
     echo '<br clear="all">' . tep_draw_separator('pixel_trans.gif', '10', '4') . '<br clear="all">';
  }
}


 // Time to remove old entries
 $xx_mins_ago = (time() - $track_time);

// remove entries that have expired
 tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
?>
<!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; ?>">

<!-- WOL 1.6 - Cleaned up refresh -->
<?php if( $_SERVER["QUERY_STRING"] > 0 ){  ?>
 <meta http-equiv="refresh" content="<?php echo $_SERVER["QUERY_STRING"];?>;URL=whos_online.php?<?php echo $_SERVER["QUERY_STRING"];?>">
<?php } ?>
<!-- WOL 1.6 EOF -->

<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<!--CSS DROP DOWN SCRIPT-->
<script type="text/javascript">
function shownavtable(elmnt)
{
document.getElementById(elmnt).style.visibility="visible"
}
function hidenavtable(elmnt)
{
document.getElementById(elmnt).style.visibility="hidden"
}
</script>
<!--CSS DROP DOWN SCRIPT-->
<script language="javascript" src="includes/general.js"></script>
</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>
<!-- 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 valign="bottom" class="pageHeading">
           <?php echo HEADING_TITLE; ?>
           <br clear="all"><br><span class="smallText" style="color:#909090"><? echo TEXT_SET_REFRESH_RATE; ?>:</span>
           <span class="dataTableContent" style="font-size: 10px; color:#000000">
           <!-- For loop displays refresh time links -->
           <?php
             echo '<a class="menuBoxContentLink" href="whos_online.php"><b>None</b></a>';
             foreach ($refresh_time as $key => $value) {
               echo ' ? <a class="menuBoxContentLink" href="whos_online.php?' . $value . '"><b>' . $refresh_display[$key] . '</b></a>';
             }
           ?>
           
           <!-- Display Profile links -->
           <br clear="all">
           <span class="smallText" style="color:#909090"><?php echo TEXT_PROFILE_DISPLAY; ?>:</span>
           <a href="whos_online.php" class="menuBoxContentLink"><b><?php echo TEXT_NONE_; ?></b></a> ? 
           <a href="whos_online.php?showAll" class="menuBoxContentLink"><b><? echo TEXT_ALL; ?></b></a> ? 
           <a href="whos_online.php?showBots" class="menuBoxContentLink"><b><? echo TEXT_BOTS; ?></b></a> ? 
           <a href="whos_online.php?showCust" class="menuBoxContentLink"><b><? echo TEXT_CUSTOMERS; ?></b></a>
           </span>
           </td>
           <!-- Status Legend - Uses variables for image names -->
           <td align="right" class="smallText" valign="bottom">
             <table border="0" cellspacing="0" cellpadding="0">
             <tr>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_active_cart, TEXT_STATUS_ACTIVE_CART) . ' ' . TEXT_STATUS_ACTIVE_CART . '  ';
             ?></td>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_inactive_cart, TEXT_STATUS_INACTIVE_CART) . ' ' . TEXT_STATUS_INACTIVE_CART . '  ';
             ?></td>
             </tr>
             <tr>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_active_nocart, TEXT_STATUS_ACTIVE_NOCART) . ' ' . TEXT_STATUS_ACTIVE_NOCART   .'  ';
             ?></td>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_inactive_nocart, TEXT_STATUS_INACTIVE_NOCART) . ' ' . TEXT_STATUS_INACTIVE_NOCART   . '  ';
             ?></td>
             </tr>
             <tr>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_active_bot, TEXT_STATUS_ACTIVE_BOT) . ' ' . TEXT_STATUS_ACTIVE_BOT . '  ';
             ?></td>
               <td class="smallText"><?php echo
                 tep_image(DIR_WS_IMAGES . $status_inactive_bot, TEXT_STATUS_INACTIVE_BOT) . ' ' . TEXT_STATUS_INACTIVE_BOT . '  ';
            ?></td>
            </tr>
            </table>
          </td>
        </tr>
       </table></td>
     </tr>
        <tr>
          <td class="pageHeading" align="center"><script language="JavaScript">
<!-- Begin
Stamp = new Date();
document.write('<font size="2" face="Arial" color="blue">Last Refresh: ' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getYear() + '  ');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " p.m.";
}
else {
Time = " a.m.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}	
document.write('  ' + Hours + ":" + Mins + Time + '</font>');
// End -->
</script>           
</td>
        </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr bgcolor="#8A9DB1" style="background: url(../images/infobox/header_footer_background.jpg)">
               <td class="dataTableHeadingContent" colspan="2" nowrap align="center"><?php echo TABLE_HEADING_ONLINE; ?></td>
               <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_FULL_NAME; ?></td>
               <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_IP_ADDRESS; ?></td>
               <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_ENTRY_TIME; ?></td>
               <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_LAST_CLICK; ?></td>
               <td class="dataTableHeadingContent" width="200"><?php echo TABLE_HEADING_LAST_PAGE_URL; ?> </td>
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_USER_SESSION; ?> </td>
               <td class="dataTableHeadingContent" align="center" nowrap><?php echo TABLE_HEADING_HTTP_REFERER; ?> </td>
             </tr>

<?php
 // Order by is on Last Click. Also initialize total_bots and total_admin counts 
 $whos_online_query = tep_db_query("select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, http_referer, user_agent, session_id from " . TABLE_WHOS_ONLINE . ' order by time_last_click DESC');
 $total_bots=0;
 $total_admin=0;
 $total_guests=0;
 $total_loggedon=0;

 while ($whos_online = tep_db_fetch_array($whos_online_query)) {

   $time_online = ($whos_online['time_last_click'] - $whos_online['time_entry']);
   if ((!isset($HTTP_GET_VARS['info']) || (isset($HTTP_GET_VARS['info']) && ($HTTP_GET_VARS['info'] == $whos_online['session_id']))) && !isset($info)) {
     $info = $whos_online['session_id'];
   }

/* BEGIN COUNT MOD */
   if ($old_array['ip_address'] == $whos_online['ip_address']) {
     $i++;
   }
/* END COUNT MOD */

   if ($whos_online['session_id'] == $info) {
      if($whos_online['http_referer'] != "")
      {
       $http_referer_url = $whos_online['http_referer'];
      }
     echo '<tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
   } else {
     echo '<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_WHOS_ONLINE, tep_get_all_get_params(array('info', 'action')) . 'info=' . $whos_online['session_id'], 'NONSSL') . '\'">' . "\n";
   }

  // Display Status
  //   Check who it is and set values
   $is_bot = $is_admin = $is_guest = $is_account = false;
   // Bot detection
   if ($whos_online['customer_id'] < 0) {
     $total_bots++;
     $fg_color = $fg_color_bot;
     $is_bot = true;
     // Admin detection
   } elseif ($whos_online['ip_address'] == tep_get_ip_address() ) { //$_SERVER["REMOTE_ADDR"]) {
     $total_admin++;
     $fg_color = $fg_color_admin;
     $is_admin = true;
   // Guest detection (may include Bots not detected by Prevent Spider Sessions/spiders.txt)
   } elseif ($whos_online['customer_id'] == 0) {
     $fg_color = $fg_color_guest;
     $is_guest = true;
     $total_guests++;
   // Everyone else (should only be account holders)
   } else {
     $fg_color = $fg_color_account;
     $is_account = true;
     $total_loggedon++;
   }
?>
               <!-- Status Light Column -->
               <td class="dataTableContent" align="left" valign="top">
                 <?php echo ' ' . tep_check_cart($whos_online['session_id'], $whos_online['customer_id'], $whos_online['session_id']); ?>
               </td>

               <!-- Time Online Column -->
               <td class="dataTableContent" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php echo gmdate('H:i:s', $time_online); ?>
               </font> </td>

               <!-- Name Column -->
               <td class="dataTableContent" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php
                 // WOL 1.6 Restructured to Check for Guest or Admin
                 if ( $is_guest || $is_admin ) 
                 { 
                   echo $whos_online['full_name'] . ' ';
                 // Check for Bot
                 } elseif ( $is_bot ) { 
                   // Tokenize UserAgent and try to find Bots name
                   $tok = strtok($whos_online['full_name']," ();/");
                   while ($tok) {
                     if ( strlen($tok) > 3 )
                       if ( !strstr($tok, "mozilla") && 
                            !strstr($tok, "compatible") &&
                            !strstr($tok, "msie") &&
                            !strstr($tok, "windows") 
                          ) {
                         echo "$tok";
                         break;
                       }
                     $tok = strtok(" ();/");
                   }
                 // Check for Account
                 } elseif ( $is_account ) {
//                    echo '<a HREF="customers.php?selected_box=customers&cID=' . $whos_online['customer_id'] . '&action=edit">' . $whos_online['full_name'] . '</a>';
     ?>
                 <a HREF="<?php ('customers.php?selected_box=customers&cID=' . $whos_online['customer_id'] . '&action=edit"');?>">
<font color="<?php echo $fg_color; ?>">
                 <?php 
     echo $whos_online['full_name'];
     
     ?>
     </font></a>
     <?php
                 } else {
                   echo TEXT_ERROR;
                 }
                 ?>
               </font> </td>   

               <!-- IP Address Column -->
               <td class="dataTableContent" valign="top">
                 <?php
                 // Show 'Admin' instead of IP for Admin
                 if ( $is_admin ) 
                   echo TEXT_ADMIN;
                   else {
                   // Show IP with link to IP checker
//                    echo '<a HREF="http://www.showmyip.com/?ip=' . $whos_online['ip_address'] . '" target="_blank">
  	 ?>
                   <a HREF="<?php echo ('http://www.showmyip.com/?ip=' . $whos_online['ip_address']);?>" target="_blank">
<font color="<?php echo $fg_color; ?>">
   <?php
   echo $whos_online['ip_address'];
   }
   ?>
   </font></a>
                 
                </td>

               <!-- Time Entry Column -->
               <td class="dataTableContent" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php echo date('H:i:s', $whos_online['time_entry']); ?>
               </font></td>

               <!-- Last Click Column -->
               <td class="dataTableContent" align="center" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php echo date('H:i:s', $whos_online['time_last_click']); ?>
               </font> </td>

               <!-- Last URL Column -->
               <td class="dataTableContent" valign="top">
               <?php 
               $temp_url_link = $whos_online['last_page_url'];
               if (eregi('^(.*)' . tep_session_name() . '=[a-f,0-9]+[&]*(.*)', $whos_online['last_page_url'], $array)) {
                 $temp_url_display =  $array[1] . $array[2];
               } else {
                 $temp_url_display = $whos_online['last_page_url'];
               }
               // WOL 1.6 - Removes osCid from the Last Click URL and the link
               if ( $osCsid_position = strpos($temp_url_display, "osCsid") )
                 $temp_url_display = substr_replace($temp_url_display, "", $osCsid_position - 1 );
               if ( $osCsid_position = strpos($temp_url_link, "osCsid") )
                 $temp_url_link = substr_replace($temp_url_link, "", $osCsid_position - 1 );
              if (strpos($temp_url_link,'product_info.php')) {
               $temp=str_replace('product_info.php','',$temp_url_link);
               $temp=str_replace('/?','',$temp);
               $temp=str_replace('?','',$temp);
               $parameters=split("&",$temp);
               
               $i=0;
   while($i < count($parameters)) {
       $a=split("=",$parameters[$i]);
       if ($a[0]="products_id") { $products_id=$a[1]; }
       $i++;
      }
     $product_query=tep_db_query("select products_name from products_description where products_id='" . $products_id . "' and language_id=1");
     $product = tep_db_fetch_array($product_query);                           
               
               $display_link = $product['products_name'].' <I>(Product)</I>';
              }elseif (strpos($temp_url_link,'?cPath=')) {
               $temp=str_replace('index.php?','',$temp_url_link);
               $temp=str_replace('?','',$temp);
               $temp=str_replace('/','',$temp);
               $parameters=split("&",$temp);

               $i=0;
   while($i < count($parameters)) {
       $a=split("=",$parameters[$i]);
       if ($a[0]=="cPath") { $cat=$a[1]; }
       $i++;
      }
      
               $parameters=split("_",$cat);

   //$cat_list='';
               $i=0;
   while($i < count($parameters)) {
    $category_query=tep_db_query("select categories_name from categories_description where categories_id='" . $parameters[$i] . "' and language_id=1");
      $category = tep_db_fetch_array($category_query);                           
    if ($i>0) { $cat_list.=' / '.$category['categories_name']; } else { $cat_list=$category['categories_name']; }

       $i++;
      }
               $display_link = $cat_list.' <I>(Category)</I>';
              } else {
               $display_link = $temp_url_display;
              }
?>
                 <a HREF="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . $temp_url_link; ?>" target=\"_blank\">
                   <font color="<?php echo $fg_color; ?>">
                     <?php 
//                        echo $temp_url_display;
                      echo $display_link;
                     ?>
                   </font>
                 </a>
               </td>

               <!-- osCsid? Column -->
               <td class="dataTableContent" align="center" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php
                 if($whos_online['session_id'] != $whos_online['ip_address']) {
                     echo TEXT_IN_SESSION;
                 } else {
                     echo TEXT_NO_SESSION;
                 }
                 ?>
               </font></td>

               <!-- Referer? Column -->
               <td class="dataTableContent" align="center" valign="top"><font color="<?php echo $fg_color; ?>">
                 <?php
                 if($whos_online['http_referer'] == "") {
                     echo TEXT_HTTP_REFERER_NOT_FOUND;
                 } else {
                     echo TEXT_HTTP_REFERER_FOUND;
                 }
                 ?>
               </font></td>
             </tr>

             <tr class="dataTableRow">
               <td class="dataTableContent" colspan="3"></td>
               <td class="dataTableContent" colspan="6"><font color="<?php echo $fg_color; ?>">
               <?php 
       // Display Details for All
               if ( $_SERVER["QUERY_STRING"] == showAll ) {
         display_details();
       }
       // Display Details for Bots
       else if( $_SERVER["QUERY_STRING"] == showBots ){
         if ( $is_bot ) {
          display_details();
      	 }
       }	
       // Display Details for Customers
       else if( $_SERVER["QUERY_STRING"] == showCust ){
         if ( $is_guest || $is_account || $is_admin ) {
          display_details();
      	 }
       }	
     ?>
     </font></td>
     </tr>

<?php
$old_array = $whos_online;
 }

 if (!$i) {
	 $i=0;
 }
 $total_dupes = $i;
 $total_sess = tep_db_num_rows($whos_online_query);
 // WOL 1.4 - Subtract Bots and Me from Real Customers.  Only subtract me once as Dupes will remove others
 $total_cust = $total_sess - $total_dupes - $total_bots - ($total_admin > 1? 1 : $total_admin);
 // WOL 1.4 eof
?>
<?php
 if(isset($http_referer_url))
 {
?>
 <tr>
<td class="smallText" colspan="9"><?php echo '<strong>' . TEXT_HTTP_REFERER_URL . ':</strong> <a href='. $http_referer_url.' target=_blank>' . $http_referer_url.'</a>'; ?></td>
 </tr>
 <?php
 }
?>
             <tr>
<!-- WOL 1.4 - Added Bot and Me counts -->
               <td class="smallText" colspan="9"><br><table border="0" cellpadding="0" cellspacing="0" width="600">
<tr>
 <td class="smallText" align="left" colspan="2">      <?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, $total_sess);?></td>
</tr>
<tr>
 <td class="smallText" align="right" width="30"><?php print "$total_dupes" ?></td>
 <td class="smallText" align="left" width="570">  <?php echo TEXT_DUPLICATE_IP; ?></td>
</tr>
<tr>
 <td class="smallText" align="right" width="30"><?php print "$total_bots" ?></td>
 <td class="smallText" width="570">  <?php echo TEXT_BOTS; ?></td>
</tr>
<tr>
 <td class="smallText" align="right" width="30"><?php print "$total_admin" ?></td>
 <td class="smallText" width="570">  <?php echo TEXT_ME; ?></td>
</tr>
<tr>
 <td class="smallText" align="right" width="30"><?php print "$total_cust" ?></td>
 <td class="smallText" width="570">  <?php echo TEXT_REAL_CUSTOMERS; ?></td>
</tr>
</table><br>
<?php print "<b>" . TEXT_MY_IP_ADDRESS . ":</b> ".tep_get_ip_address(); ?><br><br><b>Note.</b> "N/A". Not Available</td>
<!-- WOL 1.4 eof -->                
             </tr>
           </table></td>

<?php
 $heading = array();
 $contents = array();
 $heading[] = array('text' => '<b>' . TABLE_HEADING_SHOPPING_CART . '</b>');
 if (isset($info)) {
   if (STORE_SESSIONS == 'mysql') {
     $session_data = tep_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $info . "'");
     $session_data = tep_db_fetch_array($session_data);
     $session_data = trim($session_data['value']);
   } else {
     if ( (file_exists(tep_session_save_path() . '/sess_' . $info)) && (filesize(tep_session_save_path() . '/sess_' . $info) > 0) ) {
       $session_data = file(tep_session_save_path() . '/sess_' . $info);
       $session_data = trim(implode('', $session_data));
     }
   }

   if ($length = strlen($session_data)) {
   
     if (PHP_VERSION < 4) {
       $start_id = strpos($session_data, 'customer_id[==]s');
       $start_cart = strpos($session_data, 'cart[==]o');
       $start_currency = strpos($session_data, 'currency[==]s');
       $start_country = strpos($session_data, 'customer_country_id[==]s');
       $start_zone = strpos($session_data, 'customer_zone_id[==]s');
     } else {
       $start_id = strpos($session_data, 'customer_id|s');
       $start_cart = strpos($session_data, 'cart|O');
       $start_currency = strpos($session_data, 'currency|s');
       $start_country = strpos($session_data, 'customer_country_id|s');
       $start_zone = strpos($session_data, 'customer_zone_id|s');
     }

     for ($i=$start_cart; $i<$length; $i++) {
       if ($session_data[$i] == '{') {
         if (isset($tag)) {
           $tag++;
         } else {
           $tag = 1;
         }
       } elseif ($session_data[$i] == '}') {
         $tag--;
       } elseif ( (isset($tag)) && ($tag < 1) ) {
         break;
       }
     }

     $session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));
     $session_data_cart = substr($session_data, $start_cart, $i);
     $session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));
     $session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));
     $session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));

     session_decode($session_data_id);
     session_decode($session_data_currency);
     session_decode($session_data_country);
     session_decode($session_data_zone);
     session_decode($session_data_cart);

     if (PHP_VERSION < 4) {
       $broken_cart = $cart;
       $cart = new shoppingCart;
       $cart->unserialize($broken_cart);
     }

     if (is_object($cart)) {
       $products = $cart->get_products();
       for ($i = 0, $n = sizeof($products); $i < $n; $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' => 'Empty');
     }
   }
 }
}
  // Show shopping cart contents for selected entry
  echo '            <td valign="top">' . "\n";

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

  echo '</td>' . "\n";
?>
         </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'); ?>

Link to comment
Share on other sites

Irina,

 

I see that you've added some code for identifying Country.  Which version of WOE is this based on? v1.6 or v1.7?

 

ed

I just combined 'WOE v1.7' with 'whos_online with country and flag'. This mod analyses the customer's IP address in order to recognize it's country of origin. It adds a country name and country flag to whos_online page.

How does it relate to bots getting a session? :rolleyes:

Do you have any ideas how to prevent spiders from getting a session?

 

Thanks,

Irina.

Link to comment
Share on other sites

Folks,

 

I updated Who's Online Enhancement to v1.4.

 

Post any and all comments, suggestions, questions, complaints here.

 

Ed

 

error: when using the refresh while a customer is in shopping cart

 

Warning: main(includes/languages/logger): failed to open stream: No such file or directory in

\httpdocs\osCommerce\admin\includes\application_top.php on line 133

 

Fatal error: main(): Failed opening required 'includes/languages/logger' (include_path='.;./includes;./pear') in \httpdocs\osCommerce\admin\includes\application_top.php on line 133

Edited by jetski
Link to comment
Share on other sites

I just combined 'WOE v1.7' with 'whos_online with country and flag'. This mod analyses the customer's IP address in order to recognize it's country of origin. It adds a country name and country flag to whos_online page.

How does it relate to bots getting a session?  :rolleyes: 

Do you have any ideas how to prevent spiders from getting a session?

 

Thanks,

Irina.

Irina,

 

Prevent Spider Sessions and a good spiders.txt file takes care of that for you. However, if Bots indexed your page before you had that turned on, then they would have stored session ids in their search engine index. In that case, they would be coming in with old session ids.

 

I asked about the WOE version and the country mod to see if it was possibly an issue from an earlier version.

 

ed

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