debug_logger->log_debug("block_fake_googlebots(): IP address = ".$ip,2); if(empty($ip)){ $aio_wp_security->debug_logger->log_debug("block_fake_googlebots(): Empty IP address detected!",2); $aio_wp_security->debug_logger->log_debug("block_fake_googlebots(): User Agent = ".$user_agent,2); return; } $name = gethostbyaddr($ip); //let's get the internet hostname using the given IP address //TODO - maybe add check if gethostbyaddr() fails $host_ip = gethostbyname($name); //Reverse lookup - let's get the IP using the name if(preg_match('/Googlebot/i', $name, $matches)){ if ($host_ip == $ip){ //Genuine googlebot allow it through.... }else{ //fake googlebot - block it! $aio_wp_security->debug_logger->log_debug("Fake googlebot detected: IP = ".$ip." hostname = ".$name." reverse IP = ".$host_ip,2); exit(); } }else{ //fake googlebot - block it! $aio_wp_security->debug_logger->log_debug("Fake googlebot detected: IP = ".$ip." hostname = ".$name." reverse IP = ".$host_ip,2); exit(); } } } }