asp簡單聊天室程式 二

來源:互聯網
上載者:User

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系統bredb您bblueb歡迎您來到聊天室。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 > 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("ttrn");
    Node = "t<聊天 時間="" + Item[6] + "">" + Node + "rnt</聊天>";
    MyData.push(Node);
}
Session.Contents("Chat_Time") = LastTime;
MyData.reverse();
%><?xml version="1.0" encoding="gb2312"?>
<聊天室>
<%=MyData.join("rn")%>
</聊天室>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.