Whether php can obtain the user's intranet ip address from the internet. if the user connects to the Internet through a router or other devices, php can be used to obtain the intranet ip address of the user, that is, 198. xxx. xxx. ip address like xxx. This refers to access from Internet users, rather than obtaining the intranet where the server host is located! Ip ------ solution ------------ can php obtain the user's intranet ip address from the internet?
Assume that you can use php to obtain the intranet ip address of the user, that is, the ip address 198. xxx. This refers to access from Internet users, rather than obtaining the intranet where the server host is located!
Ip
------ Solution --------------------
You can try a function.
function getIP() {
if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if (@$_SERVER["HTTP_CLIENT_IP"])
$ip = $_SERVER["HTTP_CLIENT_IP"];
else if (@$_SERVER["REMOTE_ADDR"])
$ip = $_SERVER["REMOTE_ADDR"];
else if (@getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (@getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if (@getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknown";
return $ip;
}
------ Solution --------------------
Let's take a look at the tcp principle and you will know the reason.
------ Solution --------------------
Generally, this is not acceptable (unless the egress gateway of the intranet is set to "transparent gateway ")
But even if you know it, what does it mean?
You cannot access it from the server!
It's just like some people have to want to know the location of the files uploaded by the user on the user's machine.
Since it is impossible for you to access from outside, what is the purpose of knowing?
------ Solution --------------------
This is not a problem except for hacking the host of the other party.
------ Solution --------------------
Determine that an independent visitor can only use cookies
------ Solution --------------------
Independent visitors are judged by cookies + time.
A cookie is generated to the local device and then p3p is used.
Then calculate a uv every day from.