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

📄 online.asp

📁 asp.net +AJAX无刷新聊天室
💻 ASP
字号:
<%Response.Charset="gb2312"%> 
<%
'定义数组
dim timername()
redim timername(50)
dim timertime()
redim timertime(50)
dim mi
dim ho
'获得当前时间
mi=MINUTE(TIME)
ho=HOUR(TIME)
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
nowtime=ho&mi

'将数据库的名单赋值给数组
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()
timername(i)=node.selectSingleNode("username").text
timertime(i)=node.selectSingleNode("onlinetime").text
next
set node=nothing
set nodeLis=nothing
'现在时间与数组时间比较大于2分针,则删除该在线名单
set nodeLis = root.childNodes 
for i=1 to nodeCount 
set node = nodeLis.nextNode()
t=int(timertime(i))
if clng(nowtime-t)>2 or clng(nowtime-t)=2 or clng(t-nowtime)>10 then
root.RemoveChild(node)
xml.Save(Server.MapPath("online.xml"))
end if
next
set node=nothing
set nodeLis=nothing
'显示最新在线名单
set nodeLis = root.childNodes 
response.Write("<p align=center><h5>在线人数"&nodeCount&"人</h5></p>")
response.Write("<a href=javascript:mtowho('所有人')>所有人</a>")
response.Write("<br />")

for i=1 to nodeCount
set node = nodeLis.nextNode()
     response.Write("<a href=javascript:mtowho('"&node.selectSingleNode("username").text&"');>"&node.selectSingleNode("username").text&"</a>")
	 response.Write("<br />")
next
set node=nothing
set nodeLis=nothing
'更新自己在线时间,防止被踢出
set nodeLis = root.childNodes 
for i=1 to nodeCount
set node = nodeLis.nextNode()
if node.selectSingleNode("username").text=session("username") then
node.selectSingleNode("onlinetime").text=int(nowtime)
xml.Save(Server.MapPath("online.xml"))
end if
next
set node=nothing
set nodeLis=nothing
%>

⌨️ 快捷键说明

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