asp 取得用户真实IP,对代理地址仍然有效的函数
2018-09-06 12:25
<%
******************************
函数: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
%>
上一篇:提供几个关于采集的函数(ASP)
文章标题:asp 取得用户真实IP,对代理地址仍然有效的函数
文章链接:http://soscw.com/index.php/essay/10306.html