全球IP地址查询完整版
数据库的设计在一个软件中的比例,毫不夸张的说占60%,虽然这是一个小的程式,但也得到一定的体现。
有任何错误或建议请一定要给我发E-mail: ljz811@ ,我也不了解“追捕”等类似算法,欢迎交流,谢谢!
好了废话少说,开始吧。
1、 转wry.dll为.mdb由于我们要优化数据库(适合我们用的),建议这样做:
Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >非有效的IP地址,IP每段必须1~3位!</p>"
else
fir=left(listip,num1-1)
if len(fir)=2 then
fir=0&fir
end if
if len(fir)=1 then
ip.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("ip.mdb") %>
search.asp 代码如下:
<!--#include file="dbpath.asp"-->
<%
´ Write by 尥蹶子
<INPUT id=submit1 name=sub1 style="BACKGROUND-COLOR: lightblue; FONT-SIZE: 12" type=submit value="我查" tabindex="0">
</FORM>
<%
userip=Request.ServerVariables ("REMOTE_ADDR")
if rs.eof then
%>
<br><br><font size="2"><P align=center><%=listip%><br>★未知IP数据★<BR>如果你知道请告诉我!OICQ:30763914 谢谢!<BR>=尥蹶子=</font></P>
<% else
do while not rs.eof
<!--#include file="dbpath.asp"-->
<%
sqlcmd="select * from ip"
‘建议使用sqlcmd="select * from ipwhere id>=值1 and id<值2" ,因为对于一万个左右的数据一下子添加资源占用很大
set rs=ip.execute(sqlcmd)
<%
end if
end if%>
<%end if%>
<%end if%>
<%end if%>
<%end if%><%end if%>
</BODY>
</HTML>
if sql.RecordCount = 1 then
sql.Close
sqlcmd2="select id,startip,endip,country,local from ip where id<9904 and newid="&fir&" and secondid="&sec&" order by id desc"
thr=0&thr
thr=0&thr
end if
´获得输入ip的第4段,并置3位
fou=right(listip,len(listip)-num3)
if len(fou)=2 then
fou=0&fou
end if
if len(fou)=1 then
fou=0&fou
fou=0&fou
end if
´判断是否为有效IP
<br><br><font size="2"><P align=center><%=listip%><br>★未知IP数据★<BR>如果你知道请告诉我!OICQ:30763914 谢谢!<BR>=尥蹶子=</font></P>
<%
end if
rs.movenext
loop
end if
end if
%>
Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >Internet IP地址输入值不正确!</p>"
else
´查询IP地址数据库
Set sql= Server.CreateObject("ADODB.Recordset")
rs1="select id,startip,endip,country,local from ip where id<9904 and newid="&fir&" and secondid="&sec&" "
sql.open rs1,ip,1,1
´对于类似224.000.000.000~224.255.255.255的ip地址进行处理
将文件改为wry.xls用Excel打开。
在Access中新建表IP
字段名 类型 长度 说明
------------------------------------------------------------------------------------------------------------
listip=trim(request("putip"))
if listip="" or listip=" " then
Response.Write "<p align=center><font size=2>请输入IP地址!</font></p>"
else
´---判断访问者的IP是否与输入的ip同
else
´判断是否为保留地址
if ((fir>=0) and (fir<= 2)) or ((fir>=58) and (fir<=60)) or ((fir>=67) and (fir<=126)) then
Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >Internet IP保留地址!</p>"
loop
%>
这样就完成数据库的修改,对于dbpath.asp 文件下面讲
2、 文件介绍
本程序分 dbpath.asp 和 search.asp
以下是源程序及简要描述
Dbpath.Asp 代码如下:(本人命名数据库名字为ip.mdb)
<%@ Language=VBScript %>
<% set ip=server.createobject("ADODB.CONNECTION")
if len(fir)=0 or len(fir)>3 or len(sec)=0 or len(sec)>3 or len(thr)=0 or len(thr)>3 or len(fou)=0 or len(fou)>3 then
Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >非有效的IP地址,IP每段必须1~3位!</p>"
set rs=ip.execute(sqlcmd2)
else
sqlcmd2="select id,startip,endip,country,local from ip where id<9904 and newid="&fir&" order by id desc"
set rs=ip.execute(sqlcmd2)
全球IP地址查询完整版
全球IP地址查询完整版
突然在某某网站看到IP地址查询,于是心血来潮做了一个。这是用asp查询全球IP地址的程式,由于类似的的用Asp查询IP的速度不是很理想,本人使用的也是宏志宏的IP地址数据库,只是对它进行了改进。
本人在 win98+pws+access2000上测试通过,效果比较理想。
do while not rs.eof
fir=left(rs("startip"),3)
sec=mid(rs("startip"),5,3)
sqlcmd3="update ip set newid=´"&str&"´,secondid=´"sec"´ "