bilawalblog
-
02:21:27 pm on June 26, 2009 | # |
Okay, right here, I’ll show you some code that a lot of people who develop using systematic coding languages (in this instance, LAMP – Linux Apache MySQL PHP).
If you use background processes in your application, such as checking a Google bot is accessing your web page, you want to verify this. Anyone can mask the HTTP User Agent protocol, so they can pretend their from Google.
Here’s a function code that will determine if Google’s accessing your site.
<?php
public function is_google_bot()
{
$server = $_SERVER['REMOTE_ADDR']; //IP
$hostname = gethostbyaddr($server);
$format = str_replace(".", "-", $format);
$google_hostname = "crawl-".$format.".googlebot.com";
if($hostname == $google_hostname)
return true;
else
return false;
}?>
That code I have just provided is 100% secure. It never has the ability to be hacked, and will work like awesomeness in any application you will develop. Just develop it in your own environment and it will be ready to go.
If you’ve got any questions to ask about the code above, feel free to comment on my post. I’ll be happy to respond to any appropriate and relevant comments.