全球IP地址查询完整版[转帖] - 德化论坛

关键信息

作者
自由人
发布时间
2003-08-31

全球IP地址查询完整版1、 转wry.dll为.mdb由于我们要优化数据库(适合我们用的),建议这样做:将文件改为wry.xls用Excel打开。在Access中新建表IP字段名 类型 长度 说明----------------------------------------------------...

全球IP地址查询完整版[转帖] - 德化论坛

全球IP地址查询完整版

1、 转wry.dll为.mdb由于我们要优化数据库(适合我们用的),建议这样做:

将文件改为wry.xls用Excel打开。

在Access中新建表IP

字段名 类型 长度 说明

------------------------------------------------------------------------------------------------------------

id 自动编号

newid 数字 5 startip前三个数字

seconded 数字 5 startip第二部分三个数字

startip 文本 20 起始IP段

endip 文本 20 止 IP 段

country 文本 此段IP所在国家或省

local 文本 此段IP所在地

从Excel中copy startip/endip/country/local 四个字段至Access ,id会自动添加,对于newid和secondid当然我们不可能手工添加,可以这样实现。

<!--#include file="dbpath.asp"-->

<%

sqlcmd="select * from ip"

‘建议使用sqlcmd="select * from ipwhere id>=值1 and id<值2" ,因为对于一万个左右的数据一下子添加资源占用很大

set rs=ip.execute(sqlcmd)

do while not rs.eof

fir=left(rs("startip"),3)

sec=mid(rs("startip"),5,3)

sqlcmd3="update ip set newid=′"&str&"′,secondid=′"sec"′ "

ip.execute sqlcmd3

rs.movenext

loop

%>

这样就完成数据库的修改,对于dbpath.asp 文件下面讲

2、 文件介绍

本程序分 dbpath.asp 和 search.asp

以下是源程序及简要描述

Dbpath.Asp 代码如下:(本人命名数据库名字为ip.mdb)

<%@ Language=VBScript %>

<% set ip=server.createobject("ADODB.CONNECTION")

ip.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("ip.mdb") %>

search.asp 代码如下:

<!--#include file="dbpath.asp"-->

<%

′ Write by 尥蹶子

′ If you find some error or you have better idea

′ Please contact me

′ My Email: jz811@163.co Oicq:30763914

%>

<%

′建立一个提交的表单

%>

<BODY bgColor=azure>

<P align=center>IP查询<BR><BR><BR>

<FORM action="index.asp" method=post id=form1 name=form1>

<font size=2>输入IP:</font><INPUT id=text1 name=putip

style ="BACKGROUND-COLOR: lavender; HEIGHT: 22px; WIDTH: 182px" >

<INPUT id=submit1 name=sub1 style="BACKGROUND-COLOR: lightblue; FONT-SIZE: 12" type=submit value="我查" tabindex="0">

</FORM>

<%

userip=Request.ServerVariables ("REMOTE_ADDR")

listip=trim(request("putip"))

if listip="" or listip=" " then

Response.Write "<p align=center><font size=2>请输入IP地址!</font></p>"

else

′---判断访问者的IP是否与输入的ip同

cmp=strcomp(userip,listip,1)

if cmp=0 then %>

<p align=center><font size=2 >这就是你自己呀!</p>

<%

else

′获得输入ip的第1段,并置3位

num1=Instr(listip,".")

′判断第一段是否正确

if mun1=1 then

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

fir=0&fir

fir=0&fir

end if

′获得输入ip的第2段,并置3位

num2=Instr(num1+1,listip,".")

sec=mid(listip,num1+1,num2-(num1+1))

if len(sec)=2 then

sec=0&sec

end if

if len(sec)=1 then

sec=0&sec

sec=0&sec

end if

′获得输入ip的第3段,并置3位

num3=Instr(num2+1,listip,".")

thr=mid(listip,num2+1,num3-(num2+1))

if len(thr)=2 then

thr=0&thr

end if

if len(thr)=1 then

thr=0&thr

全球IP地址查询完整版[转帖] - 德化论坛

憨鼠网(原德化网) · Hanshu · 福建省泉州市德化县