日期:2014-05-17  浏览次数:20956 次

急!!显示不出来客户端的ip
我用的是VBscrip,
.....
  userip                 =     Request.ServerVariables( "HTTP_X_FORWARDED_FOR ")     
If   userip   =   " "         Then                
                                                      userip   =   Request.ServerVariables( "REMOTE_ADDR ")  
                End   If
Rs( "ip ")               =   userip
..........
可是Rs( "ip ")     中保存的总是服务器IP地址,这是怎么回事?

------解决方案--------------------
'==========================================================================
'功能:获得IP地址
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)
actforip=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)
actforip=Request.ServerVariables( "REMOTE_ADDR ")
Else
strIPAddr = Request.ServerVariables( "HTTP_X_FORWARDED_FOR ")
actforip=Request.ServerVariables( "REMOTE_ADDR ")
End If
getIP = CheckStr(Trim(Mid(strIPAddr, 1, 30)))
End Function