Google posted the principles of bot verification a while back. MSNbot can now be verified by the same method. Can we put our heads together and come up with a way to do this in PHP? Or is there any code out there already? I don't know how to do the DNS lookups, I can fetc IP and UA just fine but from there on....
You can use PHP function gethostbyaddr() to convert IP to host name. Test for your example IP <? echo gethostbyaddr('207.46.98.149'); ?> PHP: returns livebot-207-46-98-149.search.live.com. Now you have all data for checking identity of bot
OK so that would be the reverse DNS part right? BTW Looks like it should be gethostbyaddr() instead. Combine that with gethostbyname() and we're done. OTTOMH: $bot_hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); $bot_ip = gethostbyname($bot_hostname); if ($_SERVER['REMOTE_ADDR'] == $bot_ip) { echo 'welcome friendly bot!'; } else { echo 'piss off rogue bot!'; die("You basterd!"); } PHP:
Your code does not implement instructions you quoted in your first message, because it does not handle user agent. Your code just checks if "bot" has a dedicated IP address. (There are many hostings with many sites on the same IP).
Aha (d'oh) I need to take the user agent and then match MSNbot with live.com, Googlebot with google.com etc. Thanks for correcting me!
Thanks for pointing out this thread to me TOPS3O. I'm subscribing and will be interested in seeing both actions (Reverse > Forward) automated by one or all of the analytics platforms out there as an "on demand" functionality. Hint Hint
OK, here it is folks: http://ekstreme.com/phplabs/search-engine-authentication.php I love that guy. He's one of the best kept secrets in the SEO / SEO / Design blogosphere.
You're right. I just updated the code. Thanks for the heads up It's still at http://ekstreme.com/phplabs/search-engine-authentication.php . Thanks for initial link Everett!