纯ASP(VBscript)写的全球IP地址搜索程序(2)
发布时间:2007-09-27 13:28:00
标签:ip,搜索,asp
re1.global=false
re1.Ignorecase=false
checkiplocal=re1.test(checkstring)
set re1=nothing
end function
function checkip_remote(checkstring)
dim iplength ’IP字符串的长度
dim locations ’"."字符出现的位置
iplength=Len(checksting)
locations=Instr(checkstring,".") ’从左到右检索“.”符号在IP字符串中第一次出现的位置
’以“.”字符将IP分割为4段
locations2=iplength-locations
ipstring1=Left(checkstring,locations)
ipstring2=Right(checkstring,locations2)
end function
ipinfo_local="您的IP是内部网IP!"
ipinfo_remote="外部网IP!"
getip=checkip_trueip()
currentip=checkiplocal(getip) ’调用checkiplocal()函数对得到的IP进行检查,确定是内部网地址还是外部网地址
’if currentip=true then’测试代码
’response.Write(ipinfo_local)
if currentip=true then ’为假
response.Write(ipinfo_local)’说明为内部网IP
else
’进行转换
’以下为循环提取并按位补0将IP分为4段
locations=checkip_locations(getip)’取得“.”在第一次分割前在IP中第一次出现的位置
iplength=Len(getip) ’取得客户端IP的长度
divide_locations=iplength-locations ’取得将客户端IP从右向左数到IP从左往右数第一个“.”的位置
ipstr1=Trim(Replace(Left(getip,locations),".",""))
ipstr2=Right(getip,divide_locations)’取得第一次分割后客户端右边剩下的数值
’如果IP分为4段后每一段不足3位则补0
if Len(ipstr1)="2" then ipstr1="0"&ipstr1 ’长度为二,不足三位,在字符串之前补一个0
if Len(ipstr1)="3" then ipstr1=ipstr1 ’据上类推
if Len(ipstr1)="1" then ipstr1="00"&ipstr1 ’这时的ipstr1为IP的第一段
ipstr12=checkip_right(ipstr2) ’这时的ipstr12为IP的第二段
ipstr122=checkip_left(ipstr2)
ipstr13=checkip_right(ipstr122) ’这时的ipstr13为IP的第三段
ipstr14=checkip_left(ipstr122) ’这时的ipstr14为IP的第四段
if Len(ipstr14)="1" then ipstr14="00"&ipstr14 ’对得到的IP的第四段进行补0,此步骤可不要
if Len(ipstr14)="2" then ipstr14="0"&ipstr14
if Len(ipstr14)="3" then ipstr14=ipstr14
’response.write ipstr1&"<br>" ’写出IP分割后的每段的值
’response.write ipstr12&"<br>"
’response.write ipstr13&"<br>"
’response.write ipstr14
allip=ipstr1&"."&ipstr12&"."&ipstr13&"."&ipstr14
finishgetip=left(allip,11)
dim ipaddr,iplocal,sqls
’以下SQL语句为提取startip字段左边11位值是否等于客户端IP的左边的11位的值
sqls="SELECT country_state,areauser FROM ip WHERE Left(startip,11)=’"&finishgetip&"’"
set rs=getaccessrecordset("#worldip.mdb",sqls,"1","1") ’得到查询值
if rs.eof then ’如果没找到与客户端IP相等的值
showip=checkip_trueip() ’把客户端IP赋予showip
ipaddr="未知地区" ’国家或省份
iplocal="未知地点" ’具体的地方
else
showip=checkip_trueip()
ipaddr=rs("country_state")
iplocal=rs("areauser")
end if
’response.write("您的IP是:"&showip&" ")
’response.write("您来自:"&ipaddr&" ")
’response.write("您是:"&iplocal)
rs.close
set rs=nothing
%>
<%="您的IP是:"&showip&" "%>
<%="您来自:"&ipaddr&" "%>
<%="您是:"&iplocal&"<br>"%>
如果IP地址有错误,请与我联系,或下载数据库更正,谢谢!
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="203"><a href="Script56.rar">下载Script56.CHM</a>-->1.34M</td>
<td width="548">简介:Microsoft的帮助文档,有VBscript语法,JScript语法,正则表达式 </td>
<td width="3"> </td>
<td width="6"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><a href="ipsearch.rar">下载ASP全球IP地址搜索程序</a></td>
<td>ASP+ACCESS 大小401K;格式rar</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font color="#000099"> </font> <font color="#0000FF"> </font></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>如果你的IP是未知,如果你愿意,请提交你的所在地:</td>
<td>
<form name="form1" method="post" action="postip.asp">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="21%"> 省份: </td>
<td width="44%">
<input type="text" name="country_state">
</td>
<td width="35%"> </td>
</tr>
<tr>
<td width="21%">具体所在地或是什么网的用户:</td>
<td width="44%">
<input type="text" name="areauser">
</td>
<td width="35%">例如:北京清华大学或北京网通用户</td>
</tr>
<tr>
<td width="21%"> </td>
<td width="44%">
<input type="hidden" name="startip" value="<%=finishgetip&".000"%>">
<input type="hidden" name="endip" value="<%=finishgetip&".255"%>">
</td>
<td width="35%"> </td>
</tr>
<tr>
<td width="21%"> </td>
<td width="44%">
<input type="submit" name="Submit" value="提交">
</td>
<td width="35%"> </td>
</tr>
</table>
</form>
</td>
<td> </td>
<td> </td>
</tr>
</table>
<%
end if
%>
</body>
</html>
0
投稿
猜你喜欢
- 有些时间没更新blog了,这两天为了更新<code collection>,于是重写了语法高亮的模块,这次是一个引擎,你可以根据
- 很多的朋友一而再,再而三的在Server.Mappath上卡壳,cnbruce也是一遍两遍地重复,还是不能全部解决,所以通过下面的举例,希望
- 《色彩解答》系列之一 色彩层次这次我们将深入进去了解一下众多色彩在一起之后所存在的“比例”关系。我们在使用色彩的时候不可能把所有的色彩都做得
- AddHeaderAddHeader 方法用指定的值添加 HTML 标题。该方法常常向响应添加新的 HTTP 标题。它并不替代现有的同名标题
- 1 The syntax of the SQL statement is verified.SQL的语法检查2 The data dicti
- 每个人都可以编写CSS代码,甚至你现在已经让它为你的项目工作了。但是CSS还可以更好吗?开始用这5个Tips改进你的CSS吧!一、关于CSS
- 信息图表设计(Inforgraphic Design),是信息设计(Information Design)学科的一个分支,它兴起于20世纪末
- Linux下MySQL整个数据库的备份与还原[root]# /usr/bin/mysqldump -h127.0.0.1 -uusernam
- 此文章主要介绍的是MySQL数据库的字符(串)的实际操作步骤,我们大家都知道MySQL数据库的字符(串)在实际操作是经常被用到了,所以你对其
- 在Web开发的时候,经常会遇到的一种情况就是浏览器提示脚本运行时间过长,停止还是继续,无论你选择什么,相信你都会想尽一切办法让这个对话框远离
- 看lifesinger的《由Kimi找茬想到的》,我想到的:1、 我不同意将“合并付款”定调在“很多卖家都需要”。这个“很多”在卖家里面大概
- 在VS2005装完后,会自带SQL Server2005 express版,为了便于管理,还需要安装一个企业管理器,需要下载 Microso
- 不知不觉2008已经走到了尽头,在这近一年中,一直不断的尝试用ExtJS做项目,从1.1到现在的2.2,吃了不少苦头,也有不少收获,总结一
- 在SQL Server Management Studio 用WINDOWS连接的情况下改实列的“属性&rdqu
- 嵌套SELECT语句也叫子查询,形如:SELECT name FROM bbc WHERE region = (SELECT region
- 阅读上一篇:css基础教程属性篇 本篇主要介绍css对边框(border)的属性控制和链接(link)的伪类选择器.边框(border):
- 问题:MySQL 5.0不能使用自动增加字段。具体原因:引起的原因是在MySQL5.0.2版本中的The Server SQL Mode 中
- 在JavaScript中,我们应该尽可能的用局部变量来代替全局变量,这句话所有人都知道,可是这句话是谁先说的?为什么要这么做?有什么根据么?
- 最简单的:<textarea name="A" cols="45" rows="2&
- 一天不小心把ROOT的权限改到最小了(只能登录,什么都做不了),这可急死我了.重装的话太麻烦,而且里面有很多的用户,一个个重新弄不知道到什么