ASP Simple Chat Room program two
<% @Language = "JavaScript" codepage= "936"%><%
var nothing;
Response.AddHeader ("Cache-control", "No-cahce");
if (! Session.Contents ("Chat_user"))
{
Session.Contents ("chat_user") = "Guest";
Session.Contents ("chat_time") = (new Date). GetTime ();
}
if (application.contents ("chat_data") = = Nothing)
{
Application.Lock ();
Application.Contents ("chat_data") = "F system bredb you bblueb Welcome to the chat room. BBLACKB "+ (3000 + (new Date). GetTime ());
Application.UnLock ();
}
var postchat = Request.QueryString.Item;
if (postchat)
{
var chat_data = application.contents ("Chat_data"). Split ("F");
if (Chat_data.length >) chat_data.shift ();
Chat_data.push (Server.HTMLEncode (unescape (postchat)) + "B" + (new Date). GetTime ());
Application.Lock ();
Application.Contents ("chat_data") = Chat_data.join ("f");
Application.UnLock ();
}
var lasttime = session.contents ("Chat_time");
var MyData = new Array;
var alldata = application.contents ("Chat_data"). Split ("F");
for (Var c=alldata.length-1; c>=1; c--)
{
var Node = new Array;
var Item = Alldata[c].split ("B");
if (Item[6] <= session.contents ("Chat_time")) break;
if (Item[6] > Lasttime) lasttime = item[6];
Node.push ("< Sender color =" "+ item[1] +" ">" + item[0] + "</sender >");
Node.push ("< Receiver color =" "+ item[3] +" ">" + item[2] + "</receiver >");
Node.push ("< speak color =" "+ item[5] +" ">" + item[4] + "</talk >");
Node = Node.join ("ttrn");
node = "t< Chat time =" "+ item[6] +" ">" + node + "rnt</chat >";
Mydata.push (Node);
}
Session.Contents ("chat_time") = Lasttime;
Mydata.reverse ();
%><?xml version= "1.0" encoding= "gb2312"?>
< chat room >
<%=mydata.join ("RN")%>
</Chat Room >