- '******************************
- 'Function CheckIp(cInput_Ip,cBound_Ip)
- 'Created by qqdao, qqdao@263.net 2001/11/28
- '说明:首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内
- '参数: cInput_Ip,代检查的ip
- 'cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位
- '每个范围后添加":ALLOW"表示允许登陆,添加":REFUSE"表示拒绝登陆。多个范围用”;“隔开
- '例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"
- '返回值: true/false
- '更新:2001/12/05 支持ALLOW,REFUSE支持'*‘,不想对?支持,因为和*差不多
- '******************************
- function CheckIp(cInput_Ip,cBound_Ip)
- dim cSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip
- CheckIp = false
- cSingle_Ip=split(cBound_Ip,";")
- for i=0 to ubound(cSingle_Ip)
- if Instr(cSingle_Ip(i),"REFUSE") <> 0 then “就是拒绝了
- cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
- if Instr(cTemp_IP,"*") <> 0 then “是宽范围
- cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)
- if left(cInput_Ip,len(cStart_IP))=cStart_IP then
- CheckIp = false
- exit function
- end if
- end if
- if Instr(cTemp_IP,"-") = 0 then
- cStart_IP = cTemp_IP
- cEnd_Ip = cTemp_IP
- else
- cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)
- cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
- end if
- if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then
- CheckIp = false
- exit function
- end if
- elseif Instr(cSingle_Ip(i),"ALLOW") <> 0 then “允许
- cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
- if Instr(cTemp_IP,"*") <> 0 then “是宽范围
- cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)
- if left(cInput_Ip,len(cStart_IP))=cStart_IP then
- CheckIp = true
- end if
- end if
- if Instr(cTemp_IP,"-") = 0 then
- cStart_IP = cTemp_IP
- cEnd_Ip = cTemp_IP
- else
- cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)
- cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
- end if
- if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then
- CheckIp =true
- else
- CheckIp =false
- end if
- end if
- next
- end function
- '******************************
- 'Function Ip2Str(cIp)
- 'Created by qqdao, qqdao@263.net 2001/11/28
- '参考动网ip算法
- '参数:cIp ip地址
- '返回值: 转换后数值
- '******************************
- function Ip2Str(cIp)
- Dim str1,str2,str3,str4
- Dim cIp_Temp
- if cIp="127.0.0.1" then cIp="192.168.0.1"
- str1=left(cIp,instr(cIp,".")-1)
- cIp_Temp=mid(cIp,instr(cIp,".")+1)
- str2=left(cIp_Temp,instr(cIp_Temp,".")-1)
- cIp_Temp=mid(cIp_Temp,instr(cIp_Temp,".")+1)
- str3=left(cIp_Temp,instr(cIp_Temp,".")-1)
- str4=mid(cIp_Temp,instr(cIp_Temp,".")+1)
- if isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 then
- else
- Ip2Str=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
- end if
- end function
ASP中实现限制IP的函数详解
2019-10-16 09:53asp代码网 ASP教程
ASP中实现限制IP的函数详解
延伸 · 阅读
- 2022-03-11Python 函数装饰器应用教程
- 2022-03-11Python全栈之文件函数和函数参数
- 2022-03-10C++ 函数的介绍
- 2022-03-10Python全栈之路正则函数
- 2022-03-10详解Python的函数与异常
- 2022-03-09C语言system函数使用方法详解
精彩推荐
- ASP教程
ASP常用函数:getpy()
ASP常用函数:getpy()...
- ASP教程
asp之基于adodb.stream的文件操作类
asp之基于adodb.stream的文件操作类...
- ASP教程
asp 采集实战代码
最近实在是太流行采集了,本人是不喜欢采集的,但对采集的原理我却很有兴趣进行研究,拿到了网上采集常用函数,对其进行了一番研究,并实战,结果...
- ASP教程
ASP.NET 数据源
数据源 一个 data sourse 控件与数据绑定的控件相互作用,并隐藏了复杂的数据的联编过程。这些是提供数据给 data bound 控件的工具,并且支持如插入,删除...
- ASP教程
JScript中遍历Request表单参数集合的方法
这篇文章主要介绍了JScript中遍历Request表单参数集合的方法,本文以遍历Request.QueryString集合为例给出了实现代码,需要的朋友可以参考下...
- ASP教程
asp+javascript实现404页的处理转换
asp+javascript实现404页的处理转换...
- ASP教程
asp Access数据备份,还原,压缩类代码
asp Access数据备份,还原,压缩类实现代码,大家可以参考下。...
- ASP教程
asp 标记字符串中指定字符变色不区分大小写
今天遇到这种问题,单纯的使用replace函数不行,他会改变原有的字符串的大小写,在网上找到相关的代码,自己备份下...