中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > Asp > 综合文章
一个非常简单完整的聊天室演示程序,推荐初学者下载
作者:未知 时间:2005-04-25 12:12 出处:Blog 责编:chinaitpower
              摘要:暂无

简单的聊天室演示程序

一个比较基本的聊天室程序,具备最基本的“在线成员”“私聊”“清屏”“自动滚屏”等功能

这个聊天室程序是为ASP初学者学习参考而做,程序压缩包不大,20几K

下载地址:http://image.chinaitpower.com/files/20050425/16450.zip

这个聊天室是结合数据库的,由于代码分布不集中,在此只贴出用户登陆的那页代码

<%
set link1=server.CreateObject("ADODB.Connection")
link1.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("聊天室.mdb")
set rs=link1.Execute("select * from 会员表")
if request.form("ok")="" then
%>
<HTML>
<HEAD>
<META http-equiv='Content-Type' content='text/html;charset=gb2312'>
<Meta name='Gemeratpr' content='网络程序员伴侣(Lshdic)2004'>
<TITLE>登陆聊天室</TITLE>
<STYLE>
*{font-size:12px;color:;}
</STYLE>
</HEAD>
<BODY topmargin='2' leftmargin='2'>
<center>&nbsp;<p>风云舞者的聊天室<p>
<form method='post'>
在线成员:<select style='width:125'>
<%
str1=0
do while not rs.eof
times=DateDiff("s",rs("时间"),now)   '得到“当前时间”与“会员最后操作时间”之间间隔的秒数
if times<1200 then                   '20分钟内的最大停塞时间
if str1=0 then
str1=1:response.write "<option selected>" & rs("会员")
else
response.write "<option>" & rs("会员")
end if
end if
rs.movenext
loop
%>
</select><p>
用户名:<input type='text' maxlength='10' name='user'><p>
<input type='submit' value='提交' name='ok'>
</form>
<%
else
if request.form("user")="" then response.write "你必须填写用户名":response.end
if instr(request.form("user")," ")<>0 or instr(request.form("user"),"<")<>0 or instr(request.form("user"),">")<>0 or len(request.form("user"))<1 then response.write "用户名称不可以含有空格、&lt;符号、&gt;符号、_符号,而且最少为1个字符":response.end
if request.form("user")="大家" then response.write "用户名称不可以是“大家”":response.end
if rs.eof=true and rs.bof=false then rs.movefirst
isolduser=0
do while not rs.eof
if lcase(request.form("user"))=lcase(rs("会员")) and DateDiff("s",rs("时间"),now)<1200 then
response.write "对不起,<font color=red>" & request.form("user") & "</font> 这个用户还未离线,请您另起一个名字":response.end
elseif lcase(request.form("user"))=lcase(rs("会员")) and DateDiff("s",rs("时间"),now)>1200 then
isolduser=1:exit do
end if
rs.movenext
loop
if isolduser=1 then    '如果该会员以存在数据库中
link1.Execute "update 会员表 set 时间='" & now & "',id=" & session.SessionID & " where 会员='" & request.form("user") & "'"
else
link1.Execute "Insert into 会员表(会员,时间,id) values ('" & request.form("user") & "','" & now & "'," & session.SessionID & ")"
end if
application.Lock()
application("mc_" & session.SessionID)=""    '为该用户创建一个存储聊天数据的application变量中
application.UnLock()
session("who")=request.form("user")     '为该用户创建一个Session变量为了以后动态判断
response.Redirect "MC_allform.asp"
end if
%>
</BODY>
</HTML>

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有