以文本方式查看主题

-  智睿软件_技术交流论坛  (http://zhirui.net/bbs/index.asp)
--  Web程序开发  (http://zhirui.net/bbs/list.asp?boardid=22)
----  判断代理IP访问ASP页面代码  (http://zhirui.net/bbs/dispbbs.asp?boardid=22&id=1255)

--  作者:zhirui
--  发布时间:2011-02-15 18:24:53
--  判断代理IP访问ASP页面代码

dim gethttpstr
gethttpstr=LCase(Request.ServerVariables("ALL_HTTP"))
If Instr(gethttpstr,"proxy")=0 or Instr(gethttpstr,"http_via")=0 or Instr(gethttpstr,"http_pragma")=0 then
Response.Write "禁止使用代理服务器登陆!"
\'Response.End
End if

 

 

——————————————————————————————————————————

Dim FY_IP
FY_IP=LCase(Request.ServerVariables("ALL_HTTP"))
If Instr(FY_IP,"proxy")<>0 or Instr(FY_IP,"http_via")<>0 or Instr(FY_IP,"http_pragma")<>0 or Request.ServerVariables("HTTP_PROXY_CONNECTION") <> "" or Request.ServerVariables("HTTP_VIA") <> "" or Request.ServerVariables("HTTP_USER_AGENT_VIA") <> "" or Request.ServerVariables("HTTP_X_FORWARDED_FOR") <> "" or Request.ServerVariables("HTTP_PROXY_CONNECTION") <> "" or Request.ServerVariables("HTTP_CACHE_CONTROL") <> "" or Request.ServerVariables("HTTP_CACHE_INFO") <> "" Then
Response.Write "代理"
Else
Response.Write "不是代理"
End If


--  作者:zhirui
--  发布时间:2011-02-15 18:34:15
--  

asp获取用户真实IP透过代理地址函数如下:

<%
\'******************************
\'函数:GetUserTrueIP()
\'参数:无
\'描述:取得用户真实IP,对代理地址仍然有效;返回值:文本类型的IP地址
\'示例:<%=GetUserTrueIP()%>
\'******************************
Function GetUserTrueIP()
    dim strIPAddr
    If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then 
       strIPAddr = Request.ServerVariables("REMOTE_ADDR") 
    ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then 
       strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 
    ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then 
       strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) 
    Else 
       strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
    End If 
    GetUserTrueIP = Trim(Mid(strIPAddr, 1, 30)) 
End Function
%>

[此贴子已经被作者于2011-02-15 18:35:11编辑过]