Jump to content

Detect Bot's Names


EchoFool

Recommended Posts

Ive seen a number of forums with thing in their "online" users list:

 

Google [bot], Ask Jeeves [bot], Alexa [bot] 
Etc.

 

Is this a php thing that detects a bot viewing the site and some how knows the name of the bot (or in this case the owner of the bot?) ... how is it done in php - is it php that is doing this kind of detection ?

Link to comment
Share on other sites

Ive seen a number of forums with thing in their "online" users list:

 

Google [bot], Ask Jeeves [bot], Alexa [bot] 
Etc.

 

Is this a php thing that detects a bot viewing the site and some how knows the name of the bot (or in this case the owner of the bot?) ... how is it done in php - is it php that is doing this kind of detection ?

 

$_SERVER and preg_replace should do 'er! Here's some example code:

$agent = getenv("HTTP_USER_AGENT");
$botname = "";
if (preg_match("/GOOGLE/i", $agent)) {
$botname = "Google [bot]";
} elseif(preg_match("/ASK/i", $agent)) {
$botname = "Ask Jeeves [bot]";
} elseif(preg_match("/MSNBOT/i", $agent)) {
$botname = "MSN Search [bot]";
}

 

etc. You can modify it to your needs, such as using that as an IF to remove all entries of the bots. (if you were wanting to do something with them)

Link to comment
Share on other sites

So whats the bot's primary purpose ?

 

They're bots for search engines, Them being included as a user allows them to spider your site more effectively, helping your search rank. Some bots register themselves or you can give them authentication etc, but some forums just list the guest bot as  that, even if it's not actually a user.

Link to comment
Share on other sites

Can they be a security threat?

 

Any site listed on any search engine, has had their bot on their site at one point. If you see a security risk (such as bot listing hidden pages like /admin/) than you can simply use robots.txt to disallow access to certain areas. Virtually all (non-malicious) bots use robots.txt, other than that there is virtually no security risk, especially with search bots that are known.

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.