Detect if Client is behind a proxy
<?php
// http://stackoverflow.com/questions/858357/detect-clients-with-proxy-servers-via-php
// boolean coming empty: http://stackoverflow.com/questions/9042002/php-printed-boolean-value-is-empty-why
/*
A boolean can always be represented as a 1 or a 0, but that's not what you get when you convert it to a string.
If you want it to be represented as an integer, cast it to one: $intVar = (int) $boolVar;
A boolean TRUE value is converted to the string "1". Boolean FALSE is converted to "" (the empty string).
This allows conversion back and forth between boolean and string values.
*/
$value_proxy = (int)detectProxy() ;
// Detect if client is using a Proxy
if ( detectProxy() ) {
$client_proxy = 'Client is using a proxy';
}
else {
$client_proxy = 'Client is not using a proxy' ;
}
function detectProxy () {
$proxy_headers = array(
'HTTP_VIA',
'HTTP_X_FORWARDED_FOR',
'HTTP_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_FORWARDED',
'HTTP_CLIENT_IP',
'HTTP_FORWARDED_FOR_IP',
'VIA',
'X_FORWARDED_FOR',
'FORWARDED_FOR',
'X_FORWARDED',
'FORWARDED',
'CLIENT_IP',
'FORWARDED_FOR_IP',
'HTTP_PROXY_CONNECTION'
);
foreach($proxy_headers as $x){
if (isset($_SERVER[$x]))
return true;
}
return false;
}