1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Preventing Proxy Site Access

Discussion in 'PHP & Perl' started by istarapol, Nov 27, 2008.

  1. istarapol

    istarapol Junior Member

    Joined:
    Jun 3, 2008
    Messages:
    110
    Likes Received:
    228
    Occupation:
    Graphic Designer
    Location:
    Under Your Bed
    Home Page:
    Hi!

    I'd like to know how to prevent proxy sites to access my blog/site.
    I mean if a user uses proxy site like
    Code:
    www.atunnel.com
    my site will deny the
    connection or redirect this to another page. Using HTACCESS, php or perl

    I've tried this on HTACCESS

    Code:
    order allow,deny
    deny from *.atunnel.*
    deny from 67.159.46.12
    deny from 67.159.*.*
    deny from ztunnel.com
    allow from all
    to no avail, I'm thinking a php will work for this process.

    Can someone help?

    Thanks in advance :)
     
    Last edited: Nov 27, 2008
  2. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Without trying it, you could do it in PHP:

    PHP:
    <?php
     $visitor 
    $_SERVER['REMOTE_ADDR']; 
     if((
    $visitor "67.159.44.97") || ($visitor "67.159.45.53"))
     {
        
    header("Location: http://where.you.want.proxy.user.to.go");
     }
     else
     {
        
    header("Location: http://your.real.page
     }
    ?>
    There is a more elegant way of doing it as well if you want me to put it up later when I get 10 mins to get all the code sorted :)
     
  3. istarapol

    istarapol Junior Member

    Joined:
    Jun 3, 2008
    Messages:
    110
    Likes Received:
    228
    Occupation:
    Graphic Designer
    Location:
    Under Your Bed
    Home Page:
    hi fatboy.

    Im getting an error

    Warning: Cannot modify header information - headers already sent by (output started at /home/richjrk/public_html/*****/mryr/index.php on line 5
     
  4. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Are you printing anything else to the screen before you use that bit of code?

    That just means that something is being sent to the display before my bit of code can redirect them.

    I will be away for an hour or so but feel free to shout if you are still having probs
     
  5. thanhclix

    thanhclix Power Member

    Joined:
    Oct 25, 2008
    Messages:
    646
    Likes Received:
    176
    Put a simple code at the top of the page :
    Code:
    <?php
    ob_start();
    ?>
    
     
  6. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    Just as a test - comment out the ob_start and then try it - does it work?
     
    • Thanks Thanks x 1
  7. istarapol

    istarapol Junior Member

    Joined:
    Jun 3, 2008
    Messages:
    110
    Likes Received:
    228
    Occupation:
    Graphic Designer
    Location:
    Under Your Bed
    Home Page:
    hi fatboy, actually both didnt work... :(
     
  8. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    OK - give me some time this evening and I will actually code it up on my box to test it :)
     
  9. ortal

    ortal Junior Member

    Joined:
    May 27, 2008
    Messages:
    106
    Likes Received:
    10
    remove every space before the "<?"
    it's a well knowm bug