手机
当前位置:查字典教程网 >编程开发 >ASP教程 >Asp下实现限制IP访问的程序代码
Asp下实现限制IP访问的程序代码
摘要:cint(allow2(0))then''判断IP地址段是否合法response.write"禁止访问"exitfunctionendiff...

<%

''获取访问者的地址

ip=Request.ServerVariables("REMOTE_ADDR")

''允许的IP地址段为10.0.0.0~10.68.63.255

allowip1="10.0.0.0"

allowip2="10.68.10.71"

response.writecheckip(ip,allowip1,allowip2)

functioncheckip(ip,allowip1,allowip2)

dimcheck(4)

checkip=false

ipstr=split(ip,".")

allow1=split(allowip1,".")

allow2=split(allowip2,".")

ifcint(allow1(0))>cint(allow2(0))then''判断IP地址段是否合法

response.write"禁止访问"

exitfunction

endif

fori=0toubound(ipstr)

ifcint(allow1(i))<cint(allow2(i))then

ifcint(allow1(i))=cint(ipstr(i))then

check(i)=true

checkip=true

exitfor

else

ifcint(ipstr(i))<cint(allow2(i))then

check(i)=true

checkip=true

exitfor

else

ifcint(ipstr(i))>cint(allow2(i))then

check(i)=false

checkip=false

exitfor

else

check(i)=true

checkip=true

endif

endif

endif

else

ifcint(allow1(i))>cint(ipstr(i))orcint(allow1(i))<cint(ipstr(i))then

check(i)=false

checkip=false

ifi<>ubound(ipstr)then

exitfor

endif

else

check(i)=true

endif

endif

next

if(check(0)=trueandcheck(1)=trueandcheck(2)=trueandcheck(3)=false)and(cint(allow2(2))>cint(ipstr(2)))then

checkip=true

endif

endfunction

%>

【Asp下实现限制IP访问的程序代码】相关文章:

ASP下实现自动采集程序及入库的代码

asp实现sql的备份与恢复

用asp实现的数据库中存取文件的代码

asp制作的日历程序

asp下实现替换远程文件为本地文件并保存远程文件的代码

ASP无组件分页实现思路及代码

限制一个Ip只能访问一次的asp代码

用asp实现文件浏览、上传、下载的程序

asp完整登陆代码

asp下tag的实现,简单介绍与部分代码

精品推荐
分类导航