當前位置:開發者網絡 >> 技術教程 >> ASP教程 >> ASP應用 >> 內容
精彩推薦
分類最新教程
分類熱點教程
    
asp中對ip進行過濾限制函數
作者:未知
日期:2004-07-10
人氣:
投稿:xiaxia(轉貼)
來源:未知
字體:
收藏:加入瀏覽器收藏
以下正文:
看了一些IP限制的函數,覺得太複雜。所以,試著寫了一個,比較簡單。請網友參考指教。謝謝!∼

代碼拷貝框
<%'獲取訪問者的地址ip=Request.ServerVariables("REMOTE_ADDR") '允許的IP地址段為10.0.0.0∼10.68.63.255allowip1="10.0.0.0"allowip2="10.68.10.71"response.write checkip(ip,allowip1,allowip2)function checkip(ip,allowip1,allowip2)dim check(4)checkip=falseipstr=split(ip,".")allow1=split(allowip1,".")allow2=split(allowip2,".")if cint(allow1(0))>cint(allow2(0)) then '判斷IP地址段是否合法response.write "IP地址段出錯!"exit functionend iffor i=0 to ubound(ipstr)if cint(allow1(i))<cint(allow2(i)) thenif cint(allow1(i))=cint(ipstr(i)) thencheck(i)=truecheckip=trueexit forelseif cint(ipstr(i))<cint(allow2(i)) thencheck(i)=truecheckip=trueexit forelseif cint(ipstr(i))>cint(allow2(i)) thencheck(i)=falsecheckip=falseexit forelsecheck(i)=truecheckip=trueend ifend ifend ifelseif cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) thencheck(i)=falsecheckip=falseif i<>ubound(ipstr) thenexit forend ifelsecheck(i)=trueend ifend ifnextif (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) thencheckip=trueend ifend function%>


相關文章: