主页 > 知识库 > 用ASP创建日志文件(附源程序)

用ASP创建日志文件(附源程序)

热门标签:世界地图标注了哪些城市 石家庄慧营销外呼系统 梧州市地图标注 济源电销外呼系统线路 创意电话机器人 地图标注阳江 外呼线路批发 武穴地图标注 java外呼系统是什么
这个例子使用文本文件来写入用户的信息创建一个logfile.asp放在每一个asp的页面的顶端!--#Include File="LogFile.asp"-->当有人来访问你的站点logfile.asp自动把他的信息写入LogFile.txt,如果相关的URl一样的话则不写入文件
File: LogFile.asp
复制代码 代码如下:

%
Dim ValidEntry ' Log variable
' First set that this log is valid
ValidEntry = True

' If Session Variable "LogIn" is not empty
' that mean this person has already been logged
' then set ValidLog to False
If not IsEmpty(Session("LogIn")) then ValidEntry = False

' Here you can add different restriction
' If the refering url is from same site
' don't write to log file
If Left(Request.ServerVariables("HTTP_REFERER"), 17)
="http://jb51.net" Then
ValidEntry = False
End if
If Left(Request.ServerVariables("HTTP_REFERER"), 21)
="https://www.jb51.net" Then
ValidEntry = False
End If

' Now if ValidEntry is True then enter to log file
If ValidEntry Then
Const ForAppending = 8
Const Create = true
Dim FSO
DIM TS
DIM MyFileName
Dim strLog

MyFileName = Server.MapPath("MyLogFile.txt")
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(MyFileName, ForAppending, Create)

' Store all required values in strLog
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>"
' Write current information to Log Text File.
TS.write strLog
TS.Writeline ""
' Create a session varialbe to check next time for ValidEntry
Session("LogIn") = "yes"
Set TS = Nothing
Set FSO = Nothing
End If
%>

标签:揭阳 唐山 淮北 滁州 南宁 甘南 迪庆 来宾

巨人网络通讯声明:本文标题《用ASP创建日志文件(附源程序)》,本文关键词  用,ASP,创建,日志,文件,附,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《用ASP创建日志文件(附源程序)》相关的同类信息!
  • 本页收集关于用ASP创建日志文件(附源程序)的相关信息资讯供网民参考!
  • 推荐文章