%
Head()
dim aconn,aconnstr
aConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath & "data/ipaddress.mdb")
Set aconn = Server.CreateObject("ADODB.Connection")
aconn.open aconnstr
dim admin_flag
admin_flag="29"
If not Dvbbs.master or instr(","&session("flag")&",",",29,")=0 then
Errmsg=ErrMsg + "
本页面为管理员专用,请登录后进入。
您没有管理本页面的权限。"
dvbbs_error()
Else
Dim body
dim dadadas
Dim country,city,num
dim ip1,ip2,oldip1,oldip2
Dim esip,str1,sip,str2,str3,str4
dim s1,s21,s2,s31,s3,s4
set rs= server.createobject ("adodb.recordset")
Call main()
Footer()
End if
sub main()
%>
注意事项 |
如果需要添加IP数据来源请直接添加,如果添加的来源在数据库中已经存在,将提示您是否进行修改,数据库中尚没有的记录将直接添加,您也可以直接对现有的数据进行管理操作。 |
<%
if request("action") = "add" then
call addip()
elseif request("action")="edit" then
call editip()
elseif request("action")="savenew" then
call savenew()
elseif request("action")="savedit" then
call savedit()
elseif request("action")="del" then
call del()
elseif request("action")="query" then
call ipinfo()
elseif request("action")="upip" then
call upip()
elseif request("action")="saveip" then
call saveip()
else
call ipquery()
end if
response.write body
%>
<%
end sub
sub addip()
%>
<%
end sub
sub editip()
ip1=request("ip1")
ip2=request("ip2")
sql="select ip1,ip2,country,city from dv_address where ip1="&ip1&" and ip2="&ip2&""
rs.open sql,aconn,1,1
%>
<%
end sub
sub savenew()
if request.form("ip1")="" then
body="请填写IP地址! |
"
exit sub
end if
if request.form("ip2")="" then
body="请填写IP地址! |
"
exit sub
end if
if request.form("country")="" or request.form("city")="" then
body="国家和城市必须填写其一! |
"
exit sub
end if
ip1=enaddr(request.form("ip1"))
ip2=enaddr(request.form("ip2"))
country=request.form("country")
city=request.form("city")
sql="select ip1,ip2,country,city from dv_address where ip1<="&ip1&" and ip2>="&ip2&""
rs.open sql,aconn,1,3
if rs.eof and rs.bof then
rs.AddNew
rs("ip1")=ip1
rs("ip2")=ip2
rs("country")=country
rs("city")=city
rs.update
body="添加成功,请继续其他操作。 |
"
else
body="添加失败,数据已存在,请到搜索中搜索该ip地址并进行修改。 |
"
end if
rs.close
end sub
sub savedit()
oldip1=int(request.form("oldip1"))
oldip2=int(request.form("oldip2"))
ip1=enaddr(request.form("ip1"))
ip2=enaddr(request.form("ip2"))
country=request.form("country")
city=request.form("city")
sql="select ip1,ip2,country,city from dv_address where ip1="&oldip1&" and ip2="&oldip2&""
rs.open sql,aconn,1,3
if not(rs.eof and rs.bof) then
rs("ip1")=ip1
rs("ip2")=ip2
rs("country")=country
rs("city")=city
rs.update
body="IP地址修改成功! |
"
else
body="IP地址修改失败! |
"
end if
rs.close
end sub
sub del()
ip1=request("ip1")
ip2=request("ip2")
sql="delete from dv_address where ip1="&ip1&" and ip2="&ip2&""
aconn.Execute(sql)
body="删除成功,请继续其他操作。 |
"
end sub
sub ipinfo()
dim currentpage,page_count,Pcount
dim totalrec,endpage
currentPage=request("page")
if currentpage="" or not IsNumeric(currentpage) then
currentpage=1
else
currentpage=clng(currentpage)
if err then
currentpage=1
err.clear
end if
end if
country=trim(request("country"))
city=trim(request("city"))
if request("ip")="" and country="" and city="" then
sql="select ip1,ip2,country,city from dv_address order by ip1 desc,ip2 desc"
else
sql="select ip1,ip2,country,city from dv_address where "
if request("ip")<>"" then
num=enaddr(request("ip"))
sql = sql&" ip1 <="&num&" and ip2 >="&num&" order by ip1 desc,ip2 desc"
else
if country<>"" then sql=sql&" country like '%"&country&"%'"
if city<>"" then sql=sql&" city like '%"&city&"%'"
sql=sql&" order by ip1 desc,ip2 desc"
end if
end if
rs.open sql,aconn,1,1
if rs.eof and rs.bof then
call addip()
else
%>
IP 地址库搜索结果 |
<%
rs.PageSize = Cint(Dvbbs.Forum_Setting(11))
rs.AbsolutePage=currentpage
page_count=0
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = Cint(Dvbbs.Forum_Setting(11)))
%>
<%=deaddr(rs("ip1"))%> |
<%=deaddr(rs("ip2"))%> |
<%=rs("country")%> |
<%=rs("city")%> |
&ip2=<%=rs("ip2")%>">编辑|&ip2=<%=rs("ip2")%>">删除 |
<%
page_count = page_count + 1
rs.movenext
wend
%>
分页:
<%Pcount=rs.PageCount
if currentpage > 4 then
response.write "[1] ..."
end if
if Pcount>currentpage+3 then
endpage=currentpage+3
else
endpage=Pcount
end if
for i=currentpage-3 to endpage
if not i<1 then
if i = clng(currentpage) then
response.write " ["&i&"]"
else
response.write " ["&i&"]"
end if
end if
next
if currentpage+3 < Pcount then
response.write "... ["&Pcount&"]"
end if
%>
|
<%
end if
rs.close
end sub
sub ipquery()
%>
<%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
%>