Welcome to the Linux community forum and interact with 2 million technical staff to go to if ($ useripFlagchr (2) {$ AddrSeekfread ($ fd, 3); if (strlen ($ AddrSeek) 3) {fclose ($ fd); returnSystemError;} $ useripFlagfread ($ fd, 1); if
Welcome to the Linux community forum and interact with 2 million technical staff> go to if ($ useripFlag = chr (2) {$ AddrSeek = fread ($ fd, 3 ); if (strlen ($ AddrSeek) 3) {fclose ($ fd); return 'System error';} $ useripFlag = fread ($ fd, 1); if
Welcome to the Linux community forum and interact with 2 million technicians>
If ($ useripFlag = chr (2 )){
$ AddrSeek = fread ($ fd, 3 );
If (strlen ($ AddrSeek) <3 ){
Fclose ($ fd );
Return 'System error ';
}
$ UseripFlag = fread ($ fd, 1 );
If ($ useripFlag = chr (2 )){
$ AddrSeek2 = fread ($ fd, 3 );
If (strlen ($ AddrSeek2) <3 ){
Fclose ($ fd );
Return 'System error ';
}
$ AddrSeek2 = implode ('', unpack ('l', $ AddrSeek2. chr (0 )));
Fseek ($ fd, $ AddrSeek2 );
} Else {
Fseek ($ fd,-1, SEEK_CUR );
}
While ($ char = fread ($ fd, 1 ))! = Chr (0 ))
$ UseripAddr2. = $ char;
$ AddrSeek = implode ('', unpack ('l', $ AddrSeek. chr (0 )));
Fseek ($ fd, $ AddrSeek );
While ($ char = fread ($ fd, 1 ))! = Chr (0 ))
$ UseripAddr1. = $ char;
} Else {
Fseek ($ fd,-1, SEEK_CUR );
While ($ char = fread ($ fd, 1 ))! = Chr (0 ))
$ UseripAddr1. = $ char;
$ UseripFlag = fread ($ fd, 1 );
If ($ useripFlag = chr (2 )){
$ AddrSeek2 = fread ($ fd, 3 );
If (strlen ($ AddrSeek2) <3 ){
Fclose ($ fd );
Return 'System error ';
}
$ AddrSeek2 = implode ('', unpack ('l', $ AddrSeek2. chr (0 )));
Fseek ($ fd, $ AddrSeek2 );
} Else {
Fseek ($ fd,-1, SEEK_CUR );
}
While ($ char = fread ($ fd, 1 ))! = Chr (0 )){
$ UseripAddr2. = $ char;
}
}
Fclose ($ fd );
// Return the city result corresponding to the IP address
If (preg_match ('/http/I', $ useripAddr2 )){
$ UseripAddr2 = '';
}
$ Useripaddr = "$ useripAddr1 $ useripAddr2 ";
$ Useripaddr = preg_replace ('/CZ88.Net/is', '', $ useripaddr );
$ Useripaddr = preg_replace ('/^ s */is', '', $ useripaddr );
$ Useripaddr = preg_replace ('/s * $/is', '', $ useripaddr );
If (preg_match ('/http/I', $ useripaddr) | $ useripaddr = ''){
$ Useripaddr = 'no data ';
} Elseif (! $ This-> is_utf8 ($ useripaddr )){
$ Useripaddr = iconv ('gbk', 'utf-8', $ useripaddr );
}
Return $ useripaddr;
}
/**
* Determine whether my UTF-8 encoded string is used
* @ Param type $ string
* @ Return boolean
*/
Private function is_utf8 ($ string ){
If (preg_match ("/^ ([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {1}/", $ string) = true | preg_match ("/([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {1} $/", $ string) = true | preg_match ("/([". chr (1, 228 ). "-". chr (1, 233 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1 }[". chr (1, 128 ). "-". chr (1, 191 ). "] {1}) {2,}/", $ string) = true ){
Return true;
} Else {
Return false;
}
}
}
You can search for the QQWry. Dat file on Baidu or send it to your mailbox. I will send it to you via email.
Demo:
?
1
2
3
4 include FCPATH. 'In in/ipLocation/ipCity. class. php ';
$ City = new ipCity ();
$ Addr = $ city-> getCity ('2017. 0.0.1 ');
Echo $ addr; // echo local address
[1] [2]