Automatically identify IP and jump to the visitor's city
first go to the next pure IP database, and then do the following:
1. Run pure QQIP database with ShowIP.exe, point decompression, input file name, such as IP.txt, OK, get a txt file.
2. Open access, tools-Customize, Command tab, drag the Import options to the toolbar above.
3. Build a table, four fields
StartIP type: Text (IP segment information for related cities)
EndIP Type: Text (IP segment information for related cities)
Country type: text (related city name)
Reurl type: Text (You want to jump to the city path, such as: Beijing http://bj.abc.com)
4. Click to import button, file type select text file, find just exported IP.txt file, import to just build the table ~
operation will convert real IP to numbers, such as Beijing's IP segment is: 1.1.0.0-1.1.0.255
startip:1*256 *256*256+1*256*256+0*256+0 = 16842752 (this number is ultimately to be placed in the database)
endip:1*256*256*256+1*256*256+0*256+255 = 16843007 ( This number is ultimately to be put into the database in batch processing, if not, and no time (like me) you go directly to the next network IP library, it has been processed, the following is part of the program:
User_ip = Request.ServerVariables ("remote_addr") ' Get visitor IP
Userip_ary=split (user_ip, ".")
Tmp_userip=userip_ary (0) *256*256*256+userip_ary (1) *256*256+userip_ary (2) *256+userip_ary (3) "Convert IP to digital as required
&NBSP
Find the city where the user IP belongs from the database
Set Rs=server.createobject ("ADODB. Recordset ")
sql=" select * from IP where startip<= "&tmp_userip&" and endip>= "&tmp_userip
Rs.Open sql,conn,1,1
If rs.eof then
Response.Redirect "Index.asp" if the city or IP is not recognized, go to the front page, or you can specify the page
else
Response.Redirect rs ("Reurl") ' If you have to go to the specified page
End If
rs.close
Set rs=nothing
Place the above program in your virtual host default access page! or other pages. (Of course you also want to set the default access in the Virtual host Control Panel to this file first)