纯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>


猜你喜欢
- MySql5.0以后均支持存储过程,最近有空,研究了一下这个格式:CREATE PROCEDURE 过程名 ([过程参数[,...]])[特
- 1、首先停止mysql服务管理员身份开启CMD下命令关闭或者windows服务页面关闭C:\Users\xxx>net stop my
- 工具:Jupyter notebook + Anaconda游戏规则: * 一种玩法是买尾号。2元一个数字,中奖是20元。每个数字出现的概率
- 1 引言如果你想对图像进行校准,那么透视变换是非常有效的变换手段。透视变换的定义为将图像投影到一个新的视平面,通常也被称之为投影映射。2 公
- 如果你是一位前端开发工程师,对“跨平台”一词应该不会感到陌生。像常见的前端框架:比如React、Vue、Angular,它们可以做网页端,也
- 我们熟悉了对象和类的基本概念。我们将进一步拓展,以便能实际运用对象和类。调用类的其它信息上一讲中提到,在定义方法时,必须有self这一参数。
- 背景最近在需求中有一个这样的场景:需要在页面关闭的时候,用户不需要操作,主动关闭当前订单当时考虑的方案:在页面关闭的时候,向后端发送一个请求
- 关于段落<p></p>相信大家已经都在自己的工作中开始关注并应用了。因为那真的是非常简单的事,只要你愿意你随时都可以
- 前言无聊的时候做了一个搜索文章的软件,有没有更加的方便快捷不知道,好玩就行了环境使用Python 3.8Pycharm模块使用import
- 案例:该数据集的是一个关于每个学生成绩的数据集,接下来我们对该数据集进行分析,判断学生是否适合继续深造数据集特征展示1 GRE
- 引子vuejs 是一个入门简单的框架,具有使用简单,扩展方便的特点。随着webpack的流行,vuejs也推出了自己的load,vue-lo
- 从实时视频流中识别出人脸区域,从原理上看,其依然属于机器学习的领域之一,本质上与谷歌利用深度学习识别出猫没有什么区别。程序通过大量的人脸图片
- MySQL中存在float,double等非标准数据类型,也有decimal这种标准数据类型。其区别在于,float,double等非标准类
- 如下所示:def list_dict_duplicate_removal(): data_list = [{"a&qu
- 写在前面vue中关于插槽的文档说明很短,语言又写的很凝练,再加上其和methods,data,computed等常用选项使用频率、使用先后上
- 前一阵子工作项目上的事情忙的焦头烂额,最近要进行部门调整将要去做新的项目。又要学习很多新的知识了,还是很兴奋激动的。今天下班回来查看了一下V
- 下面是代码,如果看不懂,建议先把表格的一些<tr><td>的表格原理弄清楚了,就可以了代码如下:<table&
- 每次和朋友聊天苦于没有表情包,而别人的表情包似乎是取之不尽、用之不竭。作为一个程序员哪能甘愿认输,于是做了一个表情包下载器供大家斗图。首先,
- 与运算 &举例: 3&5 &n
- 一、concat()函数1、功能:将多个字符串连接成一个字符串。2、语法:concat(str1, str2,...)返回结果为连接参数产生