ASP获取客户端IP通用函数(HTTP_X_FORWARDED_FOR)

' 获取客户端IP
Private   Function  getClientIP()
    
Dim  strIPAddr, XFOR, REMOTE_ADDR
    XFOR 
=  Request.ServerVariables( " HTTP_X_FORWARDED_FOR " )
    REMOTE_ADDR 
=  Request.ServerVariables( " REMOTE_ADDR " )
    
If  XFOR  =   ""   OR   InStr (XFOR,  " unknown " >   0   Then  
        strIPAddr 
=  REMOTE_ADDR
    
ElseIf   InStr (XFOR,  " , " >   0   Then  
        strIPAddr 
=   Mid (XFOR,  1 InStr (XFOR,  " , " ) - 1
    
ElseIf   InStr (XFOR,  " ; " >   0   Then  
        strIPAddr 
=   Mid (XFOR,  1 InStr (XFOR,  " ; " ) - 1
    
Else  
        strIPAddr 
=  XFOR
    
End   If  
    getClientIP 
=   Trim ( Mid (strIPAddr,  1 30 ))
End Function

你可能感兴趣的:(forward)