下面的代碼是post.asp檔案代碼.比較簡單所以就不說明了.
<%@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系統\bred\b您\bblue\b歡迎您來到聊天室。\bblack\b" + (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 > 30) 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("<發送人 顏色=\"" + Item[1] + "\">" + Item[0] + "</發送人>");
Node.push("<接收人 顏色=\"" + Item[3] + "\">" + Item[2] + "</接收人>");
Node.push("<說話 顏色=\"" + Item[5] + "\">" + Item[4] + "</說話>");
Node = Node.join("\t\t\r\n");
Node = "\t<聊天 時間=\"" + Item[6] + "\">" + Node + "\r\n\t</聊天>";
MyData.push(Node);
}
Session.Contents("Chat_Time") = LastTime;
MyData.reverse();
%><?xml version="1.0" encoding="gb2312"?>
<聊天室>
<%=MyData.join("\r\n")%>
</聊天室>
轉載請註明出處(www.111cn.net)