XMLHTTP+Javascript+Asp写得聊天室,无刷新实现(四)

########say.asp##############

 1 Option Explicit   
 2dim F,T,sC,cL,E,W,sJ   
 3Response.ContentType="text/xml"   
 4F=Request.Form ("F")   
 5T=Request.Form ("T")   
 6sC=Request.Form ("sC")   
 7cL=Request.Form ("cL")   
 8E=Request.Form("E")   
 9'W=Request.Form("W")   
10W="0"   
11'发言时间   
12sJ=getTime()   
13if Request.ServerVariables("REQUEST_METHOD")="POST" then   
14sC="

<f>"&amp;trim(F)&amp;"</f>

<t>"&amp;trim(T)&amp;"</t>

<e>"&amp;E&amp;"</e>

<sc>"&amp;trim(sC)&amp;"</sc>

<cl>"&amp;trim(cL)&amp;"</cl>

<sj>"&amp;sJ&amp;"</sj>

 1"   
 2else   
 3Response.End   
 4end if   
 5dim c_info,c_Lid,c_Ip,u_Lid,NewLid,u_name,i   
 6Application.Lock   
 7c_info=Application("c_info")   
 8c_Lid=Application("c_Lid")+1   
 9Application("c_Lid")=c_Lid   
10c_Ip=(c_info(0)+6) mod 240   
11c_info(0)=c_Ip   
12c_info(c_Ip)=c_Lid   
13c_info(c_Ip+1)=F   
14c_info(c_Ip+2)=T   
15c_info(c_Ip+3)=W   
16c_info(c_Ip+4)=""   
17c_info(c_Ip+5)=sC '"

<f>"&amp;trim(F)&amp;"</f>

<t>"&amp;trim(T)&amp;"</t>

<e>"&amp;E&amp;"</e>

<sc>"&amp;trim(sC)&amp;"</sc>

<cl>"&amp;trim(cL)&amp;"</cl>

<sj>"&amp;sJ&amp;"</sj>

 1"   
 2Application("c_info")=c_info   
 3Application.UnLock   
 4u_Lid=session("u_Lid")   
 5newLid=u_Lid   
 6u_name=session("u_name")   
 7'&Application("c_Lid")&"%"&c_info(0)   
 8  
 9Response.Write "
10<?xml version=""1.0""?>

<msg>"
for i=c_info(0)+6 to 240 step 6
if (c_info(i)&gt;u_Lid) and ((c_info(i+1)=u_name) or (c_info(i+2)=u_name) or (c_info(i+2)="大家") or (c_info(i+3)="0")) then
Response.Write c_info(i+5)
if (newLid<c_info(i)) (c_info(i)="" 6="" c_info(0)="" end="" for="" i="1" if="" newlid="c_info(i)" next="" step="" then="" to="">u_Lid) and ((c_info(i+1)=u_name) or (c_info(i+2)=u_name) or (c_info(i+2)="大家") or (c_info(i+3)="0")) then
Response.Write c_info(i+5)
if (newLid<c_info(i)) "<="" end="" if="" msg="" newlid="c_info(i)" next="" response.write="" then="">"
session("u_Lid")=newLid

function getTime()
dim y,m,d,h,n,s
y=Year(date())
m=Month(date())
d=Day(date())
h=Hour(time())
n=Minute(time())
s=Second(time()) '当为是一位的 时候在前面加0
if len(m)=1 then m="0" &amp; m
if len(d)=1 then d="0" &amp; d
if len(h)=1 then h="0" &amp; h
if len(n)=1 then n="0" &amp; n
if len(s)=1 then s="0" &amp; s
getTime=y&amp;"/"&amp;m&amp;"/"&amp;d &amp;" " &amp; h&amp;":"&amp; n&amp;":"&amp;s
end function

Published At
Categories with Web编程
Tagged with
comments powered by Disqus