Forum Moderators: coopster
and i've been hunting around for a simple little PHP script which blocks proxys. and they are pretty hard to find. the only ones out there don't do much.
but i reckon i've got one that finally does the job.
it will defeat a proxy which sticks your url on the end of it's own (with something like
http://www.nastyproxy.com/index.php?page=http://www.yoursite.com just stick this at the top of all your pages...
<?php //this bit blocks VERY basic proxy servers, and translation services if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){ header('HTTP/1.1 503 Service Unavailable');print("<html><head>\n"); print("<title>Error</title>\n");print("</head><body>\n"); print("<p>This page has been left intentionally blank.</p>\n"); print("</body></html>\n");exit;} //this bit blocks generated URLs containing the phrase =http if(stristr($_SERVER['REQUEST_URI'],'=http')){ header('HTTP/1.1 503 Service Unavailable');print("<html><head>\n"); print("<title>Error</title>\n");print("</head><body>\n"); print("<p>This page has been left intentionally blank.</p>\n"); print("</body></html>\n");exit;} //this bit blocks proxies that alter the URL so your sitename doesn't appear //but i included localhost so it still works on your testing server if((!stristr($_SERVER['REQUEST_URI'],'localhost'))¦¦(!stristr($_SERVER['REQUEST_URI'],'your-sitename'))){ return;}else{ header('HTTP/1.1 503 Service Unavailable');print("<html><head>\n"); print("<title>Error</title>\n");print("</head><body>\n"); print("<p>This page has been left intentionally blank.</p>\n"); print("</body></html>\n");exit;} ?> remember to change the broken pipes for full pipes, because this forum changes them when you post
[edited by: londrum at 11:35 pm (utc) on Dec. 8, 2007]
But that is not the request passed to your site, as unless you also operate www.nastyproxy then you have no control over their url's. They are using the $_GET['page'] to redirect to your site and passing you a valid url.
The $_SERVER['REQUEST_URI'] will contain something like '/' or '/some_page.php'. So you cant search for '=http', 'localhost', or 'your_site' in there.
The $_SERVER['HTTP_REFERER'] would be a good place to start, although this is often blank or spoofed.
Its an interesting problem. So im going to have a think and will let you know if I have any inspiration. Although I suspect that there is no easy answer, that will actually work in the majority of cases.