The IP source address query function is used in the project. After searching for a free IP address database on the Internet, you can directly use the ip138 website as the data source, you can directly use PHP code to Query IP information, analyze the web page to obtain the address, and insert it to the database.
$ Content = iconv ("gb2312", "UTF-8", file_get_contents ("http://www.ip138.com/ips8.asp? Action = 2 & IP = $ IP "); var_dump ($ content); $ Pos = strpos ($ content," <li> master data of this site "); echo "starting position $ POS </BR>"; if (! $ POS) {hi_logerr ("no IP address found! "); Echo" error </BR> "; return false;} $ endpos = stripos ($ content," </LI> ", $ POS ); $ jumplen = strlen ("<li> main site data:"); $ address = substr ($ content, $ POS + $ jumplen, $ endpos-$ pos-$ jumplen ); $ SQL = "insert into 'ipmap' ('IP', 'from', 'updatetime') values ('$ c_ip',' $ address', current_timestamp )";