用通ASP直接获取用户真实IP地址

发表于:2007-06-30来源:作者:点击数: 标签:
Private Function getIP() 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.ServerVa
Private Function getIP()

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
getIP = Trim(Mid(strIPAddr, 1, 30))
End Function

原文转自:http://www.ltesting.net