<?php
function isgooglebot($ip)  {
	$bot = 'googlebot.com';
	if (gethostbyaddr($ip) == $ip) return false;
	$new_name = explode(".", gethostbyaddr($ip));
	$name = $new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
	return $name == $bot;
}


function isyahooslurp($ip)  {
	$bot = 'yahoo.com';
	$bot2 = 'inktomisearch.com';
	if (gethostbyaddr($ip) == $ip) return false;
	$new_name = explode(".", gethostbyaddr($ip));
	$name = $new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
	return ($name == $bot or $name == $bot2) ? true : false;
}


function ismsnbot($ip)  {
	$bot = 'search.live.com';
	if (gethostbyaddr($ip) == $ip) return false;
	$new_name = explode(".", gethostbyaddr($ip));
	$name = $new_name[sizeof($new_name) - 3].'.'.$new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
	return $name == $bot;
}
?>

In één functie naar verzoek van siliecom14:
<?php
function iscrawler($ip)  {
	$bot = 'googlebot.com';
	$bot2 = 'yahoo.com';
	$bot3 = 'inktomisearch.com';
	$bot4 = 'live.com';
	
	if (gethostbyaddr($ip) == $ip) return false;
	$new_name = explode(".", gethostbyaddr($ip));
	$name = $new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
	if ($name == $bot) {
		return "googlebot";
	} elseif ($name == $bot2 or $name == $bot3) {
		return "yahoobot";
	} elseif ($name == $bot4) {
		return "msnbot";
	} else {
		return false;
	}
}
?>

<?php
function iscrawler2($ip, $crawler)  {
	$bot = 'googlebot.com';
	$bot2 = 'yahoo.com';
	$bot3 = 'inktomisearch.com';
	$bot4 = 'live.com';
	
	if (gethostbyaddr($ip) == $ip) return false;
	$new_name = explode(".", gethostbyaddr($ip));
	$name = $new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
	if ($name == $bot and $crawler = "googlebot") {
		return true;
	} elseif (($name == $bot2 or $name == $bot3) and $crawler = "yahoobot") {
		return true;
	} elseif ($name == $bot4 and $crawler = "msnbot") {
		return true;
	} else {
		return false;
	}
}
?>

Functie met de bots in een array, door mesynthetix
<?php
function iscrawler($ip)  {
    $bots['googlebot.com'] = 'googlebot';
    $bots['yahoo.com'] = 'Yahoo';
    $bots['inktomisearch.com'] = 'Yahoo';
    $bots['live.com'] = 'Live Search';
  
    if (gethostbyaddr($ip) == $ip) return false;
    
    $new_name = explode(".", gethostbyaddr($ip));
    $name = $new_name[sizeof($new_name) - 2].'.'.$new_name[sizeof($new_name) - 1];
    
    if (isset($bots[$name])) {
        return $bots[$name];
    } else {
        return false;
    }
}