Saturday, June 20, 2009

Script For Cloaking A Website

I have been searching for a lot of affiliate marketing lately and one of my biggest concerns is always protecting my own landing page from competitors. Since I’m tracking every visitor that comes to my main page, I can get a good idea of how many of those visits are competitors looking for ideas for their sites. I can’t really blame them, I check up on my competitors as well And This doesn’t mean I Dont protect myself...

With the help of Ben from WickedFire.com I put together a short script that will cloak your site from anyone not coming from the exact sources you specify. You can even white list IP addresses to make sure no direct traffic comes to the site that doesn’t belong there.

So, here is the script:


if(!empty($_SERVER['HTTP_REFERER'])) {
$referer = parse_url($_SERVER['HTTP_REFERER']);

preg_match(’/[^.]+\.[^.]+$/’, $referer['host'], $match);

if ($match[0] != ‘trafficsource.com’) {
header(”Location: http://www.offerpage.com”); //redirect all traffic that comes from any source except the one listed above
exit;
}
}

if(empty($_SERVER['HTTP_REFERER'])) {
$visitor = $_SERVER['REMOTE_ADDR'];

if (!(preg_match(”/xx.xxx.xxx.xx/”,$visitor)) && !(preg_match(”/yy.yyy.yyy.yy/”,$visitor))) {
header(’Location: http://www.offerpage.com?subid=directTraffic’); //redirect all IP addresses to this that are not the IP addresses listed above
exit;
}
}

?>

This should do the trick. Remember to fill out the correct information in the script, it won’t “just work.” Thing to remember is that when you enter a traffic source, it should be the root domain (myspace.com, google.com, facebook.com) and nothing else. The script will parse the referring source down to just the root domain. You can add as many IP addresses as you want just by adding another AND (&&) operator. You can also edit it.

Any suggestions or queries, please do write as comments...

No comments:

Post a Comment