⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.asp

📁 这是我课程设计的时候做的聊天程序
💻 ASP
字号:
<!--#include file="config.asp"-->
<!--#include file="functions.asp"-->
<%
if session("loginstatus")<>"logined" or session("userid")="" or session("grade")="" then
	response.write "<script language='javascript'>"&vbcrlf
	response.write "<!--"&vbcrlf
	response.write "top.window.location.href='index.asp?ntime="&ntime&"';"&vbcrlf
	response.write "//-->"&vbcrlf
	response.write "</script>"&vbcrlf
	response.end
end if
%>
<!--#include file="conn.asp"-->
<%
if request.querystring("act")<>"login" then
	sql="select * from userinfo where isonline=true and userid='"&session("userid")&"'"
	rs.open sql,conn,0,3
	if rs.eof and rs.bof then
		rs.close
		set rs=nothing
		conn.close
		set conn=nothing
		session("loginstatus")=""
		session("userid")=""
		session("grade")=""
		response.write "<script language='javascript'>"&vbcrlf
		response.write "<!--"&vbcrlf
		response.write "top.window.location.href='index.asp';"&vbcrlf
		response.write "//-->"&vbcrlf
		response.write "</script>"&vbcrlf
		response.end
	else
		rs("timecount")=rs("timecount")+datediff("s",rs("logintime"),now())/60
		rs("logintime")=now()
		rs.update
		rs.close
	end if
end if
%>
<html>
<head>
<meta http-equiv="refresh" content="15;URL=<%=selfname%>?ntime=<%=ntime%>">
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title><%=pagetitle%>--聊天内容显示页面</title>
<script language="javascript">
<!--
function setobj(obj)
{
for (i=1; i<parent.chatform.document.forms[0].object.length; i++)
{
	var iscontinue=true;
	if (parent.chatform.document.forms[0].object.options[i].value==obj)
	{
		parent.chatform.document.forms[0].object.selectedIndex = i;
		iscontinue=false;
		break;
	}
}
if (iscontinue==true)
{
	var oOption = parent.chatform.document.createElement('OPTION');
	parent.chatform.document.forms[0].object.add(oOption, 1);
	parent.chatform.document.forms[0].object.options[1].value=obj;
	parent.chatform.document.forms[0].object.options[1].text=obj;
	parent.chatform.document.forms[0].object.selectedIndex=1;
	parent.chatform.document.forms[0].putwords_temp.focus();
}
}
function gotop(isrefresh)
{
	if (window==top)
	{
		top.location.href="chat.asp?ntime=<%=ntime%>";
	}
}
//-->
</script>
<style type="text/css">
<!--
input,body,table{font-size:12px}
body{width:120px;text-align:left;padding:6px 0 0 12px;vertical-align:center;background:#f6f6f6 url(images/bg.gif)}
td{word-break:break-all}
form{margin:0;padding:0}
a{color:#333390;text-decoration:none}
a:hover{color:#ff3333;text-decoration:underline}
#announce{text-align:center;font-weight:600;color:#<%=colorS%>}
.emtxt{color:#900000;font-weight:600}
.announce{color:#ff3333;font-weight:600}
.usrname{font-style:italic;cursor:hand;}
-->
</style>
<%
putwords=request.form("putwords")
if request.form("formsubmit")="发送" and trim(putwords)<>"" then
	putwords=unhtml(putwords)
	if session("grade")>=gradeimg then
		putwords=ubbimg(putwords)
	end if
	if session("grade")>=gradeurl then
		putwords=ubburl(putwords)
	end if
	putwords=fbdwords(putwords,forbidwords)
	ispublic=request.form("ispublic")
	textcolor=request.form("textcolor")
	userface=request.form("userface")
	if ispublic<>"false" then
		ispublic="true"
	end if
	toobject=request.form("object")
	sql="select top 1 * from chatinfo order by puttime asc"
	rs.open sql,conn,0,3
	if session("grade")>=gradebulletin and left(putwords,10)="[bulletin]" then
		putwords=mid(putwords,11,len(putwords)-10)
		rs("userid")=""
		rs("sayto")=""
		rs("saycontent")=trim(putwords)
		rs("textcolor")=textcolor
		rs("userface")=userface
		rs("ispublic")="true"
	else
		rs("userid")=session("userid")
		rs("sayto")=toobject
		rs("saycontent")=trim(putwords)
		rs("textcolor")=textcolor
		rs("userface")=userface
		rs("ispublic")=ispublic
	end if
	rs("puttime")=now()
	rs.update
	rs.close
end if
response.write "</head>"&vbcrlf
response.write "<body onload='gotop()'>"&vbcrlf
response.write "<div id='announce'><script language='javascript'>"&vbcrlf&"if(top!=window)"&vbcrlf&"{"&vbcrlf&"bulletintxt=top.online.document.title;"&vbcrlf&"if(bulletintxt.substr(0,8)=='没有可以显示的页')"&vbcrlf&"top.online.window.location.href='online.asp';"&vbcrlf&"else"&vbcrlf&"document.write(top.online.document.title);"&vbcrlf&"}"&vbcrlf&"</script></div>"&vbcrlf
response.write "<hr width=""100%""><br>"&vbcrlf
sql="select top "&maxrecordnum&" userid,sayto,saycontent,textcolor,userface,ispublic,puttime from chatinfo where puttime>#"&dateadd("s",(0-5*sessionout),now())&"# order by puttime desc"
rs.open sql,conn,0,1
if not(rs.bof and rs.eof) then
	chatinfodata=rs.getrows()
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
	chatinfonum=ubound(chatinfodata,2)
	for i=0 to chatinfonum
		if chatinfodata(5,i)=true or chatinfodata(1,i)="" or chatinfodata(1,i)="大家" then
			if chatinfodata(0,i)="" then
				response.write "<span class='announce'>〖"&pagetitle&"〗公告 : "&chatinfodata(2,i)&" ("&FormatDateTime(chatinfodata(6,i),3)&")</span><br>"&vbcrlf
			else
				response.write "<font color='#"&chatinfodata(3,i)&"'><span class='usrname' onclick=""setobj('"&chatinfodata(0,i)&"')"">"&chatinfodata(0,i)&"</span> 对 <span class='usrname' onclick=""setobj('"&chatinfodata(1,i)&"')"">"&chatinfodata(1,i)&"</span> "&chatinfodata(4,i)&" <b>&gt;&gt;</b> "&chatinfodata(2,i)&" ("&FormatDateTime(chatinfodata(6,i),3)&")</font><br>"&vbcrlf
			end if
		elseif chatinfodata(0,i)=session("userid") or chatinfodata(1,i)=session("userid") then
			response.write "<font color='#"&chatinfodata(3,i)&"'><b><span class='usrname' onclick=""setobj('"&chatinfodata(0,i)&"')"">"&chatinfodata(0,i)&"</span> 悄悄的对 <span class='usrname' onclick=""setobj('"&chatinfodata(1,i)&"')"">"&chatinfodata(1,i)&"</span> "&chatinfodata(4,i)&" <b>&gt;&gt;</b> "&chatinfodata(2,i)&" ("&FormatDateTime(chatinfodata(6,i),3)&")</b></font><br>"&vbcrlf
		end if
	next
else
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
end if
'do while not rs.eof
'	if rs("ispublic")=true or rs("sayto")="" or rs("sayto")="大家" then
'		if rs("userid")="" then
'			response.write "<span class='announce'>〖"&pagetitle&"〗公告 : "&chatinfodata(2,i)&" ("&FormatDateTime(rs("puttime"),3)&")</span><br>"&vbcrlf
'		else
'			response.write "<font color='#"&rs("textcolor")&"'><span class='usrname' onclick=""setobj('"&rs("userid")&"')"">"&rs("userid")&"</span> 对 <span class='usrname' onclick=""setobj('"&rs("sayto")&"')"">"&rs("sayto")&"</span> "&rs("userface")&" <b>&gt;&gt;</b> "&rs("saycontent")&" ("&FormatDateTime(rs("puttime"),3)&")</font><br>"&vbcrlf
'		end if
'	elseif rs("userid")=session("userid") or rs("sayto")=session("userid") then
'		response.write "<font color='#"&rs("textcolor")&"'><b><span class='usrname' onclick=""setobj('"&rs("userid")&"')"">"&rs("userid")&"</span> 悄悄的对 <span class='usrname' onclick=""setobj('"&rs("sayto")&"')"">"&rs("sayto")&"</span> "&rs("userface")&" <b>&gt;&gt;</b> "&rs("saycontent")&" ("&FormatDateTime(rs("puttime"),3)&")</b></font><br>"&vbcrlf
'	end if
'	rs.movenext
'loop
%>
<!--#include file="incfoot.asp"-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -