bestscoop
Newbie
- Dec 29, 2016
- 43
- 26
Hi !
Here is a cloaking script with reverse dns. Is just triggering Googlebot nothing else. Hope it's helpful
You don't necessary need to use the included PHP files, you can just code the actions you want the server performs for each case.
Bear in mind that this script can be optimized. When you catch Googlebot the best thing is to save the IP in a text file for example, in that way the next time it comes with the same IP, you don't need to make a new RDNS.
Here is a cloaking script with reverse dns. Is just triggering Googlebot nothing else. Hope it's helpful
Code:
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
if(preg_match('#googlebot#i',$ua)){
$dns = gethostbyaddr($ip);
if (preg_match('#\.googlebot\.com$#i',$dns)) {
$host = gethostbyname($dns);
if ($host == $ip){
// This helps understand if googlebot here is googlebot for mobile, in some case you need to do other stuff
if(preg_match('#AppleWebKit#i',$ua)) {
include ('googlemobilebot.php');
exit;
}
else {
include ('googlebot.php');
return $user;
}
}
else {
// someone is trying to make you think is Googlebot
include ('fakegooglebot.php');
exit;
}
}
else {
// someone is trying to make you think is Googlebot
include ('fakegooglebot.php');
exit;
}
}
else {
// other users
include ('unknownuser.php');
exit;
}
?>
You don't necessary need to use the included PHP files, you can just code the actions you want the server performs for each case.
Bear in mind that this script can be optimized. When you catch Googlebot the best thing is to save the IP in a text file for example, in that way the next time it comes with the same IP, you don't need to make a new RDNS.
Last edited: