Log in

View Full Version : Setting up hotlink protection without .htaccess



cursed
03-08-2007, 11:26 PM
I have this code::



/*
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!
Check out proxywebsite.org if you want to try hotlinking.
*/

// allow hotlinking from these sites, seperate by comma (make sure you eneter your site's domains)
$domains="www.yourdomain.com,yourdomain.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
*/

Can this script work on any web page?

I know people wont go breaking their back to help me, but if someone has time, and can help me, please PM me.

djr33
03-09-2007, 01:58 AM
uh.... why.
People can't link to you then.

You might be able to use it on images, but that would be weird, and a lot of work.

Just use .htaccess

boxxertrumps
03-09-2007, 06:29 PM
For password protected pages, you can only access when your on the site

mburt
03-09-2007, 07:59 PM
Unless once the page is entered it saves a value to a flat-file, and redirects to another page if that value is whatever, the login page would load.

djr33
03-09-2007, 09:32 PM
This is stupid for password protection.

You could hack this without too much trouble.

so... you need real password protection, so why bother with this as well. And if a browser messes up with the transfer of the referer, which I believe can happen, then you're stuck.