- <%
- ''獲取訪問者的地址
- 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
- %>
Asp下實現限制IP訪問的程序代碼
2019-10-16 09:52asp代碼網 ASP教程
Asp下實現限制IP訪問的程序代碼
延伸 · 閱讀
- 2021-10-20關于ASP網頁無法打開的解決方案
- 2021-10-14讓apache也支持asp環境的方法
- 2021-08-15asp取整數mod 有小數的就自動加1
- 2021-08-15asp與php中定時生成頁面的思路與代碼
- 2021-05-09IIS 7.5 asp Session超時時間設置方法
- 2021-04-25Java版給愛人表白的玫瑰花程序代碼
精彩推薦
- ASP教程
asp Access數據備份,還原,壓縮類代碼
asp Access數據備份,還原,壓縮類實現代碼,大家可以參考下。...
- ASP教程
asp之基于adodb.stream的文件操作類
asp之基于adodb.stream的文件操作類...
- ASP教程
ASP.NET 數據源
數據源 一個 data sourse 控件與數據綁定的控件相互作用,并隱藏了復雜的數據的聯編過程。這些是提供數據給 data bound 控件的工具,并且支持如插入,刪除...
- ASP教程
asp 標記字符串中指定字符變色不區分大小寫
今天遇到這種問題,單純的使用replace函數不行,他會改變原有的字符串的大小寫,在網上找到相關的代碼,自己備份下...
- ASP教程
JScript中遍歷Request表單參數集合的方法
這篇文章主要介紹了JScript中遍歷Request表單參數集合的方法,本文以遍歷Request.QueryString集合為例給出了實現代碼,需要的朋友可以參考下...
- ASP教程
asp+javascript實現404頁的處理轉換
asp+javascript實現404頁的處理轉換...
- ASP教程
ASP常用函數:getpy()
ASP常用函數:getpy()...
- ASP教程
asp 采集實戰代碼
最近實在是太流行采集了,本人是不喜歡采集的,但對采集的原理我卻很有興趣進行研究,拿到了網上采集常用函數,對其進行了一番研究,并實戰,結果...