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

ASP
编写通用的asp防注入程序
vbs(asp)下的Function 语句
ASP中类Class相关内容的整理资料
字符批量替换程序asp服务器版
旁注-网站小助手旭方修改免杀asp版
用正则表达式写的HTML分离函数
asp中"无限流"分页程序代码
asp的一个日期格式化函数
asp中创建多级目录的两段代码
asp中去除内容HTML标签的三个function函数
chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解
方便的大家admin及admin888 经过 md5加密后16位和32位代码
可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
asp动态级联菜单代码
ASP中经常使用的SQL语句与教程说明
实例分析之用ASP编程实现网络内容快速查找的代码
服务端 VBScript 与 JScript 几个相同特性的写法与示例
ASP 环境下 VBS 事件应用 示例代码
asp 之上传漏洞终结篇
asp中一段防SQL注入的通用脚本

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 42 ::
收藏到网摘: 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
%>