I just learned about cloaking today so I decided to write a quick script that tries to filter out Google's spider via an ACL and the user-agent.
I know it's very basic and only works for Google's spider. Maybe you can give me some ideas so I can incorporate them into the script.
I'll definitely be updating this and I'll make an update in this thread when I do.
Anyways, I thought maybe somebody would have a use for it. If you have any questions, just ask.
I know it's very basic and only works for Google's spider. Maybe you can give me some ideas so I can incorporate them into the script.
I'll definitely be updating this and I'll make an update in this thread when I do.
Anyways, I thought maybe somebody would have a use for it. If you have any questions, just ask.
PHP:
<?php
$bip = new ArrayObject();
$bhn = new ArrayObject();
/*
* Set these variables to the location of the file that holds the black listed IP/hostnames
*/
//$ipblacklist = "ipblacklist.txt";
//$hnblacklist = "hnblacklist.txt";
if(isset($ipblacklist))
{
$file = fopen($ipblacklist, "r");
while(!feof($file))
{
$bannedip = fgets($file, 1024);
$bip->append();
}
}
if(isset($hnblacklist))
{
$file = fopen($hnblacklist, "r");
while(!feof($file))
{
$bannedhn = fgets($file, 1024);
$bhn->append();
}
}
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if(in_array($_SERVER['REMOTE_ADDR'], (array)$bip) || in_array($hostname, (array)$bhn))
{
include("spider_content.html");
} else if(stristr($_SERVER['HTTP_USER_AGENT'], "Mediapartners-Google") || stristr($_SERVER['HTTP_USER_AGENT'], "Googlebot")) {
include("spider_content.html");
} else {
include("human_content.html");
}
?>