AJAX初级聊天室代码(4)


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%><%
    Session.CodePage = 936
    Response.ContentType = "application/xml"
    Response.Expires = 0
%><%
function repla(str){
    str = str.replace(/\&/g, "&");
    str = str.replace(/\>/g, ">");
    str = str.replace(/\</g, "<");
    str = str.replace(/\"/g, """);
    str = str.replace(/\'/g, "'");
    return str;
}

var useIp = Request.ServerVariables("REMOTE_ADDR")
if(!Application("counts")){
    Application("counts") = 0
}
if(Request("cont").Count != 0){
    Application.Lock()
        if(Application("counts") < 21){        
            Application("counts") += 1
        }else if(Application("counts") >= 21){
            Application("counts") = 1
        }
        var Cnum = Application("counts")
        var Msgs = repla(Server.HTMLEncode(Request("cont")))
        Application("ips" + Cnum) = useIp +""
        Application("msgs" + Cnum) = Msgs +""
        if(Request("named").Count != 0){
            var names = Request("named")
        }else{
            var names = ""
        }
        Application("names" + Cnum) = names +""
    Application.UnLock()
}
if(Request("cont") == "cls"){
    Application.Contents.RemoveAll()
}
%><?xml version="1.0" encoding="gb2312" ?>
<ppl>
    <num><%=Application("counts")%></num>
    <%
    if(Request("clien") == "m"){
    %>
    <items>
        <ip><%=useIp%></ip>
    </items>
    <%
    }else if(Request("clien") < Application("counts")){
        for(var i=Request("clien"); i<Application("counts"); i++){
            s = Number(i)+1
            var useName = Application("names" + s)
            var useMsg = Application("msgs" + s)
            var useIp = Application("ips" + s)
    %>
    <items>
        <aaa><%=Request("clien")%> <%=s%></aaa>
        <bbb><%=Application("counts")%></bbb>
        <name><%=useName%></name>
        <conts><%=useMsg%></conts>
        <ip><%=useIp%></ip>
    </items>
    <%
        }
    }else if(Request("clien") > Application("counts")){
        for(var i=Request("clien"); i<21; i++){
            var useName = Application("names" + i)
            var useMsg = Application("msgs" + i)
            var useIp = Application("ips" + i)
    %>
    <items>
        <name><%=useName%></name>
        <conts><%=useMsg%></conts>
        <ip><%=useIp%></ip>
    </items>
    <%
        }
        for(var m=1; m<=Application("counts"); m++){
            var useNameM = Application("names" + m)
            var useMsgM = Application("msgs" + m)
            var useIpM = Application("ips" + m)
    %>
    <items>
        <name><%=useNameM%></name>
        <conts><%=useMsgM%></conts>
        <ip><%=useIpM%></ip>
    </items>
    <%
        }
    }else if(Request("clien") == Application("counts")){

    }
    %>
</ppl>



全部程序打包下载: 点击下载

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzjgj.html