HTTP检测IP跳转代码怎么写

发布网友 发布时间:2022-04-22 09:24

我来回答

1个回答

热心网友 时间:2023-09-06 12:49

通用函数:如果不能取客户端真实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
上面方法获取客户端IP地址,然后根据获取到的值做判断。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com