推薦的用Asp實(shí)現(xiàn)屏蔽IP地址訪問(wèn)的代碼
更新時(shí)間:2007年08月13日 14:55:11 作者:
By zkxp 2/15/2006 http://zkxp.cnblogs.com
‘受屏蔽IP地址(段)集合,星號(hào)為通配符,通常保存于配置文件中。
<%
Const BadIPGroup = "220.200.59.136|220.205.168.141"
If IsForbidIP(BadIPGroup) = True Then
Response.Write(GetUserIP &"IP地址禁止訪問(wèn)")
Response.End()
End If
'****************************************************************
'參數(shù)vBadIP:要屏蔽的IP段,IP地址集合,用|符號(hào)分隔多個(gè)IP地址(段)
'返回Bool:True用戶IP在被屏蔽范圍,F(xiàn)alse 反之
'****************************************************************
Function IsForbidIP(vBadIP)
Dim counter, arrIPPart, arrBadIP, arrBadIPPart, i, j
arrBadIP = Split(vBadIP, "|")
arrIPPart = Split(GetUserIP(), ".")
For i = 0 To UBound(arrBadIP)
counter = 0
arrBadIPPart = Split(arrBadIP(i), ".")
For j = 0 To UBound(arrIPPart)
If (arrBadIPPart(j)) = "*" or Cstr(arrIPPart(j)) = Cstr(arrBadIPPart(j)) Then
counter = counter + 1
End If
Next
If counter = 4 Then
IsForbidIP = True
Exit Function
End If
Next
IsForbidIP = False
End Function
'***************
'返回客戶IP地址
'***************
Function GetUserIP()
Dim IP
IP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IP = "" Then IP = Request.ServerVariables("REMOTE_ADDR")
GetUserIP = IP
End Function
%>
‘受屏蔽IP地址(段)集合,星號(hào)為通配符,通常保存于配置文件中。
<%
Const BadIPGroup = "220.200.59.136|220.205.168.141"
If IsForbidIP(BadIPGroup) = True Then
Response.Write(GetUserIP &"IP地址禁止訪問(wèn)")
Response.End()
End If
'****************************************************************
'參數(shù)vBadIP:要屏蔽的IP段,IP地址集合,用|符號(hào)分隔多個(gè)IP地址(段)
'返回Bool:True用戶IP在被屏蔽范圍,F(xiàn)alse 反之
'****************************************************************
Function IsForbidIP(vBadIP)
Dim counter, arrIPPart, arrBadIP, arrBadIPPart, i, j
arrBadIP = Split(vBadIP, "|")
arrIPPart = Split(GetUserIP(), ".")
For i = 0 To UBound(arrBadIP)
counter = 0
arrBadIPPart = Split(arrBadIP(i), ".")
For j = 0 To UBound(arrIPPart)
If (arrBadIPPart(j)) = "*" or Cstr(arrIPPart(j)) = Cstr(arrBadIPPart(j)) Then
counter = counter + 1
End If
Next
If counter = 4 Then
IsForbidIP = True
Exit Function
End If
Next
IsForbidIP = False
End Function
'***************
'返回客戶IP地址
'***************
Function GetUserIP()
Dim IP
IP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IP = "" Then IP = Request.ServerVariables("REMOTE_ADDR")
GetUserIP = IP
End Function
%>
您可能感興趣的文章:
- ASP.net做的IP訪問(wèn)限制
- 用ASP代碼實(shí)現(xiàn)對(duì)IP的訪問(wèn)限制的代碼
- Asp下實(shí)現(xiàn)限制IP訪問(wèn)的程序代碼
- 用asp腳本實(shí)現(xiàn)限制IP訪問(wèn)
- ADSI+ASP添加IP到IIS禁止訪問(wèn)列表中
- 記錄游客頁(yè)面訪問(wèn)IP的簡(jiǎn)易實(shí)現(xiàn)代碼 (asp.net+txt)
- 通過(guò)ASP禁止指定IP和只允許指定IP訪問(wèn)網(wǎng)站的代碼
- Asp限制IP訪問(wèn) 阻止某一個(gè)IP段禁止訪問(wèn)本站的代碼
- asp實(shí)現(xiàn)限制一個(gè)ip只能訪問(wèn)一次的方法
相關(guān)文章
忠網(wǎng)廣告 系統(tǒng) 用到的幾個(gè)函數(shù)
忠網(wǎng)廣告 系統(tǒng) 用到的幾個(gè)函數(shù)...2006-11-11asp 動(dòng)態(tài)生成rss(不成生xml文件)代碼
為你的網(wǎng)站添加rss閱讀功能 把以下文件保存為 rss.asp 放在網(wǎng)站的根目錄下 修改里面的幾個(gè)參數(shù)就可以2008-12-12asp中通過(guò)fso讀取和生成UTF-8編碼的txt
利用fso.OpenTextFil讀取UTF-8文件或者用FSO.save生成UTF-8文件時(shí)亂碼解決辦法生成靜態(tài)頁(yè)使用的方法是讀取asp頁(yè)面的html代碼,保存為html文件,這種方法2013-08-08通過(guò)MSXML2自動(dòng)獲取QQ個(gè)人頭像及在線情況(給初學(xué)者)
通過(guò)MSXML2自動(dòng)獲取QQ個(gè)人頭像及在線情況(給初學(xué)者)...2007-03-03FpHtmlEnCode 函數(shù)之標(biāo)題過(guò)濾特殊符號(hào)的代碼
FpHtmlEnCode 函數(shù)之標(biāo)題過(guò)濾特殊符號(hào)的代碼...2007-09-09