We use the following function to automatically detect if we are on a machine inside or on a real server, and then we select the appropriate configurations for the various components:
function devIsLocal(){ $res=false; $http_host=$_SERVER['HTTP_HOST']; if($http_host=='localhost')$res=true; if($http_host=='127.0.0.1')$res=true; if(substr($http_host,-4)=='.lan')$res=true; if(strpos($http_host, '.')===false)$res=true; return($res); }
As you can see, it depends only on the value of HTTP_HOST.
Of course, if you use some kind of virtual host locally, for example example.com, then the function will be tricked.
Are there other ways to trick a function? and what other variables / places could we look to determine where we are?
php development-environment production-environment autodiscovery
zaf
source share