All proxy owners look here - Proxy bandwidth saver

Discussion in 'Programming' started by BillyConnite, Aug 22, 2006.

  1. #1
    Hey all, I've posted this on various other forums, so I though I might as well plonk it here too :). Sorry if I put this in the wrong section also!

    I'd noticed a huge increase in my proxy sites traffic suddenly.

    This is because people are using proxies to hotlink images off your proxy sites (mostly porn, HEAPS OF BANDWIDTH!!!)

    So to prevent this hotlinking, you can use the code I made for myself, which can save you loads of bandwidth...

    Just place the code written below - ABOVE all the code in the index.php page. (make sure its after the '<?php' tag though)
    /*
    PHProxy bandwidth MOD by Rhett Canney (Billy Connite)
    This MOD will stop any hotlinking via PHProxy, even if the
    clients referer is not set!
    Check out ProxyWebsite.com if you want to try hotlinking.
    */
    
    // 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
    */
    PHP:
    The code checks to see if there is only an object (image, swf etc) being requested by a referer that is not your site. If it finds that an only an object is being requested, and no html, it will redirect straight to the homepage of your site. :D This prevents any files being hotlinked!

    Just thought i'd share it with you all

    Best of luck,
    Rhett.
     
    BillyConnite, Aug 22, 2006 IP
    RectangleMan likes this.
  2. pkrumins

    pkrumins Well-Known Member

    Messages:
    74
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    128
    #2
    The branch on line 20 is not necessary because you already checked for that condition on line 12.
     
    pkrumins, Aug 29, 2006 IP
  3. wormy

    wormy Active Member

    Messages:
    1,112
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Also this does not have a provision to check for approved hotlinkers, like top proxy sites and proxy directories that are checking to see if your proxy is alive through their scripts.
     
    wormy, Aug 29, 2006 IP
  4. BillyConnite

    BillyConnite Active Member

    Messages:
    287
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    73
    #4
    Oops, can't edit that out, DigitalPoint forums won't allow it.
    Proxy topsites will not be a problem at all, this script will only stop proxied things be hotlinked, not images or other code sitting on your server, so proxy top sites work just fine mate.

    If you want to allow certain hot linkers to hotlink via your proxy, then use this script:
    
    /*
    PHProxy bandwidth MOD by Rhett Canney (Billy Connite)
    This MOD will stop any hotlinking via PHProxy, even if the
    clients referer is not set!
    Check out ProxyWebsite.com if you want to try hotlinking.
    */
    
    $domains[]="www.yoursite.com";
    $domains[]="yoursite.com";
    $domains[]="www.proxy.org";
    $domains[]="proxy.org";
    
      // 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
    */
    
    PHP:
     
    BillyConnite, Aug 29, 2006 IP
  5. 123

    123 Peon

    Messages:
    621
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for the code I needed this I lost about 1Gb on a fairly new site.
     
    123, May 2, 2007 IP
  6. grovenet

    grovenet Active Member

    Messages:
    234
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    78
    #6
    I know this is an old thread ...


    But will this code work in phproxy 1.5, the latest version? Anyone tried it?

    If not, is there an alternative snippet of code that will save my bandwidth? :)

    Thanks.
     
    grovenet, May 7, 2007 IP
  7. Letcha

    Letcha Active Member

    Messages:
    621
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    93
    #7
    I'd like to know if this works on the newer versions as well, thanks!
     
    Letcha, May 9, 2007 IP
  8. warman2442

    warman2442 Active Member

    Messages:
    1,779
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    98
    #8
    It should work with new versions, i just tested on my proxy, it gives no errors so thats a good thing imo :)

    Tyler
     
    warman2442, Dec 8, 2007 IP
  9. warman2442

    warman2442 Active Member

    Messages:
    1,779
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    98
    #9
    This works i was doing some more testing, such as trying to hotlink my own pages, one of my proxies was using over 80gigs per day, lets see if it dies down after implanting this into that proxy aswell ;)

    Thanks again its awesome

    Tyler
     
    warman2442, Dec 14, 2007 IP
  10. Sejje

    Sejje Banned

    Messages:
    1,312
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Worked great for more as well for those that were doubting. Thanks.
     
    Sejje, Dec 14, 2007 IP
  11. RectangleMan

    RectangleMan Notable Member

    Messages:
    2,825
    Likes Received:
    132
    Best Answers:
    0
    Trophy Points:
    210
    #11
    This is invaluable to proxy owners. Thank you.
     
    RectangleMan, Feb 15, 2008 IP
  12. dre

    dre Peon

    Messages:
    1,367
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thanks! This will help me ALOT
     
    dre, Feb 16, 2008 IP
  13. hockeydevil2

    hockeydevil2 Peon

    Messages:
    179
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #13
    thanks i was looking for this code. i knew there was one but didnt know where.
     
    hockeydevil2, Jun 18, 2008 IP
  14. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #14
    Is there any ASP script like this one?
     
    yugolancer, Jun 29, 2008 IP
  15. informationHell

    informationHell Peon

    Messages:
    931
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #15
    nice one.. thanks mate.
     
    informationHell, Jun 29, 2008 IP