纯真ip数据库转动网数据库ASP脚本
第三步:新建一个MDB文件,命名为ipaddress.mdb,点击打开,使用Access提供的导入文本文件的功能,把刚才导出的ipaddress.txt导入到数据库中。
<%
Server.ScriptTimeOut=999
min=0 ''开始数
max=260262''结束数 数据数量-1
Dim Conn
Set COnn= Server.CreateObject("ADODB.Connection")
Conn.COnnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=01;Data Source="& Server.MapPath("ipaddress.mdb")
Conn.Open
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write("
")
Response.End
End If
set rs=conn.execute("select * from [ipaddress]")
if not rs.eof then
first=rs.GetRows()
for j=0 to 261501
z=""
local=""
for i=0 to 16
if len(first(i,j))>0 then
z=first(i,j)&"$$"&z
end if
next
zz=split(z,"$$")
startip=enaddr(zz(ubound(zz)-1))
endip=enaddr(zz(ubound(zz)-2))
country=zz(ubound(zz)-3)
for zzz=0 to ubound(zz)-4
local=zz(zzz)&" "&local
next
local=replace(local,"'","''")
'response.write "startip:"&startip&"
endip:"&endip&"
country:"&country&"
local:"&local&"
"
conn.execute("insert into [ipaddress2] (ip1,ip2,country,[city]) values ("&startip&","&endip&",'"&country&"','"&local&"')")
next
end if
conn.execute("update [ipaddress2] set [city]='--' where [city]='CZ88.NET' ")
response.write "升级成功!"
function enaddr(sip)
esip=cstr(sip)
str1=Left(sip,CInt(InStr(sip,".")-1))
sip=Mid(sip,cint(instr(sip,"."))+1)
str2=Left(sip,cint(instr(sip,"."))-1)
sip=mid(sip,cint(instr(sip,"."))+1)
str3=left(sip,cint(instr(sip,"."))-1)
str4=mid(sip,cint(instr(sip,"."))+1)
enaddr=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
end function
%>