如何获知用户的IP?

来源:asp之家 时间:2009-11-24 20:52:00 

如何获知用户的IP?

<% 
Dim ValidLog 
' 日志变量 
ValidEntry = True 
If not IsEmpty(Session("LogIn")) then ValidEntry = False 
' 如果LogIn不为空,则表明用户信息已经写入
If Left(Request.ServerVariables("HTTP_REFERER"), 19)=http://aspxhome.com Then 
ValidEntry = False 
' 如果访问同一个URL,则不要写进Foryoufile.txt
End if 
If Left(Request.ServerVariables("HTTP_REFERER"), 23)=http://www.aspxhome.com Then 
ValidEntry = False 
End If 
If ValidEntry Then 
Const ForAppending = 8 
Const Create = true 
' 如果ValidEntry为真,则写到Foryoufile.txt
Dim FSO 
DIM TS 
DIM MyFileName 
Dim strLog 
Set FSO = Server.CreateObject("Scripting.FileSystemObject") 
Set TS = FSO.OpenTextFile(MyFileName, ForAppending, Create) 
strLog = "<br><P><B>" & now & "</B> " 
strLog = strLog & Request.ServerVariables("REMOTE_ADDR") & " " 
strLog = strLog & Request.ServerVariables("HTTP_REFERER") & " " 
strLog = strLog & Request.ServerVariables("HTTP_USER_AGENT") & "<BR>" 
' 保存信息 
TS.write strLog 
TS.Writeline "" 
' 写到Foryoufile.txt
Session("LogIn") = "yes" 
' 创建session变量,好检查下次ValidEntry的值 
Set TS = Nothing 
Set FSO = Nothing 
End If 
%>

标签:ip,asp,session
0
投稿

猜你喜欢

  • 朴素贝叶斯分类算法原理与Python实现与使用方法案例

    2022-03-11 10:59:04
  • IE7下动态创建Iframe时,去除边框的办法

    2009-01-19 13:56:00
  • Mac包管理器Homebrew的安装方法

    2023-02-16 06:20:19
  • 如何让Windows的bat脚本运行php程序

    2024-03-07 09:14:23
  • Python3+selenium配置常见报错解决方案

    2022-12-21 14:44:53
  • vue使用ElementUI时导航栏默认展开功能的实现

    2024-05-09 15:18:14
  • Python实现提取Excel指定关键词的行数据

    2022-09-01 10:15:59
  • MySQL8.0.21安装步骤及出现问题解决方案

    2024-01-22 20:43:44
  • MySQL触发器简单用法示例

    2024-01-26 11:26:53
  • Oracle 常用的SQL语句

    2009-08-02 07:09:00
  • ipython jupyter notebook中显示图像和数学公式实例

    2022-06-20 12:19:37
  • python连接mongodb集群方法详解

    2021-08-26 11:45:08
  • sqlserver存储过程语法详解

    2024-01-21 04:43:53
  • python 打印出所有的对象/模块的属性(实例代码)

    2023-09-02 21:46:15
  • SpringBoot 中使用JSP的方法示例

    2023-06-16 22:35:09
  • pytorch载入预训练模型后,实现训练指定层

    2022-01-22 12:40:35
  • 利用Python和C语言分别实现哈夫曼编码

    2021-08-12 09:59:49
  • MySQL 8.0.29 解压版安装配置方法图文教程

    2024-01-16 03:20:50
  • 动态导航设计

    2008-09-21 13:40:00
  • 利用OBJECT_DEFINITION函数来代码存档

    2009-01-20 15:34:00
  • asp之家 网络编程 m.aspxhome.com