PDA

View Full Version : Who's Online Enhancement



michael_s
09-11-2007, 09:16 PM
I've been working on a project, and it's currently working, but looking to see if I can get some inhancement on it.

I didn't like the Current version of Who's on line, and it's Bot Checking, and at times it was very slow if the Remote computer did not have a reverse dns entry.

What I wanted was a new MYSQL Table that stored IP, ReverseDNS, and BotStatus.

I wanted to open up Who's been here / Who's online and see all the Unique visitors that occured from the last time I managed the list.

I also wanted to be able to mark the IP as Bot or Hide from list as customer if it was not a bot, and the ability to change the record back if I made an error.

Once I had this daily list of who was here, on the same page I wanted to see who IS here now, and I wanted to pull the Reverse info and bot status from my table rather than checking the internet.

The Result is coming to gether very nicely, I'd like to keep cleaning it up, If there is allready such a thing then please dirrect me, otherwise submited for your approval: Who's been here? V.0

You need to Create a new Table in your database called ip_visit
Then create three rows: ip, isbot, reverse_IP

Note: Some of the code at the beggining of this file is from the who's online, however most of it is not used, I need the code to include my page within the admin page.

Place the file in the Admin folder and call it using the /admin/ip_visit.php

And I choose to have each visitor added to the ip_visit when they opened my index.php by placing the following code into either a left or right box that runs when they open the site.

$bot_name = array('googlebot','inktomisearch','crawl','bot');

$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');
$whos_online = tep_db_fetch_array($whos_online_query);

$ec=0;
while($ec < count($bot_name)) {
if (strstr(gethostbyaddr($whos_online['ip_address']),$bot_name[$ec])) {
$ecbot = true;
}

$currentip = tep_db_query("select reverse_IP,ip from ip_visit where ip = '" . ($whos_online['ip_address']) . "'");
if ($row = tep_db_fetch_array($currentip)) {$test='true';
} else { $test='false';
tep_db_query("insert into ip_visit (isbot, ip, reverse_IP) values ('" . $ecbot . "' ,'" . ($whos_online['ip_address']) . "','" . gethostbyaddr($whos_online['ip_address']) . "')");
}

$ec++;
}



More... (http://www.oscommerce.com/community/contributions,824)