asp 取得用户真实IP,对代理地址仍然有效的函数

2018-09-06 12:25

阅读:441

  <%
******************************
函数:GetUserTrueIP()
参数:无
作者:阿里西西
日期:2007/7/13
描述:取得用户真实IP,对代理地址仍然有效;返回值:文本类型的IP地址
示例:<%=GetUserTrueIP()%>
******************************
FunctionGetUserTrueIP()
dimstrIPAddr
IfRequest.ServerVariables(HTTP_X_FORWARDED_FOR)=ORInStr(Request.ServerVariables(HTTP_X_FORWARDED_FOR),unknown)>0Then
strIPAddr=Request.ServerVariables(REMOTE_ADDR)
ElseIfInStr(Request.ServerVariables(HTTP_X_FORWARDED_FOR),,)>0Then
strIPAddr=Mid(Request.ServerVariables(HTTP_X_FORWARDED_FOR),1,InStr(Request.ServerVariables(HTTP_X_FORWARDED_FOR),,)-1)
ElseIfInStr(Request.ServerVariables(HTTP_X_FORWARDED_FOR),;)>0Then
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)
EndIf
GetUserTrueIP=Trim(Mid(strIPAddr,1,30))
EndFunction
%>


评论


亲,登录后才可以留言!