<%
dim ipname,iptable,TCONN
ipname=Checkstr(trim(request("ipname")))
iptable=Checkstr(trim(request.form("iptable")))
if ipname="" then
ErrMsg=ErrMsg+" "+"请填写导入的数据库名"
response.write Errmsg
exit sub
end if
if iptable="" then
ErrMsg=ErrMsg+" "+"请填写导入的IP库表名"
response.write Errmsg
exit sub
end if
'删除旧的IP数据
conn.execute("delete from address")
'*************************************
'取出新的数据进行更新
'*************************************
'on error resume next
Set tconn = Server.CreateObject("ADODB.Connection")
tconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(ipname)
dim trs,nrs
set trs=tconn.execute(" select * from "&iptable&" ")
do while not trs.eof
conn.execute("insert into address (ip1,ip2,country,city) values ('"&trs("ip1")&"','"&trs("ip2")&"','"&trs("country")&"','"&trs("city")&"')")
trs.movenext
loop
trs.close
set trs=nothing
if err.number<>0 then
ErrMsg=ErrMsg+" "+"数据库操作失败,请以后再试,"&err.Description
err.clear
response.write Errmsg
exit sub
else
response.write "数据导入成功! "
end if
%> |
<%
end sub%>
<%
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
function deaddr(sip)
sip=sip+1
s1=int(sip/256/256/256)
s21=s1*256*256*256
s2=int((sip-s21)/256/256)
s31=s2*256*256+s21
s3=int((sip-s31)/256)
s4=sip-s3*256-s31
deaddr=cstr(s1)+"."+cstr(s2)+"."+cstr(s3)+"."+cstr(s4)
end function
%>