[P]首先看到MAN之前的贴子说会有解决方案,哈哈,自美一下,给MAN点赞。。。。。[/P][P]话说,本着学习的目的,来个简单版的先凑合下。。。[/P][P]于是有了如下:[/P][P]在register.asp的一开头增加:[/P][P][CODE]
ip=Request.ServerVariables("REMOTE_ADDR")
allowip1="172.16.5.0"
allowip2="172.16.129.255"
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
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
else response.Write("<script>alert('仅限公司局域网内方可进行注册!');javascript:history.go(-1)</script>")
end if
end function
[/CODE][/P][P] [/P][P]并不成功,请大家指点下。。感谢,新手求教~~~[/P] |