⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.asp

📁 asp.net +AJAX无刷新聊天室
💻 ASP
字号:
<%
dim ischk,online,mi,ho
'用时间来控制在线用户
mi=MINUTE(TIME)
ho=HOUR(TIME)
'如果mi的位数小于2位则在10为添0,防止以前的在线用户,下线以后不能即使删除
if len(mi)<2 then
mi="0"&mi
end if
if len(mi)<1 then
mi="0"&"0"
end if
if len(ho)<2 then
ho="0"&ho
end if
if len(ho)<1 then
ho="0"&"0"
end if
'保持了4位数
nowtime=ho&mi
online=request("userid") 
ischk=true
'检查用户名是否存在
dim node,i,nodecount 
set xml = CreateObject("Microsoft.XMLDOM") 
xml.async = false 
xml.load(Server.MapPath("online.xml")) 
set root = xml.documentElement 
set nodeLis = root.childNodes 
nodeCount = nodeLis.length
For i=1 to nodeCount 
set node = nodeLis.nextNode()
if node.selectSingleNode("username").text=online then
response.Write "no"
ischk=false
exit for
end if
next
set node=nothing
set nodeLis=nothing
'把用户名添加到在线名单中
if online<>"" and ischk then
strSourceFile = Server.MapPath("online.xml")
'获取XML文件的路径这里根据你的虚拟目录不同而不同
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
'创建XML对像
objXML.load(strSourceFile)
'把XML文件读入内存中
Set objRootlist = objXML.documentElement
'选取<NewList>节点
brstr=chr(13)&chr(10)&chr(9)
'为了插入XML文件中的节点换行空格排列整齐(当然你也可以不用这样只是为了XML数据好看而以)
XMLnode=brstr&"<online>"&brstr & _
"<username>"&online&"</username>"&brstr & _
"<onlinetime>"&int(nowtime)&"</onlinetime>"&brstr & _
"</online>"&chr(13)
'根据得到的数据建立XML片段
set objXML2=Server.CreateObject("Microsoft.XMLDOM")
'建立一个新XML对像
objXML2.loadXML(XMLnode)
'把XML版片段读入内存中
set rootNewNode=objXML2.documentElement
'获得objXML2的根节点
objRootlist.appendChild(rootNewNode)
'把XML片段插入到List.xml中
objXML.save(strSourceFile)
'存储lsit.xml文件(因为不存储List.xml只在内存中更新了)
set objXML=nothing
set objXML2=nothing
end if
session("username")=online
'设置session的值为1,可以随便修改
session.timeout=1
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -