突然在某某网站看到IP地址查询,于是心血来潮做了一个。这是用asp查询全球IP地址的程式,由于类似的的用Asp查询IP的速度不是很理想,本人使用的也是宏志宏的IP地址数据库,只是对它进行了改进。

本人在 win98+pws+access(小型网站之最爱)2000上测试通过,效果比较理想。

数据库的设计在一个软件中的比例,毫不夸张的说占60%,虽然这是一个小的程式,但也得到一定的体现。

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: ljz811@163.com    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:<INPUT id=text1 name=putip

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

<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地址!

"
else

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

cmp=strcomp(userip,listip,1)

if cmp=0 then %>

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

<%

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位!

"

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

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

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位!

"

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保留地址!

"

else

'判断是否为分配地址

if (fir>=219 and fir<=223) or fir=225 then

Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >此IP地址尚未分配!

"

else

if fir>255 or fir<0 or sec>255 or sec<0 or thr>255 or thr<0 or fou>255 or fou<0 then

Response.Write "<p align=center>"&listip&"<br>"&" <font size=2 >Internet IP地址输入值不正确!

"

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地址进行处理

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"

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)

if rs.eof then

%>

<br><br><font size="2"><P align=center><%=listip%><br>★未知IP数据★<BR>如果你知道请告诉我!OICQ:30763914 谢谢!<BR>=尥蹶子=</P>
<% else

do while not rs.eof

'*******处理country or local为空的情况,使用了按id倒排(why?因为根据IP地址表可知,先列大地区的ip段,例如先列出欧洲的062.000.000.000~062.255.255.255,再列英国等IP段)

'对后面三段IP进行处理,是否在IP表内

if (sec>=(mid(rs("startip"),5,3)) and (sec<=mid(rs("endip"),5,3))) and (thr>=(mid(rs("startip"),9,3)) and (thr<=mid(rs("endip"),9,3))) and (fou>=(mid(rs("startip"),13,3)) and (fou<=mid(rs("endip"),13,3))) then

%>

<center><font size=2><%=listip%><br><%=rs("country")%>&nbsp;&nbsp;<%=rs("local")%></center>

<%

'若查到数据,马上跳出以免占用资源

exit do

else

end if

if rs.eof then

'如果没有打出提示

%>

<br><br><font size="2"><P align=center><%=listip%><br>★未知IP数据★<BR>如果你知道请告诉我!OICQ:30763914 谢谢!<BR>=尥蹶子=</P>

<%

end if

rs.movenext

loop

end if

end if

%>

<%

end if

end if%>

<%end if%>

<%end if%>

<%end if%>

<%end if%><%end if%>

</BODY>

</HTML>

全球IP地址查询完整版相关推荐

  1. 计算机主机ip地址题,(完整版)IP地址划分测试题

    1.你的网络使用B类IP地址,子网掩码是255.255.224.0,请问通常可以设定多少个子网? A.14 B.7 C.9 D.6 2的3三次方减2 2.用户需要在一个C类地址中划分子网,其中一个子网 ...

  2. 全球IP地址数周内用完,或现无法上网情况

    "互联网之父"文顿瑟夫 与公路交通网类似,互联网也会拥堵.由于互联网必须给任何接驳入网络的终端分配独享IP地址,随着网络终端多样化,互联网IP地址分配压力越来越大. 切莫认为一个网 ...

  3. 实现调用阿里云API第二章——API调用实战(全球IP地址归属地查询)

    本篇将实现利用springboot实现阿里云API调用实战. 一.购买阿里云API https://market.aliyun.com/data?spm=5176.9502607.1387859.3. ...

  4. 通过Ip查询对应地址,Ip2location全球IP地址网段

    通过Ip查询对应地址,Ip2location全球IP地址网段 1. Ip2location介绍 Ip2location IP 库 是比较准确的 在 免费查询IP 行列, 有很多的地址段, 有 Ip 详 ...

  5. 全球IP归属地查询 IP地址查询

    全球IP归属地查询 IP地址查询 推荐一个非常简单的全球IP归属地查询 IP地址查询接口,只需要传入要查询的IP,即可返回相应的基本信息,以下是演示 请求地址是:http://ip.wyk-super ...

  6. java webservice ip_通过Web Service实现IP地址查询功能的示例

    实例01 实现一个简单的Web服务访问 本实例将实现IP地址查询接口服务,根据用户传入的IP地址返回IP所在的省.市.地区,实例中将会用到IP地址库用于查询信息,由于数据较多,所以读者可在光盘资源文件 ...

  7. 通过Web Service实现IP地址查询功能

    实例01  实现一个简单的Web服务访问 本实例将实现IP地址查询接口服务,根据用户传入的IP地址返回IP所在的省.市.地区,实例中将会用到IP地址库用于查询信息,由于数据较多,所以读者可在光盘资源文 ...

  8. Ip-adress.com:国际IP地址查询工具

    以前经常使用ip38.com来查询IP地址对应的地理位置,服务简单但很实用,不过查询国外的IP就有些吃力了.而IP-a d dress.com可以查询全球的IP地址,并且精确定位到该IP的国家.城市, ...

  9. 远程终端IP地址查询助手

    最近配置网桥,如果忘了网桥的地址,是一件很麻烦的事情.总是要试每个网桥的地址.想着开发一个查询IP助手,可以省很多的事,就试了试了试网络编程和程序打包的方法,花了一天时间做出来一个IP查询助手,速度不 ...

最新文章

  1. 目前常用的服务器端网络操作系统有,目前常用的服务器端网络操作系统是()。...
  2. LBS突围:从微信到微博
  3. 开发教程(四) MIP组件平台使用说明
  4. mysql触发器如果某个字段被修改_mysql trigger触发器 一张表一个字段改变 更新另一张表对应字段...
  5. window 下Qt for android 环境搭建
  6. 程序编码应保持良好的规范(C#)
  7. MyEclipse的Debug模式
  8. 模块简介与matplotlib基础
  9. 在C / C ++中使用INT_MAX和INT_MIN
  10. CAD 图层颜色更换程序-VLISP源码(免开图层控制中心)
  11. python分析数据走势图_python数据分析-11数据分析实战案例
  12. 蚂蚁金融NLP竞赛——文本语义相似度赛题总结
  13. 我们这么努力到底为了什么
  14. 探索Whisper语音识别
  15. java念整数 你的程序要读入一个整数,范围是[-100000,100000]。然后,用汉语拼音将这个整数的每一位输出出来。 如输入1234,则输出: yi er san si
  16. 调试 GPS 1.575G干扰无法搜星问题
  17. 量化投资之宏观篇 | 达里欧谈美国社会的矛盾及如何改良
  18. 单相半波可控整流电路仿真设计(任务书+lunwen+MATLAB仿真源文件)
  19. v模拟器(华为、H3C)点滴
  20. vue 富文本编辑器 quill (含代码高亮、自定义字体、汉化、鼠标悬浮提示、组件封装等)

热门文章

  1. 设置video标签的默认样式
  2. 多亏它,让大家做好“山竹”来袭的准备「Make It Real故事汇」
  3. ubuntu14英文系统无法输入中文
  4. JavaSE(08)-Java包机制+Doc生成文档
  5. 关闭shift中英文切换 英文代码/中文注释随意切换着写。
  6. 零跑汽车引领汽车概念股集体向上,市场信心彻底恢复了吗?
  7. msi文件安装mysql_msi文件安装MySQL
  8. 用expat解析xml文件c++
  9. 常用的javascript事件大全
  10. Python爬虫实战:极客学院