-
Notifications
You must be signed in to change notification settings - Fork 0
/
iptest.php
44 lines (38 loc) · 1.05 KB
/
iptest.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html>
<meta charset="utf-8">
<body>
PHP代码:
<br>
if (getenv('HTTP_CLIENT_IP')) {<br>
$ip = getenv('HTTP_CLIENT_IP');<br>
}elseif (getenv('HTTP_X_FORWARDED_FOR')) {<br>
$ip = getenv('HTTP_X_FORWARDED_FOR');<br>
}elseif (getenv('HTTP_X_FORWARDED')) {<br>
$ip = getenv('HTTP_X_FORWARDED');<br>
}elseif (getenv('HTTP_FORWARDED_FOR')) {<br>
$ip = getenv('HTTP_FORWARDED_FOR');<br>
}elseif (getenv('HTTP_FORWARDED')) {<br>
$ip = getenv('HTTP_FORWARDED');<br>
}else {<br>
$ip = $_SERVER['REMOTE_ADDR'];<br>
}<br>
echo $ip;<br>
得到的结果:<br>
<?php
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
}elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
}elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
}elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
}else {
$ip = $_SERVER['REMOTE_ADDR'];
}
echo $ip;
?>
</body>
</html>