帮忙改程序,高分~~改简单的聊天室程序
要求改成:私聊功能可用,能够正常聊天,无刷新,不用数组存储所有对话,应该存储单个对话,总之和一般的无刷新聊天室基本一样就行了,我实在是改的头疼了,菜呀~~
===============================================================
index.asp入口文件
------------------------------------------------------------
<form action="enter.asp">
<Font color="#FF0000"><center><%If Not IsEmpty(Session("pplchatmess")) Then Response.Write(Session("pplchatmess")&"<BR>"):Session("pplchatmess")=Empty%></center></font>
<table width="345" height="127" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#F0E0F0">
<tr align="center" bgcolor="#000000">
<td colspan="2"><font color="#FFFFFF"><Big>聊天广场</Big></font></td>
</tr>
<tr bgcolor="#FF6600">
<td> <font color="#FFFFFF">您在聊天室中使用的名字:</font></td>
<td><input type="text" name="UserName" value=""><BR></td></tr><tr bgcolor="#FF6600">
<td> <font color="#FFFFFF">希望进入的聊天室:</font></td>
<td>
<select name="CRNAME">
<option value="情人世界">情人世界<%If Application("情人世界"&"usernum")>0 then Response.Write("["&Application("情人世界"&"usernum")&"]")%></option>
<option value="白领公寓">白领公寓<%If Application("白领公寓"&"usernum")>0 then Response.Write("["&Application("白领公寓"&"usernum")&"]")%></option>
<option value="三十而立">三十而立<%If Application("三十而立"&"usernum")>0 then Response.Write("["&Application("三十而立"&"usernum")&"]")%></option>
<option value="情感天地">情感天地<%If Application("情感天地"&"usernum")>0 then Response.Write("["&Application("情感天地"&"usernum")&"]")%></option>
</select>
<input name="sex" type="radio" value="男" checked>
男
<input type="radio" name="sex" value="女">
女 </td>
</tr><tr align="center" bgcolor="#FF6600"><td colspan="2">
<input type="submit" value="进入聊天室"></td></tr></table>
</form>
===================================================================
enter.asp引导文件
------------------------------------------------------------------
<%
'If1
If len(Request("UserName"))=0 or len(Request("CRNAME"))=0 then
Session("PPLCHATMESS")="请输入你在聊天室中使用的名字"
Response.Redirect("index.asp")
End If
'EIf1
sex=request("sex")
uname=request("username")&"("&sex&")"
Session("CRNAME")=Server.HtmlEncode(Request("CRNAME"))
Session("username")=Server.HtmlEncode(uname)
'IF1
If IsEmpty(Application(SESSION("CRNAME")&"sentences")) then'如果房间没有人则执行下列代码
dim sentences(60)'定义sentences句子数组
dim whotowho(60,2)'定义交谈双方数组
dim OUN(60) 'Online User Name在线用户数组
dim OULT(60) 'Online User Last Timer
OUN(1)=Session("username")
OULT(1)=Now
cur=1'数组指针
sentences(cur)="<font color=#FF0000>GYZ CHAT Service Running at "&Now&"</font>"
whotowho(cur,1)="System"
whotowho(cur,2)="大家"
cur=cur+1'计数器指针+1
If cur>60 then cur=1
sentences(cur)="<font color=#FF0000>[系统公告]</font>"&Session("username")&"刚刚进入<u>"&Session("CRNAME")&"</u>……<font color=#B0B0B0>("&Now&")</font>"
whotowho(cur,1)="System"
whotowho(cur,2)="大家"
Application.Lock
Application(SESSION("CRNAME")&"sentences")=sentences
Application(SESSION("CRNAME")&"whotowho")=whotowho
Application(SESSION("CRNAME")&"OUN")=OUN
Application(SESSION("CRNAME")&"OULT")=OULT
Application(SESSION("CRNAME")&"cur")=cur
Application(SESSION("CRNAME")&"usernum")=1
Application.UnLock
else
OUN=Application(SESSION("CRNAME")&"OUN")
OULT=Application(SESSION("CRNAME")&"OULT")
for i=1 to 60
'IF2
If Session("username")=OUN(i) and abs(DateDiff("s",OULT(i),Now))<130 then
Session("PPLCHATMESS")="已经有人正在使用<font color=#0000FF>"&Session("username")&"</font>这个名字在本聊天室聊天,请换用其它名字登录。"
Response.Redirect("index.asp")
End If
'EIF2
next
'检测人数是否超出最大限量(60)
'IF2
If Application(SESSION("CRNAME")&"usernum")>=59 then
Session("PPLCHATMESS")="对不起本聊天室已经满员,请进入其它聊天室。"
Response.Redirect("index.asp")
End If
'EIF2
usernum=0 '在线人数
OUN=Application(SESSION("CRNAME")&"OUN")
OULT=Application(SESSION("CRNAME")&"OULT")
sentences=Application(SESSION("CRNAME")&"sentences")
cur=Application(SESSION("CRNAME")&"cur")
whotowho=Application(SESSION("CRNAME")&"whotowho")
for i=1 to 60
If len(OUN(i))>0 then usernum=usernum+1 '统计在线人数
next
'删除过期聊天用户
for i=usernum to 1 step -1
If abs(DateDiff("s",OULT(i),Now))>60 then
cur=cur+1
if cur>60 then cur=1
sentences(cur)="<font color=#FF0000>[公告]</font>"&OUN(i)&"刚刚离开<u>"&Session("CRNAME")&"</u>……<font color=#B0B0B0>("&OULT(i)&")</font>"
whotowho(cur,1)="System"
whotowho(cur,2)="大家"
for os=i to usernum-1
OUN(os)=OUN(os+1)
OULT(os)=OULT(os+1)
next
OUN(usernum)=EMPTY
OULT(usernum)=EMPTY
usernum=usernum-1
End If
next
End If
'EIF1
Application.Lock
Application(SESSION("CRNAME")&"sentences")=sentences
Application(SESSION("CRNAME")&"whotowho")=whotowho
Application(SESSION("CRNAME")&"usernum")=usernum
Application(SESSION("CRNAME")&"cur")=cur
Application(SESSION("CRNAME")&"OUN")=OUN
Application(SESSION("CRNAME")&"OULT")=OULT
Application.unLock
Response.Redirect("chat.asp")
%>
=========================================================================
chat.asp聊天框架文件
----------------------------------------------------------------------
<%Response.Expires=0%>
<html>
<head>
<meta http-equiv="Content-Type" content='text/html; charset=gb2312'>
<title><%=Session("CRNAME")%></title>
<frameset cols='*,100' framespacing=4 frameborder=yes border=4 bordercolor="#000000">
<frameset rows='*,0,80' id="topframeset" cols="*" framespacing=0 frameborder=0 border=0>
<frameset rows="7,268">
<frame src="f_top.asp" name="f_top" id="f_top">
<frame src='f1.asp' name='f1'>
</frameset>
<frame src="about:<body bgcolor=#f2f2f2>blank" name="f_me" scrolling="auto" id="f_me" style="border-top: 3 dashed #80b888; bgcolor:#ffff00">
<frame src='f2.asp' name='f2' frameborder="yes" scrolling='no' bordercolor="f2f2f2">
</frameset>
<frameset rows='*,90' border=0 frameborder=0 framespacing=0 >
<frame src='f3.asp' name='f3' marginheight=10 marginwidth=5>
<frame src='f4.asp' name='f4' marginwidth=0 scrolling='no'>
</frameset>
</frameset><noframes></noframes>
</head>
</html>