首页 >> 读书频道 >> 电脑 >> 一个只有一个文件,功能强大的聊天室
 
· 多层回复的基于 ASP
· 多层回复的基于 ASP
· 多层回复的基于 ASP
· 建立一个小型的购物车程序
· 制作购物车程序!
· 同时订购多样物品的源程序
· ASP商场源程序
· 一个简单的购物篮源代码
· 网上“店铺”DIY(3)
· 网上“店铺”DIY(2)
· 网上“店铺”DIY(1)
· 准确统计在线用户数量!
 
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 红楼梦:120回全本[清
· 武林寓言故事
· 2006高考录取规则
· 首批中国世界名牌产品和2
· 济南美食大全
· 管理三十六计
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

一个只有一个文件,功能强大的聊天室


查看有无更新版本

关键字:代码乐园 2006-8-28

 

<%@ Language=VBScript codepage=936%>
<%option explicit%>
<%
const CMAXLINE = 100
const CMAXUSER = 10
const CMAXROOM = 5
''tp = main,getchat,snddata,content,input
''ucd =
''line=
''on error resume next

dim vtp, vucd, vline, vroom
dim vcount, vcount2, i, v
vtp = Request.QueryString("tp")
vucd = Request.QueryString("ucd")
vline = Request.QueryString("line")
vroom = Request.QueryString("room")
if vtp = "" then vtp = "roomlist"
if vucd = "" then vucd = "guest"
if vline = "" then vline = 0 else vline = cint(vline)
if vroom = "" then vroom = 1
%>

<%
'' Initial chat data
'' roomsize - chat room size

'' chatroom* - chat room list room
'' chatroomchatsize* - chatsize room
'' chatroomusersize* - usersize room

'' chatuser** - chat user list room_user
'' chatusertime** - user active lasttime room_user

'' chatdata** - chat data room_line
'' chatdatauser** - chat user room_line
'' chatdatatouser** - chat to user room_line
'' chatdatatype** - chat data type room_line

if Application.Contents("roomsize") = "" then
''Application.Lock
Application.Contents("roomsize") = CMAXROOM
for i = 1 to CMAXROOM
Application.Contents("chatroom_" & i) = "room" & i
Application.Contents("chatroomchatsize_" & i) = 0
Application.Contents("chatroomusersize_" & i) = 0
next
''Application.UnLock
end if

%>

<HTML>
<%Response.Expires = 0%>
<%if vtp = "roomlist" then%>
<%Response.Write Application.Contents("roomsize")%>
<TABLE cellpadding=0 cellspacing=0 border=1 center>
<TR>
<TD>Chat Room</TD>
<TD>lines</TD>
<TD>users</TD>
</TR>
<%
for i = 1 to cint(Application.Contents("roomsize"))
Response.Write "<TR>" & vbCrlf
Response.Write "<TD>" & _
"<A HREF=chat.asp?tp=login&ucd=guest&room=" & i & ">" & _
Application.Contents("chatroom_" & i) & "</A></TD>" & vbCrlf
Response.Write "<TD>" & Application.Contents("chatroomchatsize_" & i)
& "</TD>" & vbCrlf
Response.Write "<TD>" & Application.Contents("chatroomusersize_" & i)
& "</TD>" & vbCrlf
Response.Write "</TR>" & vbCrlf
next
%>
</TABLE>
<%elseif vtp = "login" then%>
<CENTER>
<H1>Chat in <%=Application.Contents("chatroom_" & vroom)%></H1>
<FORM action="chat.asp">
<INPUT type=hidden id=tp name=tp value=main>
<INPUT type=hidden id=room name=room value=<%=vroom%>>
<INPUT type=text size=20 maxlength=20 id=ucd name=ucd>
<INPUT type=submit value=LogIn>
</FORM>
<CENTER>
<%elseif vtp = "main" then%>
<%
'' Add User to user list
if Application.Contents("chatuser_" & vroom & "_" & vucd) = "" then
''Application.Lock
Application.Contents("chatuser_" & vroom & "_" & vucd) = vucd
Application.Contents("chatusertime_" & vroom & "_" & vucd) = Now
Application.Contents("chatroomusersize_" & vroom) = _
Application.Contents("chatroomusersize_" & vroom) + 1
vcount = cint(Application.Contents("chatroomchatsize_" & vroom)) + 1
Application.Contents("chatroomchatsize_" & vroom) = vcount
Application.Contents("chatdata_" & vroom & "_" & vcount) = "<FONT
color=red>" & vucd & "</FONT> come in room at " & now()
Application.Contents("chatdatauser_" & vroom & "_" & vcount) = vucd
''Application.UnLock
end if
%>
<HEAD>
<TITLE><%=Application.Contents("chatroom_" & vroom)%></TITLE>
</HEAD>
<SCRIPT id=mainjs language=javascript>
var vline, vucd, vroom;
vline = 0;
vucd = ''<%=vucd%>'';
vroom = <%=vroom%>;
function AddChatData(vData){
content.chatdata.innerHTML = vData + content.chatdata.innerHTML;
}
function setLine(tline){
vline = tline;
}
function pp() {
//this.getchat.location = ''chat.asp?tp=getchat&room=<%=vroom%>&ucd=<%
=vucd%>&line='' + vline;
}
function setPageCome(p) {
pagecome = p;
}
var ti;
var timeout;
var pagecome;
timeout = 0;
pagecome = 0;
function rrr(){
var today = new Date();
clearTimeout(ti);
window.status = "welcome to sodick chat room";
timeout = timeout + 100;
if (timeout > 1000 || pagecome==1) {
timeout = 0;
pagecome = 0;
this.getchat.location = ''chat.asp?tp=getchat&room=<%=vroom%>&ucd=<%
=vucd%>&line='' + vline +"&nowt=" + today.getTime(); ;
}
window.status = "welcome to sodick chat room";
ti = setTimeout(''rrr();'', 1000);
}
ti = setTimeout(''rrr();'', 1000);
//window.location.reload();
</SCRIPT>
<FRAMESET cols="80%,*" name=chatroom>
<FRAMESET rows="100,60%,*,0,0">
<FRAME name=ad src="http://webdev/eMake/advert/adver.asp" scroll=no>
<FRAME name=content src="chat.asp?tp=content&room=<%=vroom%>&ucd=<%
=vucd%>">
<FRAME name=input src="chat.asp?tp=input&room=<%=vroom%>&ucd=<%=vucd%
>">
<FRAME name=getchat src="chat.asp?tp=getchat&room=<%=vroom%>&ucd=<%
=vucd%>">
<FRAME name=sndchat src="chat.asp?tp=sndchat&room=<%=vroom%>&ucd=<%
=vucd%>">
</FRAMESET>
<FRAME src="chat.asp?tp=userlist&room=<%=vroom%>">
</FRAMESET>
<%elseif vtp = "getchat" then%>
<%
'' Support multiple character sets.
''Session.Codepage = 65001
''Response.Charset = "UTF-8"

Response.CacheControl = "no-cache"

''HTTP/1.0 Compatibility
Response.AddHeader "Pragma", "no-cache"
Response.Expires = 0

%>
<SCRIPT>

function window_onload() {
<%
vCount = cint(Application.Contents("chatroomchatsize_" & vroom))
for i = vLine + 1 to vCount
v = "<FONT color=blue>" & Application.Contents("chatdatauser_" &
vroom & "_" & i) & "</FONT>" & _
":> " & Application.Contents("chatdata_" & vroom & "_" & i) & "<BR>"
Response.Write "this.top.AddChatData(""" & v & """);" & vbCrlf
next
Response.Write "this.top.setLine(" & vCount & ");" & vbCrlf
Response.Write "this.top.setPageCome(1);" & vbCrlf
%>
}
</SCRIPT>
<BODY language=javascript onload="return window_onload();">
<%Response.Write "Now:" & Hour(now()) & ":" & minute(now()) & ":" &
Second(now())%>
</BODY>
<%elseif vtp = "sndchat" then%>
<%
if Request.QueryString("chattext") <> "" then
vcount = cint(Application.Contents("chatroomchatsize_" & vroom)) + 1
''Application.Lock
Application.Contents("chatroomchatsize_" & vroom) = vcount
Application.Contents("chatdata_" & vroom & "_" & vcount) = _
Hour(now()) & ":" & minute(now()) & ":" & Second(now()) & " " &
Request.QueryString("chattext")
Application.Contents("chatdatauser_" & vroom & "_" & vcount) = vucd
''Application.UnLock
end if
%>
<%elseif vtp = "content" then%>
<%
''Response.AddHeader "REFRESH", "5"
''Response.Write Application.Contents("chatroomchatsize_" & vroom)
''for i = cint(Application.Contents("chatroomchatsize_" & vroom)) to
1 step -1
'' Response.Write Application.Contents("chatdatauser_" & vroom & "_"
& i) & ":"
'' Response.Write Application.Contents("chatdata_" & vroom & "_" & i)
& "<BR>" & vbCrlf
''next
%>
<SPAN id=chatdata>
</SPAN>
<%elseif vtp = "input" then%>
<FORM action="chat.asp" target=sndchat>
<INPUT type=hidden id=tp name=tp value=sndchat>
<INPUT type=hidden id=room name=room value=<%=vroom%>>
<INPUT type=hidden id=ucd name=ucd value=<%=vucd%>>
<INPUT type=text id=chattext name=chattext size=50 maxlength=200>
<INPUT type=submit id=send name=send value="send">
</FORM>
<%elseif vtp="userlist" then%>

<TABLE>
<%
''Response.Write Application.Contents("chatroomusersize_" & vroom)
for each v in Application.Contents
if left(v,10) = "chatuser_" & vroom then
Response.Write "<TR>" & vbCrlf
Response.Write "<TD>" & Application.Contents(v) & "</TD>" & vbCrlf
Response.Write "</TR>" & vbCrlf
end if
next
''for i = 1 to cint(Application.Contents("chatroomusersize_" & vroom))
'' Response.Write "<TR>" & vbCrlf
'' Response.Write "<TD>" & Application.Contents("chatuser_" & vroom
& "_" & i) & "</TD>" & vbCrlf
'' Response.Write "</TR>" & vbCrlf
''next
%>
</TABLE>

<%elseif vtp="outputdata" then%>
<%Response.Write Application.Contents("roomsize")%>
<%
for each v in Application.Contents
Response.Write v & " " & Application.Contents(v) & "<BR>" & vbCrlf
next
%>
<%elseif vtp="reset" then%>
<%
Application.Contents("roomsize") = ""
for each v in Application.Contents
if left(v, 4) = "chat" then
Application.Contents(v) = ""
end if
next
Response.Write "Clear Ok."
%>
<%else%>
<%="I don''t know"%>
<%end if%>
</HTML>

一个只有一个文件,功能强大的聊天室

[ 1 ]
一个只有一个文件,功能强大的聊天室 num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑