var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
Hi, I'm using php and trying to detect if a person is using a proxy or not, anyone got any ideas how I can do this?
What do you mean by 'proxy'?
This really depends on your definition of 'proxy'. Do you mean an anonymous proxy service? If so, then you'd have to use some sort of GeoIP database to see if it's a known one.
If you mean "are they behind a corporate firewall/proxy" then the problem is a bit trickier.
Well, I just need to know if they're behind a proxy, not a firewall. I'm basically trying to detect if they're using fake traffic software or not.
Most proxies send X-Forwarded-for header, so you can check it. I use this code on my website:
That code will create 2 variables: $client_ip which is connection ip, and $forward_ip which is real ip of user.
$forward_ip = '';
$client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
$forward_ip = $client_ip;
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) || isset($_ENV['HTTP_X_FORWARDED_FOR']))
$fw = $_SERVER['HTTP_X_FORWARDED_FOR'];
$fw = $_ENV['HTTP_X_FORWARDED_FOR'];
if(preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $fw, $ip_list))
$private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10..*/', '/^224..*/', '/^240..*/');
$forward_ip = preg_replace($private_ip, $forward_ip, $ip_list);
CyberAlien approach is correct but they are proxy servers that don't send any of that headers.
You can use an online proxy checker to verify is some proxy server sends that headers or not. Then try using that proxy to visit your site and see if your script detects it.