IP: 113. 83. ***. ** return status: 1IP range: Strat: 113.83.0.0IP range: End: 113.83.20.255 country: Chinese province: Guangdong city: Huizhou district/county: line: Telecom type: Description: [PHP] code 01/*** get client + server IP address and geographic location information Sinai... "> <LINKhref =" http ://
IP: 113. 83 .***.**
Returned status: 1
IP address range: Strat: 113.83.0.0
IP address range: End: 113.83.255.255
Country: China
Province: Guangdong
City: Huizhou
District/county:
Line: China Telecom
Type:
Description: [PHP] code
02 |
* Obtain the client + server IP address and geographic location information Sina iplookup |
04 |
* @ Support: QQ 910111100 (JoY) |
05 |
* @ Time: 2012.10.11 15:50:00 |
06 |
* @ HZapi.com (http://www.php100.com /) |
09 |
// Obtain geographic location information |
10 |
Function iplookup ($ ip = 1 ){ |
12 |
$ Userip = egetip_joy (); // client IP address |
14 |
$ Domain = $ _ SERVER ['http _ host']; |
15 |
$ Userip = gethostbyname ($ domain ); |
17 |
// Returns the location information of Sina. |
18 |
$ Json = @ file_get_contents ('http: // int.dpool.sina.com.cn/iplookup/iplookup.php? Format = js & ip = '. $ userip ); |
19 |
$ Patterns = array (); |
20 |
$ Patterns [0] = '/var remote_ip_info = /'; |
21 |
$ Patterns [1] = '/;/'; |
22 |
$ Patterns [2] = '/\ Wu /'; |
27 |
$ Json = preg_replace ($ patterns, $ find, $ json); // filter extra characters |
28 |
$ Json_arr = json_decode ($ json, true ); |
31 |
// Obtain the IP address |
32 |
Function egetip_joy (){ |
33 |
If (getenv ('http _ CLIENT_IP ') & strcasecmp (getenv ('http _ CLIENT_IP'), 'Unknown ')) |
35 |
$ Ip = getenv ('http _ CLIENT_IP '); |
37 |
Elseif (getenv ('http _ X_FORWARDED_FOR ') & strcasecmp (getenv ('http _ X_FORWARDED_FOR'), 'Unknown ')) |
39 |
$ Ip = getenv ('http _ X_FORWARDED_FOR '); |
41 |
Elseif (getenv ('remote _ ADDR ') & strcasecmp (getenv ('remote _ ADDR'), 'Unknown ')) |
43 |
$ Ip = getenv ('remote _ ADDR '); |
45 |
Elseif (isset ($ _ SERVER ['remote _ ADDR ']) & $ _ SERVER ['remote _ ADDR '] & strcasecmp ($ _ SERVER ['remote _ ADDR'], 'Unknown ')) |
47 |
$ Ip = $ _ SERVER ['remote _ ADDR ']; |
49 |
$ Ip = preg_replace ("/^ ([d.] +). */", "1", $ ip ); |
53 |
* Simulate unescape in JS |
55 |
* @ Support: QQ 910111100 (JoY) |
56 |
* @ Time: 2012.09.29 15:50:00 |
57 |
* @ HZapi.com (http://www.hzapi.com /) |
58 |
* Echo unescape ('% u4e1c % u6e56 % u82b1 % u56ed4 % u53f7 % u5c0f % u533a '); |
60 |
Function unescape ($ str ){ |
61 |
$ Str = rawurldecode ($ str ); |
62 |
Preg_match_all ("/(? : % U. {4}) |. {4}; | & # \ d +; |. +/U ", $ str, $ r ); |
64 |
Foreach ($ ar as $ k => $ v ){ |
65 |
If (substr ($ v, 0, 2) = "% u ") |
67 |
$ Ar [$ k] = iconv ("UCS-2", "UTF-8 // IGNORE", pack ("H4", substr ($ v,-4 ))); |
69 |
Elseif (substr ($ v, 0, 3) = "") |
71 |
$ Ar [$ k] = iconv ("UCS-2", "UTF-8", pack ("H4", substr ($ v, 3,-1 ))); |
73 |
Elseif (substr ($ v, 0, 2) = "&#") |
75 |
Echo substr ($ v, 2,-1 ).""; |
76 |
$ Ar [$ k] = iconv ("UCS-2", "UTF-8", pack ("n", substr ($ v, 2,-1 ))); |
79 |
Return join ("", $ ar ); |
83 |
$ Iplookup = iplookup (); // The parameter iplookup (1) is not empty. |
85 |
Echo "IP:". egetip_joy ()." "; |
86 |
Echo 'return status: '. $ iplookup ['ret']." "; |
87 |
Echo 'IP range Strat: '. $ iplookup ['start']." "; |
88 |
Echo 'IP range End: '. $ iplookup ['end']." "; |
89 |
Echo 'Country: '. unescape ($ iplookup ['country'])." "; |
90 |
Echo 'Province: '. unescape ($ iplookup ['Province'])." "; |
91 |
Echo 'City: '. unescape ($ iplookup ['city'])." "; |
92 |
Echo 'district/county:'. unescape ($ iplookup ['District '])." "; |
93 |
Echo 'line: '. unescape ($ iplookup ['isp'])." "; |
94 |
Echo 'type: '. $ iplookup ['type']." "; |
95 |
Echo description: '. $ iplookup ['desc']." "; |
96 |
// Print_r ($ iplookup ); |