EchoFool Posted December 6, 2009 Share Posted December 6, 2009 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 ? Quote Link to comment Share on other sites More sharing options...
Cardale Posted December 6, 2009 Share Posted December 6, 2009 I believe the most commen method is finding out their user agent. Here is a good link I found. http://www.useragentstring.com/pages/All/ If you do make a class incorporating these let me know. I wouldn't mind using it. Quote Link to comment Share on other sites More sharing options...
Altec Posted December 6, 2009 Share Posted December 6, 2009 I found this short article on the subject: http://ditio.net/2008/09/07/detecting-search-engine-bots-with-php/ Obviously you'll need to do some research on which bots use what names, but the premise is the same. EDIT: Looks like Cardale hit the jackpot. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 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) Quote Link to comment Share on other sites More sharing options...
EchoFool Posted December 6, 2009 Author Share Posted December 6, 2009 So whats the bot's primary purpose ? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 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. Quote Link to comment Share on other sites More sharing options...
EchoFool Posted December 6, 2009 Author Share Posted December 6, 2009 Can they be a security threat if coded for that purpose? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 6, 2009 Share Posted December 6, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.