How to Prevent Hotlinking in PHProxy
A Web proxy server with PHProxy is a risky business because this script not have any hotlinking prevention allowing other can just go to your proxied pages without going through your front page and download, link any picture, etc by using your bandwidth with the risk that your server going down.
How to prevent users from hotlinking through your PHPproxy script?
Open index.php file with notepad and put this code above.
Replace domain.com with your proxy domain name
<?
/*
Start MOD
*/
/*
PHProxy bandwidth MOD 1.1 by Rhett Canney (Billy Connite)
This MOD will stop any hotlinking via PHProxy, even if the
clients referer is not set!
*/
// allow hotlinking from these sites, seperate by comma (make sure you eneter your site’s domains)
$domains=”www.domain.com,domain.com”;
// convert domains into an array
$domains=explode(”,”,$domains);
// if there is a request:
if($_GET[’q']!=”")
{
// get referer
$referer=explode(”/”,($_SERVER[’HTTP_REFERER’]));
// if the referer is not allowed:
if(!in_array($referer[2],$domains))
{
// redirect to homepage and finish script
header(”Location: http://”.$domains[0].”/”);
exit();
}
}
/*
END MOD
*/
?>
Comments
One Response to “How to Prevent Hotlinking in PHProxy”
Leave a Reply
You must be logged in to post a comment.


Hey there!
Relly cool info.
Appreciated.
http://www.ProxyWebsites.us