Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Whos online not identifying bots? Here's why...


piernas

Recommended Posts

I've wondered why who's online addon did not identify bots other than googlebot and showed as normal users.

I have updated spiders.txt for each bot I find, but none of them showed as bots on this addon.

 

Today, while adapting this addon to recent osc versions, I finally found the problem:

 

If you have SESSION_FORCE_COOKIE_USE set to true oscommerce skips completely the check for spiders and $spider_flag variable is not set at all.

So, if you experience this problem with your configuraton, all you have to do is do the check on the includesfunctions/whos_online.php file:

 

Right below:

  function tep_update_whos_online() {
    global $customer_id, $spider_flag, $user_agent;

add:
 

    is_spider ();

and in the end of the file add the function itself:

  function is_spider () {
  global $user_agent, $spider_flag;

  $spider_flag = false;

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

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

Now the bots will show as boots :) assuming the correct strings are on spiders.txt

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