📄 display.asp
字号:
<% Response.ContentType="text/vnd.wap.wml" %>
<% Response.Charset="gb2312"
response.buffer=True
response.cachecontrol="Private" '禁止代理服务器缓存本页面
response.expires=0 '让页面立即过期
%>
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="main" title="聊天室0.6测试版" ontimer="display.asp">
<timer value="60"/>
<p>
<a href="send.asp">[发言]</a> <a href="userlist.asp">[在线用户]</a><br/>
<%
IF session("usernick")="" then
response.write "与系统失去联系,请重新登录。"
'response.end
end if
userlist=Application("userlist")
speaktowho=request("towho") '''''''''''''''''''''''''''''''获得对谁发言
'判断发言者在用户列表中是否有
speakeronlineflag=0 '初始化标志变量为不在线
towho_onlineflag=0 '初始化发言对象为不在线
for n=1 to 30
if session("usernick")=userlist(n) then '说明在线
speakeronlineflag=1 '设置在线标志
exit for
end if
next
if speakeronlineflag=0 then
response.write "你潜水太久,已被系统踢出。" '''''''''''''''''''''''''这里好像执行不到(就算条件满足)
session("usernick")="" '将当前用户设置为空字符串
'response.end
end if
if trim(speaktowho)<>"大家" then '若不是对大家发言,则判断发言对象是否在线
for n=1 to 30
if speaktowho=userlist(n) then '找到,则说明在线
towho_onlineflag=1 '设置在线标志
exit for
end if
next
if towho_onlineflag=0 then
'在Application对象中获得数组和相关变量的值
saymsg=Application("saymsg")
CurmsgID=Application("CurmsgID")
whotowho=Application("whotowho")
CurmsgID=CurmsgID+1 '增加一条发言内容(系统公告)
if CurmsgID>10 then CurmsgID=1 '若超过10条,则从第一条覆盖
saymsg(CurmsgID)="[公告]"&speaktowho&"已经离开。"&time
whotowho(CurmsgID,1)="System"
whotowho(CurmsgID,2)=Session("usernick")
'下面将更新后的数组和变量内容,重新回存到Application对象中保存
Application.lock
Application("saymsg")=saymsg
Application("whotowho")=whotowho
Application("CurmsgID")=CurmsgID
Application.unlock
end if
else
towho_onlineflag=1 '若是对大家发言,则为在线状态
end if
%>
<%
usersay=request("content") '获得用户的发言内容
towho=speaktowho
IF Len(usersay)>0 THEN
'response.write usersay
usernick=session("usernick")
'从Application对象中获得相关数组和变量的值
saymsg=Application("saymsg")
whotowho=Application("whotowho")
CurmsgID=Application("CurmsgID")
userlist=Application("userlist")
userlastsaytime=Application("userlastsaytime")
'更新当前用户的最近发言时间
for i=1 to 30
if usernick=userlist(i) then
userlastsaytime(i)=now
exit for
end if
next
'增加发言内容到保存发言的数组中
CurmsgID=CurmsgID+1
if CurmsgID>80 then CurmsgID=1
whotowho(CurmsgID,1)=usernick
whotowho(CurmsgID,2)=towho
saymsg(CurmsgID)=usernick&"对"&towho&"说:"&usersay&"("&time&")" ''''''''以后要为用户的发言增加表情在这里要做修改
'将更新了数据的数组和相关变量的值,回存到Application对象中保存
Application.lock
Application("saymsg")=saymsg
Application("whotowho")=whotowho
Application("CurmsgID")=CurmsgID
Application("userlastsaytime")=userlastsaytime
Application.unlock
END IF
'下面准备输出发言内容(输出前的预处理) 输出时最近的发言内容显示在最下面(应该在最上面比较好)
saymsg=Application("saymsg")
CurmsgID=Application("CurmsgID")
outputstr=""
for i=CurmsgID+1 to 10
if Len(saymsg(i))>0 then
outputstr=outputstr&saymsg(i)&"<br/>"
end if
next
for i=1 to CurmsgID
if Len(saymsg(i))>0 then
outputstr=outputstr&saymsg(i)&"<br/>"
end if
next
response.write outputstr
%>
</p>
</card>
</wml>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -