您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> asp编程 >> 正文

获取用户真实IP地址代码

作者:佚名    责任编辑:admin    更新时间:2022-06-22

获取用户真实IP地址代码
Public Function GetIp(getType)
  If getType = 0 then
   GetIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
   if GetIp = "" Then getIp = Request.ServerVariables("REMOTE_ADDR")
  ElseIf getType = 1 Then
   GetIp = Request.ServerVariables("LOCAL_ADDR")
  Else
   GetIp = "<span style=""color:#FF0000"">未知</span>"
  End if
  If GetIp = "::1" Then GetIp = "127.0.0.1"
 End Function

 '使用方法
 dim i
 i=1
 GetIp(1)