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

📄 enter.asp

📁 聊天室
💻 ASP
字号:
<%@ Language=VBScript %>
<HTML>
<HEAD>
<title>聊天室程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>
</HEAD>
<BODY>

<script language="jscript">
<!--
	function Check()
	{ 
		var NotNull
		NotNull=true

			if (document.room.topic.value  =="")
			{
				window.alert("请输入聊天室话题!")
				NotNull=false
			}
			
			if (document.room.newroom.value  =="")  
			{
				window.alert("请输入新房间名!")
				NotNull=false
			}
			
			return NotNull

	}
//-->	

</script>



<%

if Request.ServerVariables ("REQUEST_METHOD")="POST"  then
	dim UserID,IPAdd,UserPwd,NickName,TimeLogin
	dim mysql,mysql1
	
	UserID=Request.Form ("UID")
	UserPwd=Request.Form ("PWD")
	NickName=Request.Form ("NickName")
	session("nickname")=NickName
	
	set myconn=server.CreateObject ("ADODB.Connection")
	myconn.ConnectionString ="DSN=ChatRoom"
	myconn.Open 
	
	mysql="select UserID,PWD,IfClosed,OpenTime from EverUser where UserID='" & UserID & "' and PWD='" & UserPwd & "'"
	mysql1="select IPAdd,TimeOpen,IfClosed from FaultIpAdd where IPAdd='" & Request.ServerVariables ("Remote_Host") & "'"
	mysql2="update EverUser set NickName='" & NickName & "',IPAdd='" & Request.ServerVariables ("Remote_Host") & "',TotalVisit=TotalVisit+1 where UserID='" & UserID & "'"
	mysql3="insert into UserOnLine (UserID,PWD,NickName) values ('" & UserID & "','" & UserPwd & "','" &  NickName &  "')" 
	mysql4=	"select * from RoomInfo"
	mysql5="select * from UserOnLine where UserID='" & UserID & "'"
	
	set myrecord0=myconn.Execute (mysql5)
	
	if not myrecord0.bof then

		if dateadd("n",5,myrecord0("TimeLastTalking"))>now then
			Response.Write ("你已经登录过了,请在五分钟后再登录!")
			Response.End 
		else
			newsql="delete from UserOnLine where UserID='" & UserID & "'"
		end if
	end if
	
	set myrecord1=myconn.Execute (mysql1)
	
	'确定是否以前曾经被封过,并判断现在是否已经被解封
	if not myrecord1.bof then
		if myrecord1("IfClosed")<>true then
			IfClosed=1
		end if
	end if

	if myrecord1.bof  or IfClosed=1 then
		
		set myrecord=myconn.Execute(mysql)
	
		if myrecord.eof then
			Response.Write ("密码或帐号输入错误!<a href='default.asp'>请重新登录</a>")
			Response.End 
		elseif myrecord("IfClosed") then
			if myrecord("OpenTime")<date() then
			Response.Write ("你的帐号刚刚被解封,<a href='default.asp'>请重新登录</a>,以后请注意!")
			mysql="update EverUser set IfClosed=false where UserID='" & UserID & "'"
			myconn.Execute (mysql)  
			Response.End 
			
			else
			Response.Write ("你的帐号已经被封,到" & myrecord("OpenTime") & "才开放!")
			Response.End 
			
			end if
		else
			if session("refresh")="" then
				myconn.Execute (mysql2)
				myconn.Execute (mysql3)
				session("refresh")=true
			end if
			
			set myrecord2=myconn.Execute (mysql4)
			
			
%>


<form name="room" action="main.asp" method="post" onsubmit="return Check()">
<table border="0" width="100%" bgcolor="#5A8BCE" height="39" cellspacing="1" cellpadding="5">
  <tr>
    <td width="50%" height="18" bgcolor="#E6F7FF">
      <p align="center"><font color="#000000">新建聊天室</font></p></td>
    <td width="50%" height="18" bgcolor="#E6F7FF">
      <p align="center"><font color="#000000">话题</font></p></td>
    <td width="50%" height="18" bgcolor="#E6F7FF">
      <p align="center"><input type="submit" class="smallInput"  value="提交"></p>
    </td>
  </tr>
 
  <tr>
    <td width="50%" height="9" bgcolor="#FFFFFF">
      <p align="center"><input name="newroom" class="smallInput" 
     ></p>
    </td>
    <td width="50%" height="9" bgcolor="#FFFFFF">
      <p align="center"><input name="topic" class="smallInput" 
     ></p>
    </td>
    <td width="50%" height="9" bgcolor="#E6F7FF">
      <p align="center"><input name="B2" type="reset" class="smallInput"  value="清除"></p></td>
  </tr>
</table>

<input type="hidden" name="user" value=<% =UserID %> >
</form>




<hr size="1" color="#000080">
<table width="100%" height="76" border="0" cellpadding="5" cellspacing="1" bgcolor="#E6F7FF">
  <tr>
    <td width="10%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">房间号</span></td>
    <td width="20%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">房间名称</span></td>
    <td width="20%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">话题</span></td>
    <td width="20%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">聊天人数</span></td>
    <td width="15%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">是否上锁</span></td>
    <td width="15%" height="48" align="middle" bgcolor="#E6F7FF"><span class="style2">创建者</span></td>
  </tr>
  
<%
	do while not myrecord2.eof  
	
		if myrecord2("IfLocked")=true then
			newsql="select UserID from UserOnLine where RoomName='" & myrecord2("RoomName") & "' and UserID='" & myrecord2("WhoCreate") & "'"
			set myrecord3=myconn.Execute(newsql)
			if myrecord3.bof then
				newsql="update RoomInfo set IfLocked=false where RoomName='" & myrecord2("RoomName") & "'"
				myconn.Execute (newsql)
				Changed=true
			end if
			myrecord3.close
		end if
%> 
  
  <tr bgcolor="#FFFFFF">
    <td width="10%" height="2" align="middle"><P class="style2">
<% =myrecord2("RoomID") %>
    </P></td>
<%
	if myrecord2("IfLocked")=false or Changed=true then
%>
    <td width="20%" height="2" align="middle"><span class="style2">
      <% =myrecord2("RoomName") %>    
    <FONT color=maroon size=2><a href=main.asp?roomname=<% =myrecord2("RoomName") %>&user=<% =UserID %>>进入</a></span></td>
<%
	else
%>
    <td width="20%" height="2" align="middle"><span class="style2">
      <% =myrecord2("RoomName") %>    
    <FONT color=maroon size=2>锁住</a></span></td>
<%
	end if
%>
    <td width="20%" height="2" align="middle"><P class="style2">
      <%  =myrecord2("Topic")  %>
    </P></td>
    <td width="20%" height="2" align="middle"><P class="style2">
      <% =myrecord2("HowManyUsers") %>
    </P></td>
    <td width="15%" height="2" align="middle"><P class="style2">
      <% =myrecord2("IfLocked") %>
    </P></td>
    <td width="15%" height="2" align="middle"><P class="style2">
      <% =myrecord2("WhoCreate") %>
    </P></td>
  </tr>
<P>

<%
		myrecord2.movenext
		
		loop
%>

</table>


<%			
		
		end if
	else
		if myrecord1("TimeOpen")<date() then
			Response.Write ("你的IP地址刚刚被解封,<a href='default.asp'>请重新登录</a>,请以后注意!")
			mysql="update FaultIpAdd set IfClosed=false where IpAdd='" & Request.ServerVariables ("Remote_Host") & "'"
			myconn.Execute (mysql)
			Response.End 

		else
			Response.Write ("你的IP地址已经被封住了,直到" & myrecord1("TimeOpen") & "才能开放!")
			Response.End 
		end if

	end if
	
	myrecord.close
	set myrecord=nothing
		
	myrecord1.close
	set myrecord1=nothing
	
	myrecord2.close
	set myrecord2=nothing
	set myconn=nothing
end if

%>



</P>



</BODY>
</HTML>

⌨️ 快捷键说明

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