Is any method is available which through we can determine that our current connection is through internet Or intranet using php script.
Thanks.....
Is any method is available which through we can determine that our current connection is through internet Or intranet using php script.
Thanks.....
You can use $_SERVER["HTTP_HOST"]
variable to obtain if it is localhost
or other IP address.
You could check $_SERVER['SERVER_ADDR'] against $_SERVER['REMOTE_ADDR'] If the first number of the IP is the same and is 192,172,10 or 127 then it is most likely an intranet page.
like this:
function is_intranet() {
$serverIP = explode('.',$_SERVER['SERVER_ADDR']);
$localIP = explode('.',$_SERVER['REMOTE_ADDR']);
return (
($serverIP[0] == $localIP[0]) &&
(in_array($serverIP[0],array('127','10','172','192') ) )
);
}
this can be improved upon a bit using the rules here: http://en.wikipedia.org/wiki/Private_network