-
Notifications
You must be signed in to change notification settings - Fork 77
/
ip.php
26 lines (24 loc) · 595 Bytes
/
ip.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
function getIP() /*获取客户端IP*/
{
if(@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
elseif(@$_SERVER["HTTP_CLIENT_IP"])
$ip = $_SERVER["HTTP_CLIENT_IP"];
elseif(@$_SERVER["REMOTE_ADDR"])
$ip = $_SERVER["REMOTE_ADDR"];
elseif(@getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
elseif(@getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
elseif(@getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknown";
return$ip;
}
$ip=getIP();
echo "{\"ip_addr\": \"$ip\"}";
header('Content-Type: application/json');
exit;
?>