开发学院WEB开发ASP 用通ASP直接获取用户真实IP地址 阅读

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

 2003-12-17 10:27:26 来源:WEB开发网   
核心提示:通用FUNCTION,如果不能取真实ip,用通ASP直接获取用户真实IP地址,就会取代理IPPRivate Function getIP() Dim strIPAddr If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "&quo

通用FUNCTION,如果不能取真实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)
   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

Tags:ASP 直接 获取

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接