How to disable hotlinking with PHProxy

Posted by admin on October 4th, 2007 filed in Proxy Tips

I just found a great post on Digital Point about how to stop hot linking bandwidth wasting if you’re using PHProxy.

What is hotlinking? And why is it bad for proxy owners?

Hotlinking is when people link to proxified pages on your proxy. Meaning people go directly to proxified pages without having to go through your frontpage / homepage. Hotlinking allows people to link images, files, pictures, basically anything downloadable through your web proxy, killing your bandwidth as the same time revenue. That is why you try to disable it!, so people have to go through your homepage first.

If you’re using PHProxy put the following code in index.php straight after <?php

/*
PHProxy bandwidth MOD by Rhett Canney (Billy Connite)
This MOD will stop any hotlinking via PHProxy, even if the
clients referer is not set!
Check out ProxyWebsite.com if you want to try hotlinking.
*/

// Change this to your domain (no ‘www.’)
$domain=”CHANGETHISTOYOURSITE.COM”;

// If no request:
if($_GET['q']!=”"){
// Get referer
$referer=$_SERVER['HTTP_REFERER'];
// Check to see if referer is not the proxys domain
$count=substr_count($referer,$domain);
// If there is an outside referer:
if($count==0){
// If there is a request:
if($_GET['q']!=”"){
// Redirect to homepage and finish script
header(”Location: http://www.” . $domain . “/”);
exit();
}
}
}

/*
END MOD
*/

and just change “CHANGETHISTOYOURSITE.COM” to your own domain

The source of this information came from DP post http://forums.digitalpoint.com/showthread.php?t=489551

Leave a Comment