Jump to content
medvid

Who's Online Enhancement 1.4

Recommended Posts

.? When I get it working nicely, I'll post it as v1.6.?

 

ed

 

Ed,

 

I just wanted to say, Thanks!

 

I downloaded it the minute you posted it (Version 1.5). I'm enjoying my colored lights and appreciate all the hard work you've done on this contribution.

 

Thanks, also, for the font change instructions as I think it will look more pleasing to the eye and more uniform to the admin section. I still have to change mine, so I hope it works for me.

 

Anyway, is it ready yet??? (Just kidding!!!)

 

Thanks again for all your hard work.

Edited by airolg

Share this post


Link to post
Share on other sites

No it's not ready yet :lol:

 

v1.6 will probably be out after the New Year. The 2 things I want in it are a better Bot identification and to have Last URL display the catalog page/product/category name while still being the link it is today. Also, I want to strip out osCid from the link.

 

Bot identification is not as easy as I'd hoped. I'm pulling from the User Agent. For many bots, that would display GoogleBot or MSNBot nicely. For others it displays mozilla2.0 (compatible; blah blah BotName). For yet others ...

 

If anyone has experience with Bot name identification, let me know. I found a real nice Perl script that claims to parse the User Agent for many variations but I'm not a Perl coder. If anyone can help, let me know.

 

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

Hey there,

I had a question about "No Session/Bot" tracking. In the "IP Address" column I've seen the same visitor jump from one type of Bot to another (i.e. "MSNBot" to "GoogleBot"). I can't say I've ever seen two Bots at the same time. What I think is happening is that WOE 1.5 is grouping all Bots into the same user.

 

For example, MSNBot will be online for, say, 00:15:30 and then it'll turn into GoogleBot and keep using the same visitor and then time will keep counting up to, say, 00:52:21. And then it'll go back to MSNBot and keep the counter running.

 

Does anyone else see this? It seems like Bots hardly expire since the next "No Session/Bot" user seems to re-use the current active/inactive "No Session/Bot" user. Anyone else see/think this?

 

Thanks!

BD

Share this post


Link to post
Share on other sites

Sheesh,

I can't see where to edit my post. I also wanted to know if the "Online" column should be updating the amount of time someone has been online upon each reload. I know before I upgraded to WOE 1.5 it used to keep a running count and update all of the times on each reload... but now that I installed WOE 1.5 it only updates the visitors online time after they perform a last click.

 

Did I mess something up that it doesn't update each reload or is everyone having the same experience?

 

Thanks yet again!

BD

Share this post


Link to post
Share on other sites

Hey,

Nothing like talking to one's self :-" . To get a running total of time that someone's been online, I changed this line in WOE 1.5:

 

$time_online = ($whos_online['time_last_click'] - $whos_online['time_entry']);

 

To this (from the default WO):

 

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

 

The first one, just by looking at it, would always give the same time (even upon reload) unless the "last click" changed. Please let me know if this messes anything else up I'm not seeing.

 

See ya,

BD

Share this post


Link to post
Share on other sites

BD,

 

I thought I saw the Bots jump a few times from one to the other but I was never sure. It may have something to do with session id (which is empty for the bots.) I'll look into that for v1.6.

 

As for time online, you're correct. The original whos online calculates time online = current time - last click. I personally didn't like that because if a person clicks once or twice and then leaves the site, time online keeps counting up as if they are still online. It's a matter of personal taste. Your tweak reverses it to the original. I think I forgot to document that change in v1.4. Sorry, but good check.

 

Editing posts is only available for a few minutes, then the button disappears.

 

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites
Hey,

Nothing like talking to one's self :-" . To get a running total of time that someone's been online, I changed this line in WOE 1.5:

 

$time_online = ($whos_online['time_last_click'] - $whos_online['time_entry']);

 

To this (from the default WO):

 

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

 

The first one, just by looking at it, would always give the same time (even upon reload) unless the "last click" changed. Please let me know if this messes anything else up I'm not seeing.

 

See ya,

BD

I haven't looked at the code, but I wonder if making this change will screw up the buttons (in terms of whether someone is active or inactive).

Share this post


Link to post
Share on other sites
I haven't looked at the code, but I wonder if making this change will screw up the buttons (in terms of whether someone is active or inactive).

 

Not that I've seen. "$time_online" is only used to display their time... whereas "time_last_click" is used against "$xx_mins_ago_long" and "$xx_mins_ago" to determine activity/inactivity.

 

See ya,

BD

Share this post


Link to post
Share on other sites
BD,

 

I thought I saw the Bots jump a few times from one to the other but I was never sure.  It may have something to do with session id (which is empty for the bots.)  I'll look into that for v1.6.

 

ed

 

Hmm... maybe add another column to the whos_online table to assign bots a separate id (since they all share the same empty session id) to differentiate between the bots, and truly see how many are crawling site at a time. Maybe "if no session id, assign ip to the new column" and then consider the new column a session id? I don't know.

 

Catch you later,

BD

Share this post


Link to post
Share on other sites

Ed,

 

Is there some code I can add to make change the color of the font of the word "Me!" in the IP address column? I know that when a customer is logged in, their name is in blue. I'd love to have "Me!" stand out so I can see instantly that's it's me hanging out on my site. :D

 

I'm sure it's simple and just a font color change somewhere and if you say it's possible, I'll go fooling around with it and see if I make it work, if it's not possible, oh, well, I can still read that it's me.

 

BTW, I'm loving my lights!!! Thank you so much.

Share this post


Link to post
Share on other sites
Ed,

 

Is there some code I can add to make change the color of the font of the word "Me!" in the IP address column? I know that when a customer is logged in, their name is in blue. I'd love to have "Me!" stand out so I can see instantly that's it's me hanging out on my site.  :D

 

I'm sure it's simple and just a font color change somewhere and if you say it's possible, I'll go fooling around with it and see if I make it work, if it's not possible, oh, well, I can still read that it's me.

 

BTW, I'm loving my lights!!! Thank you so much.

 

airolg,

 

Find:

                      echo '<td class="dataTableContent" align="center">Me!</td>';

and replace with:

                      echo '<td class="dataTableContent" align="center"><font color="green">Me!</font></td>';

or whatever color you want.

 

You're welcome. Credit also goes to Paul, BD, and others who helped with code and suggestions.

 

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites
Hmm... maybe add another column to the whos_online table to assign bots a separate id (since they all share the same empty session id) to differentiate between the bots, and truly see how many are crawling site at a time. Maybe "if no session id, assign ip to the new column" and then consider the new column a session id? I don't know.

 

BD,

 

I did end up using the IP address of the Bot but I didn't create a new column. I assign it to the sessionID column and set customerID = -1. Then, in admin, I check the customerID. If it's < 0, it's a Bot.

 

This only affects the whos_online table. It appears to be working so far. I'm actually hoping for more Bots to come through the site for testing. A few minutes ago, 1 msnbot and 4 googlebots (all with different IP addresses) were on the site.

 

Now I need to clean up how I get the Bot's name from the UserAgent.

 

Thanks for all of the help.

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

Hey there Ed et al,

That's awesome that you've tweaked it! I do, respectfully of course, disagree a bit in re-using the sessionID column for the Bot IP. Here's why: I've built a "profile" kind of thing to display the sessionID of Bots and Customers or both (definable with a new menu at the top). Why? Because I like to verify that no Bots have sessionID's... which would mean my Spider SessionID Killer is working (since it's supposed to stop sessionID's from being created; for search engine purposes):

 

woe15.gif

 

Earlier today, I saw 8 Duplicate IP's with different sessionID's and looked it up... yup, it was a GSpec Bot which I did not have in my my Spider SessionID Killer (though I quickly added the "ocelli" string to the User Agent lookout file [which prevents sessionID's from being created if the visitor's User Agent has the defined string in the file]). As in the above, I can now confirm that my my Spider SessionID Killer is working (since no sessionID is being created) and I can take a look at the Bot IP and User Agent for good measure as well. (As a side note: see how the Last URL of the GSPec Bot has a sessionID? That's because it's visiting a link it got and indexed before I started killing its sessionID's with the "ocelli" string... which I can now verify that it worked).

 

A few tweaks you may note in my personal Who's Online 1.5 version (which I can make available, but I didn't document anything as I hacked it :blush: ):

 

- Profile Display: IP, User Agent (I like seeing the whole string for Spider Killer string purposes), and Stored SessionID

- Bot Colorization

- Streamlined Color Dots: I thought it was too many colors for too few choices

- Visitor: Only names appear, as I thought "Guest" was redundant

- Referrer URL: Only "Y" will appear as I thought the found's were kind of cluttery

- Customer Math: Little bit of formatting at the bottom

 

None of the above would be possible without everyone's (especially Ed's) help. So, I hope we can maybe decide to create a new column to store the Bot IP's (for differentiating between Bots) so that we can use the sessionID as a kind of "verification" that one's osCommerce ID spider killer is working. Let me know what ya think!

 

BD

Share this post


Link to post
Share on other sites

BD,

 

First let me say I like the mods you've done. I think I like your colors better since their simpler. The profile display is excellent work. Streamlining the Y for Referrer and no text for Guest cleans it up nicely.

 

I agree with you that over using a database column is generally a bad idea. It only leads to problems in the future. However, here's my current rationale.

1) I was looking for the least impact to make it an easier contribution (no .sql file)

2) If my logic works (feel free to find the flaw), it doesn't overwrite any data, only blank fields.

 

Point 2 is the one you are concerned about. In my code, I only write the IPAddress in the SessionID column if and only if ("iff" for you math and logic majors B) ) the visitor is already recognized as a Bot. UserID and SessionID are always set to '' if the visitor is a Bot so I'm only overwriting blank fields.

 

In your real life scenario where GSpec wasn't recognized in spiders.txt, my code would leave it as a guest. You would see duplicate IPs with osC style SessionIDs, investigate, and realize it was a Bot not in your spiders.txt.

 

I had noticed a Guest on my site with a rather large cart that had been on the site for a few hours. I looked up the IP and saw it was the eXavaBot.

 

Does that address your concerns about Bot (especially new Bot) detection?

 

Ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

Hey there Ed,

Believe me, there's no flaw in your logic. And I like the fact you're trying to keep things simple (no .sql file). True to your statement, your workaround doesn't overwrite any data, but it does overwrite a blank Bot sessionID field. And for me, I like leaving it blank so that I can verify that my Spider Killers are working properly.

 

If the sessionID for the GSpec Bot in the above image is overwritten by its IP (in order to differentiate between Bots), I'm not able to see (as in the above image) that there is in fact no sessionID being created. See, my Spider Killer (and I think most on the Contributions) relies on User Agent strings... so if GlobalSpec were to change their User Agent without "ocelli" it would fail. The IP I've placed in the Who's Online contribution for GlobalSpec would detect it and define it as such "GSpec Bot" and I could verify that a sessionID was incorrectly created (since their User Agent could have been changed). And this is possible because the Bot sessionID isn't being overwritten by its IP.

 

So for me, because I really want to track and verify all Bots, it's imperative that the sessionID stay blank to prove that they really have no sessionID (whereas overwriting it with their IP would not allow me to check it... unless I go into the database each time).

 

But hey, maybe that's just me being picky by over-tracking the Bots. I think I may have to create a new column in the WO database to write their IP into and have WOE 1.5 check against that for writing different Bots onto the array. Ah well.

 

See ya!

BD

Share this post


Link to post
Share on other sites

BD,

 

I think we are both trying to accomplish the exact same thing, namely, display Bots as Bots in Whos Online and still be able to determine if a visitor is really an unknown Bot and add this new Bot to spiders.txt.

 

You appear to be relying on sessionID in admin/whos_online.php to determine if a visitor is a Bot. Let me know if that's an incorrect assumption.

 

I've modified catalog/includes/functions/whos_online.php. When a Bot is identified from spiders.txt, a spider_flag is set. When I see that flag, I put the IP in sessionID and I set customerID = -1. (again, only affects whos_online table, nothing else)

 

Then in admin/whos_online.php, I use customerID < 0 to determine if I have a Bot. I've moved the Bot/noBot determination from sessionID to customerID.

 

Here's some of the catalog/includes/functions/whos_online.php code:

  function tep_update_whos_online() {
// WOL 1.6 - Need access to spider_flag and user_agent and moved some assignments up here from below
   global $customer_id, $spider_flag, $user_agent;

   $wo_ip_address = getenv('REMOTE_ADDR');
   $wo_last_page_url = getenv('REQUEST_URI');

   $current_time = time();
   $xx_mins_ago = ($current_time - 900);
   $wo_session_id = tep_session_id();
// WOL 1.6 EOF

   if (tep_session_is_registered('customer_id')) {
     $wo_customer_id = $customer_id;

     $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
     $customer = tep_db_fetch_array($customer_query);

     $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
// WOL 1.6 - Moved session_id assignment into if statement (was just below.)
     $wo_session_id = tep_session_id();
// WOL 1.6 EOF
   } else {
// WOL 1.6 - Write Spiders name as full name and use IP Address as SessionID
     if ( $spider_flag ) {
       // Bots are customerID = -1
       $wo_customer_id = '-1';
       // Remove (URL) from spiders name
       $wo_full_name =  substr( $user_agent, 0, strcspn( $user_agent, '(' ) );
       //$wo_full_name = $user_agent;
       $wo_session_id = $wo_ip_address;
     } else {
       // Just in case it wasn't a spider after all
       $wo_full_name = 'Guest';
       $wo_customer_id = '';
     }
// WOL 1.6 EOF
   }

 

Here's some of the code from admin/whos_online.php:

// WOL 1.5 - Display Status
   // spider detection??
   //if (($whos_online['session_id'] == '') | (!(isset($whos_online['session_id'])))) {
   if ($whos_online['customer_id'] == -1) {
// WOL 1.6 - Moved image code here
    $noSessionDetected = ' ' . tep_image(DIR_WS_IMAGES . 'icon_status_white.gif', TEXT_STATUS_NO_SESSION_BOT);
// WOL 1.6 EOF
   } else {
    $noSessionDetected = '';
   }
?>
             <td class="dataTableContent" align="left">
               <?php 
// WOL 1.6 - Added bot counter here and reformatted code
               if ( $noSessionDetected == '' ) {
                 // session = not a bot
                 echo ' ' . tep_check_cart($whos_online['session_id']);
               } else {
                 // no session = bot
                 echo $noSessionDetected;
                 $total_bots++;
               } 
// WOL 1.6 EOF
               ?>
             </td>
<!-- WOL 1.5 EOF -->

And here is where I used to have all of those if/else and hardcoded Bot IPs:

// WOL 1.4 - Changed so that if IP Address is mine, it displays Me!.
//       If it's a known Bot, it displays the Bot's name
//       Otherwise, it displays the IP Address as a link to ShowMyIP.com
//       Tracks number of Bot and Me sessions
               // My own IP
               if ($whos_online['ip_address'] == $_SERVER["REMOTE_ADDR"])
               {
                     echo '<td class="dataTableContent" align="center"><font color="green">Me!</font></td>';
                     $total_me++;
               }
// WOL 1.6 - Removed Bot id code.  Functionality now in catalog/includes/functions/whos_online.php                
               else
               { ?>
               <td class="dataTableContent" align="center"><a HREF="http://www.showmyip.com/?ip=<?php echo $whos_online['ip_address']; ?>" target="_blank"><?php echo $whos_online['ip_address']; ?></A></td>
               <?php   } ?>
               <!-- <td class="dataTableContent" align="center"><a HREF="http://www.showmyip.com/?ip=<?php echo $whos_online['ip_address']; ?>" target="_blank">who is</A></td> -->
<!-- WOL 1.4 eof -->                

 

I am now relying on Prevent Spider Sessions and spiders.txt to determine what is and is not a Bot. This is done in catalog/includes/functions/whos_online.php. I don't track hardcoded IP addresses in admin/whos_online.php anymore.

 

I think all of this addresses your comment:

So for me, because I really want to track and verify all Bots, it's imperative that the sessionID stay blank to prove that they really have no sessionID (whereas overwriting it with their IP would not allow me to check it... unless I go into the database each time).

Moving the Bot/noBot decision to customerID < 0 allows a blank sessionID to hold the Bot's IP.

 

I need to clean up the code that parses the User Agent to get the Bot name.

 

Thoughts?

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

Hey there Ed,

I'm going to throw it into my code and see how it works. It sounds great. For me though, I think I'll continue to display a Bot's name based on its IP (instead of trying to parse it out), so there might be the only place my code's going to end up differing.

 

Talk to ya!

BD

Share this post


Link to post
Share on other sites

Has anyone added sounds to indicate any activity on a page refresh.

 

The colors work nice, but watching the screen for activity isn't really too productive.

Share this post


Link to post
Share on other sites

Henry,

 

I haven't. I've been working with BoulderDash to add more descriptive colors. I've also been working on identifying Bots WITHOUT having to update IP Addresses in if statements in the code. But, I haven't worked on sounds.

 

Ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

Heh heh,

As long as they have an "off" or "on" state that is... I'd hate to have them going off while I'm sneaking a peek at my visitors, while I'm at work. What I think would be fun is a "cha ching" sound when a Cart is created!

 

:P

 

See ya,

BD

Share this post


Link to post
Share on other sites

This looks a great addition, thats for your work!

 

I have finally got round to updating from the basic whose online to v1.5, and it's much easier on check what is happening quickly etc. , which c is great!

 

I do get an error however, only when i click on a customer to display cart or referrer and i get:

 

Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition supercart of the object you are trying to operate on was loaded _before_ the session was started in /xxx/xxx/xxxxx/xx/xxx/xxx/whos_online.php on line 398

 

It is quite possible i had this error before updating, as my who's online wans;t working properly since installing ebay auction manager (hence the 'Supercart' class) (possibly even before that, as you can see i didnt use it that much before!)

 

Any ideas as to the cause of this error would be greatly appreciated.

 

Cheers

 

Matt

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

×