Hello There, Guest! (LoginRegister)
Post Reply  Post Thread 
Untitled DocumentUntitled Document
Stop Hotlinking on phProxy
Author Message
Admin
Administrator
*******


Posts: 17
Group: Administrators
Joined: Dec 2007
Status: Offline
Reputation: Neutral Reputation
Post: #1
Stop Hotlinking on phProxy

Proxies in general, at least well trafficked ones, use quite a bit of bandwidth on their own. Imagine if people were hotlinking to images, files, etc through your proxified pages using your proxy server, but instead of you getting the visitors, you just get the bandwidth usage charges!

To stop that from happening, place the following code at the beginning of your index.php file, just after the beginning "<?php" code :

Code:
/*
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="proxy-talk.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
*/


Anyone who now tried to hotlink an image through one of your proxified pages, will now be redirected to the main index page of the url defined at the top of the code.

This post was last modified: 01-14-2008 08:59 PM by Admin.

01-14-2008 08:58 PM
Find all posts by this user Quote this message in a reply


Admin
Administrator
*******


Posts: 17
Group: Administrators
Joined: Dec 2007
Status: Offline
Reputation: Neutral Reputation
Post: #2
RE: Stop Hotlinking on phProxy

Here's a version that will stop hotlinking, but also allow sites that you define to be able to hotlink to images on your site, whether they are in proxified pages, or images that are hosted on your site:

Code:
/*
PHProxy bandwidth MOD by Rhett Canney (Billy Connite)
This MOD will stop any hotlinking via PHProxy, even if the
clients referer is not set!
*/

$domains[]="www.proxy-talk.com";
$domains[]="proxy-talk.com";
$domains[]="www.station2you.com";
$domains[]="station2you.com";

  // Get referer
  $referer=explode("/",($_SERVER['HTTP_REFERER']));
  // Check to see if referer is not the proxys domain
  // If there is an outside referer:
  if(!in_array($referer[2],$domains)){
    // If there is a request:
    if($_GET['q']!=""){
      // Redirect to homepage and finish script
      header("Location: http://www.someaddress.com/something.html");
      exit();
    }
  }

/*
END MOD
*/


Obviously, you'll need to change the domains defined above Smile

01-15-2008 09:36 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: