局限內外網訪問的ASP代碼
發表時間:2024-01-06 來源:明輝站整理相關軟件相關文章人氣:
[摘要]準備只區別內外網的,我們學校的內網都是192.168.*.*的,這個很容易區別,但是校內用戶一用學校對外的代理,IP又變成服務器在外的代理,于是乎又加進去,現在變成了可以允許某些外網訪問了。因為領導要求就這些,只做到這點,以后還可以還可 以豐富,甚至做成組件。 有些人可能需要這個東西,放上來...
準備只區別內外網的,我們學校的內網都是192.168.*.*的,這個很容易區別,但是校內用戶一用學校對外的代理,IP又變成服務器在外的代理,于是乎又加進去,現在變成了可以允許某些外網訪問了。因為領導要求就這些,只做到這點,以后還可以還可 以豐富,甚至做成組件。
有些人可能需要這個東西,放上來共享!
編程高手來提出寶貴意見~~~
<%
ip=Request.ServerVariables("REMOTE_ADDR") '獲取訪問者的地址
allowip1="192.168.0.0" '第一允許IP段特點
allowip2="192.168.255.255" '暫時無用
allowip3="61.153.213.14" '具體允許IP地址
allowip4="61.129.69.177"
dim check(5)
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
allow3=split(allowip3,".")
allow4=split(allowip4,".")
for aa=0 to 1
for bb=0 to 3
if cint(allow1(aa))<> cint(ipstr(aa)) then
if cint(allow3(bb))<> cint(ipstr(bb)) then
if cint(allow4(bb))<> cint(ipstr(bb)) then
response.redirect "http://www.nhxx.net/err.php"
end if
end if
end if
next
next
%>
這個也可以,優點是速度快,但輸入IP麻煩
<%
'獲取訪問者的地址
ip=Request.ServerVariables("REMOTE_ADDR")
allowip1="192.168.0.0"
allowip2="192.168.255.255"
function checkip(ip,allowip1,allowip2)
dim check(4)
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))<> cint(ipstr(0)) then'判斷IP地址段是否內網用戶
if cint(ipstr(0))=61 and cint(ipstr(1))=153 and cint(ipstr(2))=213 and cint(ipstr(3))=14 then '判斷具體地址
else
if cint(ipstr(0))=61 and cint(ipstr(1))=129 and cint(ipstr(2))=69 and cint(ipstr(3))=166 then
else
response.redirect "http://www.nhxx.net/err.php"
end if
end if
end if
end function
%>