报纸的故事教案:怎样可以限制别人的IP访问我的个人ASP空间?

来源:百度文库 编辑:高校问答 时间:2024/05/05 12:01:27
我的ASP空间要限制一些IP的人的访问
我知道他们的IP
怎么限制?

<%
ip_start="***.***.***.1"
ip_end="***.***.***.254"
ip_start_arr =split(ip_start,".")
ip_end_arr =split(ip_end,".")
ip_start_str=""
ip_end_str=""
ip_user_str=""
for i=0 to 3
ip_start_str=ip_start_str&right(Cstr(formatnumber(Cint(ip_start_arr(i))/1000,3)),3)
ip_end_str=ip_end_str&right(Cstr(formatnumber(Cint(ip_end_arr(i))/1000,3)),3)
next
'测试客户端是否用代理
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
ip_user_arr =split(userip,".")
for i=0 to 3
ip_user_str=ip_user_str&right(Cstr(formatnumber(Cint(ip_user_arr(i))/1000,3)),3)
next
if CDbl(ip_user_str)>CDbl(ip_end_str) or CDbl(ip_user_str)<CDbl(ip_start_str) then
response.write "超出访问范围"
response.end
end if
%>