PHP and proxy visits
Sometimes is important for you to know if your website visitor is accessing trough a proxy. One of my projects is an url shortner that gives analytics and, definitely, that is important.
When you realize that your visitor is using a proxy to hide himself and cheat the statistics, you can stop him from accessing your url or just ignore his visit on analysis… The last one is what I prefer.
Bruno Bertolini sent me a post called Block Tough Proxies and it helps me discovering who came from a proxy like hidemyass.com, in a very simple way:
<?php if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1))
die("Proxy access not allowed"); ?>
In the code above, the visitor can not see the site. You can change this behavior with a different logic after the if statement.
The post shows how to block with .htaccess too, but PHP is more effective in this case.
