SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Monday, July 12, 2010

Hotlinking prevention for Phproxy, CGI-Proxy and Zelune


Hotlinking in the proxy business happens when someone goes directly to a website without going through your web proxy’s home page. Hotlinking harms you and your proxy in two ways:
  1. People linking directly to images and/or videos are using/stealing your bandwidth
  2. You are losing advertising revenue since people go directly to the webpage without coming through your home page which holds the majority of your advertising.
PHProxy supposedly has hotlink prevention incorporated into it. It could be just me but I never managed to make it work. Instead you can add a piece of code to achieve hotlink prevention. Same for CGI-Proxy and Zelune.
For PHProxy, open up you index.php with Wordpad and add the following code right 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!
*/

// Change this to your domain (no ‘www.’)
$domain=”443proxy.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();
}
}
}
For CGI-Proxy, open up you npi-proxy.cgi with Wordpad. Find
$HTTP_1_X=$NOT_RUNNING_AS_NPH?’Status:’:”HTTP/$HTTP_VERSION”;
and add the following code right under it:
if($ENV{’HTTP_REFERER’} =~ /^http:\/\/www.443proxy.com/)
{
}
else
{
&redirect_to(’http://www.443proxy.com/’, ”);
For Zelune proxy, open up you index.php with Wordpad and add the following code right after <?php (thanks to Matt - on DigitalPoint forums for this mod):
// Change this to your domain (no ‘www.’)
$domain=”yourdomain.com”;
// If no request:
if($_GET[’__new_url’]!=”"){
// 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[’__new_url’]!=”"){
// Redirect to homepage and finish script
header(”Location: http://www.” . $domain . “/”);
exit();
}
}
}

Source :  http://kiloserve.com/blog/2007/10/26/hotlinking-prevention-for-phproxy-and-cgi-proxy/#more-6

No comments:

Post a Comment