sx Posted March 22, 2007 Share Posted March 22, 2007 I need to detect whether a visitor is a spider or a human visitor. I need to output the info in a varialble like $visitor. How can I go about doing that. I know SMF forums can detect them as I use SMF too but an unable to find the code in their scripts that do this. Thx. Link to comment https://forums.phpfreaks.com/topic/43853-detect-bot-or-human/ Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 You have to find the range of IPs. How they do it is they have a range of google, yahoo etc IPs. When someone comes to the site they check against the IP, if it is in the range it is a bot else it is a human. You want a list of Bot IPs. Link to comment https://forums.phpfreaks.com/topic/43853-detect-bot-or-human/#findComment-213206 Share on other sites More sharing options...
kenrbnsn Posted March 23, 2007 Share Posted March 23, 2007 Take a look at $_SERVER['HTTP_USER_AGENT']. Most bots will say they are a bot in the value. Here's the "if" statement I use to determine if the visitor is not a human. <?php if (preg_match('/slurp|inktomisearch|[Gg]rub|[bb]ot|archiver|[ss]qworm/', $_SERVER['HTTP_USER_AGENT'])) echo "Is not a human"; ?> It's not perfect, but it comes close. You probably want to save this string or email it back to yourself when your site is visited, so you can capture any that are slipping through. Ken Link to comment https://forums.phpfreaks.com/topic/43853-detect-bot-or-human/#findComment-213237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.