ASP获取用户IP地址的函数

‘[读取用户IP地址信息]
‘函数名:Readusip
‘作 用:读取用户IP地址信息
‘参 数:
‘返回值:返回用户IP地址
‘**************************************************
Public Function Readusip()
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
Readusip = Trim(Mid(strIPAddr, 1, 30))
End Function

分类: ASP

寒林

www.3code.cn 专注WordPress企业主题