phpretard Posted February 19, 2008 Share Posted February 19, 2008 I am trying to catch that waskaly googlebot crawling my site. Evidently they have lots of IP addresses and whois says the range is 66.249.64.0 - 66.249.95.255. Please help me with the code below. <? $ip=$_SERVER['REMOTE_ADDR']; if($ip=='RANGE OF IPS'){ echo "Caught ya"; ?> } Thank you. -Anthony Quote Link to comment Share on other sites More sharing options...
phpretard Posted February 19, 2008 Author Share Posted February 19, 2008 anyone? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 <?php $parts = explode('.',$_SERVER['REMOTE_ADDR'],4); if($parts[0] == 66 && $parts[1] == 249 && $parts[2] >= 64 && $parts[2] <= 95){ echo "Caught ya"; } ?> Quote Link to comment Share on other sites More sharing options...
phpretard Posted February 19, 2008 Author Share Posted February 19, 2008 I have no idea what that code reads but I am going to use it. Thank you!! Quote Link to comment Share on other sites More sharing options...
tinker Posted February 19, 2008 Share Posted February 19, 2008 You could also catch 'em by looking at $_SERVER['HTTP_USER_AGENT'], not the way you asked but another method, here's some random agents from my logs: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) msnbot-media/1.0 (+http://search.msn.com/msnbot.htm) Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp) Gigabot/3.0 (http://www.gigablast.com/spider.html) msnbot/1.0 (+http://search.msn.com/msnbot.htm) IRLbot/3.0 (compatible; MSIE 6.0; http://irl.cs.tamu.edu/crawler) I'd also recommend a look here: http://www.robotstxt.org/ Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 I have no idea what that code reads but I am going to use it. Thank you!! First, it splits the IP into it's 4 parts. Then, tests for the case where the first part is 66, the second is 249, and the third is between 64 and 95. The forth part is irrelevant if they own everything in the 0-255 range. Quote Link to comment Share on other sites More sharing options...
phpretard Posted February 19, 2008 Author Share Posted February 19, 2008 Thank you!!! Now I get to hunting that Waskely Wobot. HEHEHEHEH 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.