My basic cloaking script

Asprin

Newbie
Joined
Oct 15, 2007
Messages
15
Reaction score
15
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.

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");
}


?>
 
I only see the edit button on new posts, but goes away after a while.
Maybe I need a certain number of posts before I can edit?

I'll be making an update on this soon.
 
hey there Asprin

thanks for sharing this code.. it's very cool to see an example.

as for handling multiple user-agents, try creating another hash containing the complete list and then check against that in a conditional.

i.e. if user-agent in array, then process..

peace
 
Any updates on the script?
I had something similiar, but don't know how to move from there.
 
Back
Top