Bandwidth MOD

SpaceshipSpaceship
Watch
Bandwidth MOD

Version:
1.1

Installation: Simply copy and paste the mod code into your index.php page, just below the '<?php' at the top of the page.

PHP:
/*
Bandwidth MOD 1.1
*/

// 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
*/
Best of luck
 
Last edited:
17
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
just a note I notice you are using $HTTP_GET_VARS, this is deprecated and you should use $_GET (the same goes for post as well). The ones you use do still work but could be disabled at any time by the php developers. These arrays changed in 4.1.0.
 
1
•••
i use cgiproxy... :P

So I have just the form on my front page.
 
0
•••
filth@flexiwebhost said:
just a note I notice you are using $HTTP_GET_VARS, this is deprecated and you should use $_GET (the same goes for post as well). The ones you use do still work but could be disabled at any time by the php developers. These arrays changed in 4.1.0.
Thanks for the info Peter :), made the appropriate changes to the mod, rep added.
jimmeh said:
i use cgiproxy... :P

So I have just the form on my front page.
Aahh, I see, I haven't made a mod for CGIProxy yet, but I'll look into it later for you.
 
0
•••
i am using phproxy

let me know if you have any solutions for core dumps
 
0
•••
rep added
 
0
•••
1
•••
Thanks, Rep Added!
 
0
•••
Thank you for the very useful tip!

Rep added!
 
0
•••
Thanks for the rep and kind words everyone :).

I have updated the MOD, as the previous code had a small hole in it ;):
PHP:
/*
PHProxy bandwidth MOD 1.1
This MOD will stop any hotlinking via PHProxy, even if the
clients referer is not set!
*/

// Change this to your domain (no 'www.')
$domain="proxywebsite.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
*/
Updated in first post also.

Enjoy!
 
Last edited:
0
•••
Even though I hate perl, I did learn a little bit of it a while back. I'll see if I can find some time, and come up with something similar for CGIProxy
 
0
•••
thanks guys! =D
 
0
•••
Hi,
Excuse my ignorance but does this work if users type my domain with or without 'WWW'?
PHP:
// Change this to your domain (no 'www.') 
$domain="proxywebsite.com";

Also, does this suffer from the same issue that some browsers have with http_referer as this other solution?

http://www.webmastertalk.net/showthread.php?t=29

Many thanks,

- Vince
 
0
•••
vincenzo said:
Hi,
Excuse my ignorance but does this work if users type my domain with or without 'WWW'?
PHP:
// Change this to your domain (no 'www.') 
$domain="proxywebsite.com";

He is checking the existance of the domain name within the referer field. That is why it needs to be without the www. so that it will work regardless of wether they use it or not.

vincenzo said:
Also, does this suffer from the same issue that some browsers have with http_referer as this other solution?

http://www.webmastertalk.net/showthread.php?t=29

Yes unfortunately it will. Some browsers do not set this as well as some firewalls stripping it. (there are even extensions for some browsers that will change it) BUT the vast majority of people I would say have this set and so would fix them.
 
Last edited:
0
•••
Thanks for clearing the first bit up Peter.

But, the good thing about this is that if the referer is equal to nothing, then it will redirect back to the main page (if they have sent a request). So that means that this will stop ANY hotlinking, even from browsers not sending a referer :).

Nice and sweet :D.
 
0
•••
One last question.
If it also blocks when "the referer is equal to nothing, and redirect back to the main page" does that mean it will stop them from using the proxy completely, and keep sending them back to the home page?

Thanks,

- Vince
 
0
•••
vincenzo said:
One last question.
If it also blocks when "the referer is equal to nothing, and redirect back to the main page" does that mean it will stop them from using the proxy completely, and keep sending them back to the home page?

Thanks,

- Vince
Hey Vince,

No, the proxy will work fine, it will only redirect back to the main page if a request has been made (if they're trying to proxy something) if the referer is nothing (the referer will be yourdomain.com if they are making a request from your website, so it wont simply go to the main page there either).

It does mean that the people who have delibrately disabled their referer setting will not be able to use the proxy, but thats about 0.001% of the web browsers being used. I'd say if they have their referer blocked, its may be a good thing to keep them from using your website anyway.

As you can see from my proxywebsite.com the site works just fine with this mod :)

Hope that helps, i'm not excellent at explaining things lol.

But basically the mod will work just fine, and will only stop around 0.001% of people from using it.
 
Last edited:
1
•••
Excellent!
I'll give it a try on one of mine that seems to suffer from hotlinking.
Rep added. :)

- Vince
 
0
•••
vincenzo said:
Excellent!
I'll give it a try on one of mine that seems to suffer from hotlinking.
Rep added. :)

- Vince
Thanks Vince :).

Take note, that when you apply it, if you are suffering from hotliking, you will see your traffic go down in awstats, that will be all the hotlinking traffic disappearing (which can be a lot), just saying that it won't be good traffic you're losing, only bad :)
 
Last edited:
0
•••
any progress on the CGI version? :P
 
0
•••
Just wanted to report back that it works great for phpproxy.
My traffic has not reduced, but my clicks on Google ads has increased.
I suspect this is due to all those hotlinks redirected to the home page :)

Will have to see if it continues long-term, but so far so good.

Many thanks again.

- Vince
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back