我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 网络学院 > 网络编程 > ASP专区 > asp记录日志程序
热门文章排行
热门文章排行 手推车”功能的实现(10-07)
八大法则防范ASP网站漏洞(10-23)
在JSP中访问数据库大全(10-23)
ASP教程十一、调试ASP脚本(10-23)
虚机服务中常见Asp.Net低级错误一览(03-21)
精采文章排行
精采文章排行 ASP.NET实现抓取网页中的链接(11-15)
ASP连接数据库的11种方法(11-10)
如何动态创建网页的RSS内容摘要(11-10)
ASP网站漏洞及入侵防范方法(11-10)
ASP自定义函数:对字符串正则替换(11-10)
技术专题推荐
网管论坛交流
 

asp记录日志程序 

作者:   来源:   点击:   日期:2006-11-24

'书写日志的程序
?'username :用户信息(标示进行该操作的人员)
'operate :操作(标示用户进行了什么操作)
'userip :用户IP(标示用户用于登录系统的计算机的IP地址)
'opdate :用户操作发生的日期
'日志写入一个xml文件,第一次写入时如果xml文件不存在,则创建。 '返回值:0 表示输入的参数无效 '返回值:1 表示打开日志文件时出错 '返回值:9 表示正确完成写入日志文件

?function WriteLog(username,operate,userip,opdate)
if username="" or operate="" or userip="" or opdate="" then
WriteLog=0 '参数无效
exit function
end if
RootNode="syslog"
'日志文件根节点名字
LogFile=server.mappath("uuu.xml") '日志文件路径
set fso=server.CreateObject("scripting.filesystemobject")
'如果日志文件不存在,就创建一个,并写入头信息和根信息
if not fso.FileExists(LogFile) then
fso.CreateTextFile LogFile
set fff=fso.GetFile(LogFile)
set mmm=fff.openastextstream(2)?
mmm.write "《?xml version=""1.0"" encoding=""gb2312"" ?〉" & vbcrlf & "《" & rootnode & "〉《/" & rootnode & "〉"
set mmm=nothing
set fff=nothing
else
Response.Write("文件名冲突!")
Response.End
end if
set fso=nothing
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false xd.load(LogFile)
if xd.parseError.errorcode<>0 then
WriteLog=1 '打开日志文件出错
exit function
end if
'创建新节点信息
set et=xd.documentElement
set cnode=xd.createElement("log")
et.appendchild(cnode)
set node2=xd.createElement("username")
node2.text=username
cnode.appendchild(node2)
set node2=xd.createElement("operate")
node2.text=operate
cnode.appendchild(node2)
set node2=xd.createElement("userip")
node2.text=userip
cnode.appendchild(node2)
set node2=xd.createElement("opdate")
node2.text=opdate
cnode.appendchild(node2)
xd.save LogFile '写入日志文件
set cnode=nothing
set node2=nothing
set xd=nothing
writeLog=9 '说明正常写入了日志信息
end function



文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·ASP自动解压RAR文件 ·ASP判断文件地址是否有效
·一个很简单的验证码程序 ·使用PHP批量生成随机用户名
·ASP中实用的广告交替组件 ·webconfig的设置节点说明

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。