Jump to content

[SOLVED] track spiders on my site?


marksie1988

Recommended Posts

So would something like the following work? and would this be able to post the information for all users to see or just the bot? or would i need to write the information into a database and then display this information?

 


<?php
function agent($bot) {
$useragent = $_SERVER['HTTP_USER_AGENT'];
return strstr($useragent,$bot);
}

if(agent("WISENutbot") !== FALSE) {
echo "Looksmart Bot";
}
else if(agent("Googlebot") !== FALSE) {
echo "Google Bot";
}
else {
echo "";
}
?>

Link to comment
Share on other sites

it's the way your session handler works. many forums and other CMS's use the database to store sessions, so they can store additional info such as the user agent, IP, etc.

 

This way, all you need is a simple query to the sessions table and you're away.

 

see http://uk.php.net/session_set_save_handler

 

there are other ways of doing it, made easier if you have a common include file for every request (such as a front controller). simply store the IP/Agent/Timestamp, etc followed by a cleanup of records that are older than a certain period, and you're done. Just query the table when you need the info.

The reason why I personally use sessions is just keeping all info together as there are many other uses, too.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.