手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp下实现IP限制函数代码
asp下实现IP限制函数代码
摘要:IP限制函数大家如果还有好的建议算法,就联系我!!:)“******************************“FunctionChe...

IP限制函数

大家如果还有好的建议算法,就联系我!!:)

“******************************

“FunctionCheckIp(cInput_Ip,cBound_Ip)

“Createdbyqqdao,qqdao@263.net2001/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支持'*‘,不想对?支持,因为和*差不多

“******************************

functionCheckIp(cInput_Ip,cBound_Ip)

dimcSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip

CheckIp=false

cSingle_Ip=split(cBound_Ip,";")

fori=0toubound(cSingle_Ip)

ifInstr(cSingle_Ip(i),"REFUSE")<>0then“就是拒绝了

cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

ifInstr(cTemp_IP,"*")<>0then“是宽范围

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)

ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen

CheckIp=false

exitfunction

endif

endif

ifInstr(cTemp_IP,"-")=0then

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)

endif

ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then

CheckIp=false

exitfunction

endif

elseifInstr(cSingle_Ip(i),"ALLOW")<>0then“允许

cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

ifInstr(cTemp_IP,"*")<>0then“是宽范围

cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)

ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen

CheckIp=true

endif

endif

ifInstr(cTemp_IP,"-")=0then

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)

endif

ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then

CheckIp=true

else

CheckIp=false

endif

endif

next

endfunction

“******************************

“FunctionIp2Str(cIp)

“Createdbyqqdao,qqdao@263.net2001/11/28

“参考动网ip算法

“参数:cIpip地址

“返回值:转换后数值

“******************************

functionIp2Str(cIp)

Dimstr1,str2,str3,str4

DimcIp_Temp

ifcIp="127.0.0.1"thencIp="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)

ifisNumeric(str1)=0orisNumeric(str2)=0orisNumeric(str3)=0orisNumeric(str4)=0then

else

Ip2Str=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1

endif

endfunction

【asp下实现IP限制函数代码】相关文章:

Asp实现假静态

asp 获取地址栏参数代码

ASP整理一些实用的速查代码

asp复制文件夹代码

asp实现的7xi音乐网的采集源代码

ASP中字符与数字操作函数总结

在asp中通过vbs类实现rsa加密与解密的代码

Asp 函数介绍

asp中通过getrows实现数据库记录分页的一段代码

asp实现表格3列5行

精品推荐
分类导航