How Can I Block Web Proxies

Discussion in 'PHP' started by Mr.Bill, Apr 28, 2009.

  1. #1
    Would someone be able to make this script use "header function to redirect to the main site if a proxy is detected" or else just load the main site if no proxy is detected.

    Just need a way to prevent the site from being viewed from a web proxy. Here is a code I have that doesnt work but was something I found that was one of the better ones.

    
    <?php
    if (
          $_SERVER['HTTP_X_FORWARDED_FOR']
       || $_SERVER['HTTP_X_FORWARDED']
       || $_SERVER['HTTP_FORWARDED_FOR']
       || $_SERVER['HTTP_CLIENT_IP']
       || $_SERVER['HTTP_VIA']
       || in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554))
       || @fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 30))
    {
        header('Location: http://www.google.com');
    }
    ?>
    
    PHP:
    it will redirect to google if a proxy is detected but if no proxy is used then it wont the main site. If I put the main site url in place of Google it just keeps reloading the page and never breaks out of the proxy
     
    Mr.Bill, Apr 28, 2009 IP
  2. googlerankmaniac

    googlerankmaniac Peon

    Messages:
    568
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Nice Thanks for the info!
     
    googlerankmaniac, Apr 28, 2009 IP
  3. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #3
    UHM? Did something get lost in the reading? I am looking for help to make a script work.
     
    Mr.Bill, Apr 28, 2009 IP
  4. googlerankmaniac

    googlerankmaniac Peon

    Messages:
    568
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ow i did get lost! i missed interpret. but anyways thanks anyway i was talking about sites being redirected to google. goodluck with the code.
     
    googlerankmaniac, Apr 28, 2009 IP
  5. Nathan Malone

    Nathan Malone Well-Known Member

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Basically, just include this code on every page of your site, except for the home page (the one you want them to be redirected to).

    If, because of scripting issues, you have to include the code on the home page, there are ways to set it up so the script automatically recognizes that it is on the home page, and doesn't redirect again. If that is the case, let us know, and I or someone else here can stick the code up for you.
     
    Nathan Malone, Apr 28, 2009 IP
  6. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #6
    I am trying to get a working code that would be for the main page and if they visit that page using a proxy it would break them out of the proxy and then display the page. If no proxy is used it would display the page like normal.
     
    Mr.Bill, Apr 28, 2009 IP
  7. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #7
    A) Not all variables checked for are always passed by all browsers.
    B) Doing and fsockopen on each page view, well it will kill your server if you have many users.

    Peace,
     
    Barti1987, Apr 29, 2009 IP
  8. Mr.Bill

    Mr.Bill Well-Known Member

    Messages:
    2,818
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    160
    #8
    Thanks given up on this going to use a paid service to try and accomplish my idea
     
    Mr.Bill, Apr 29, 2009 IP