Asp限制IP访问
% ''获取访问者的地址 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) checki
''获取访问者的地址
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
%>
顶一下
(1)
25%
踩一下
(3)
75%
- 上一篇:没有了
- 下一篇:多域名同一空间的处理实例
- 最新评论 查看所有评论
-
- 发表评论 查看所有评论
-
2012 cheap ugg ugg uggs uggs ugg ugg uggs ugg ugg ugg uggs boots ugg ugg UGGS boots uggs boots. tory burch shoes tory burch outlet for sale.
- Asp下利用Smtp服务器发送邮件
- 用ASP编写的实现文本框过滤的函数
- ASP的对象结构
- 对ASP 动态包含文件方法的改进
- ASP中的表单验证实现方法
- 动态网页技术ASP日期和时间函数示例
- ASP实例:用ASP程序实现网站在线人数统计
- 初学ASP来看:用ASP查看数据库记录的代码
- ASP实现让数据库连接仅在需要读取数据库时打开
- ASP取出HTML里面的图片地址的实用函数
- 总结:谈谈学习ASP动态网页制作技术的编程心得
- ASP实例:用ASP编写更人性化的弹出窗口程序
- 通过实例学习ASP读取XML数据文件的方法
- 初学ASP最容易犯的程序问题及解决办法
- IIS自定义404错误,输入URL地址的小技巧
