当前位置: 首页 > 图文教程 > 网络编程 > ASP > Asp下实现限制IP访问的程序代码

ASP
ASP中实现限制IP的函数详解
Asp下实现限制IP访问的程序代码
asp下DateDiff 函数参数说明
Highlight patterns within strings
Insert Date and Time into Access
asp下调试程序的debug类
RESPONSE.WRITE和<%=%的区别
用asp实现网页邮箱访问的方法
编写一个含二级目录的源码(Asp+JavaScript)
asp下删除Access数词库中的空记录的sql语句
asp下制做行背景颜色交替变换的表格
asp下将数据库中的信息存储至XML文件中
asp下如何在Access数据库中立即得到所插入记录的自动编号?
asp下如何在ADO服务器端利用好缓存技术?
asp调用Word打印的代码
巧用FileSystem组件实现WEB应用中的本地特定打印的方法
用javascript解决外部数据抓取中的乱码问题
Asp中随机产生用户密码的代码
反SPAM新思路—换Z-BLOG的验证码!
在Z-BLOG可用的新版ASP的GIF验证码[V70404]

ASP 中的 Asp下实现限制IP访问的程序代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 41 ::
收藏到网摘: n/a

<%
''获取访问者的地址
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.write checkip(ip,allowip1,allowip2)
function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判断IP地址段是否合法
response.write "禁止访问"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if
end function
%>