<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #INCLUDE FILE = "inc.asp" -->
<%
Response.Expires = 0
Response.Buffer = True
Dim iRoom, iGUID, sUserID, bSex, iAge
iRoom = Request("Room")
If iRoom = Empty Or Not IsNumeric(iRoom) Then err("非法访问房间，我们的房间是按数字进行编码的。")
iRoom = CInt(iRoom)
If iRoom < 1 Or iRoom > UBound(Application("UserList")) Then err("您所访问的房间超出了范围。")

iGUID = Request.Cookies("GUID")
If iGUID = Empty Then err("请您先登陆网站，再进入聊天室。")

sUserID = Request.Cookies("UserID")

Dim iState, dtFreeTime 'iState和dtFreeTime是引用传递，根据返回值返回相应的错误提示


Dim oChat
Set oChat = Server.CreateObject("LSChat.Users")
oChat.Configure g_SiteName, g_SiteDomain, g_DBString, g_ErrFile, g_ScriptName
oChat.login iGUID, sUserID, iRoom, iState, dtFreeTime

Select Case iState
	Case -2
		Set oChat = Nothing
		err("房间人数已满，请您选择其他房间或者稍候再进入。")
	Case -1
		Set oChat = Nothing
		err("房间暂时被锁定。")
	Case 0
		Set oChat = Nothing
		err("您的账号已被完全禁用，请与管理员联系。")
	Case 1
		'正常通过
	Case 2
		Set oChat = Nothing
		err("您的账号被暂时禁用，在" & dtFreeTime & "时间后您才能进入聊天室。")
	Case 3
		Set oChat = Nothing
		err("您并未开通聊天账号！点<a href=""regchatuser.asp"">这里</a>开通！")
	Case Else
		Set oChat = Nothing
		err("未知错误，请与作者联系。")
End Select

Dim iRoomID, sRoomName, iRoomState, sWelcome, sDescription, iCapacity, sStyle, bEmote, dtOpenTime
oChat.getRoomInfo iRoom, iRoomID, sRoomName, iRoomState, sWelcome, sDescription, iCapacity, sStyle, bEmote, dtOpenTime

Dim sVersion
sVersion = oChat.Version
Set oChat = Nothing

Dim sHTML
sHTML = "<html><head><meta http-equiv=\""Content-Type\"" content=\""text/html; charset=gb2312\""><link rel=\""stylesheet\"" href=\""ChatRoom.css\"" type=\""text/css\"">" & _
	"\n<script language=\""javascript\"" src=\""chatinc.js\""></script></head>\n" & _
	"<body vLink=\""DarkBlue\"" text=\""black\"" bgcolor=\""white\"" style=\""font-size:10.5pt;font-family:Arial,Helvetica,sans-serif\"">" & _
	"<div class=\""Welcome\"">[<span class=\""Title\"">" & sRoomName & "</span>]</div>\n<div class=\""Welcome\"">" & sWelcome & "</div><hr size=0>"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
<!--
self.onerror = null;
var MessageFrame = "<html><body bgcolor=\"#C0C0C0\" text=#ffffff><div style=\"COLOR:white;FONT-SIZE:10.5pt\" align=\"center\">正在读取资料, 请稍候 ......<br>LSChat v" + "<%=sVersion%>" + ", &copy;2002-2003 Powered By <A href='mailto:shooray@163.net'>Lion Shooray</A></div></body></html>";
var HandleMessageFrame = "<html><body bgcolor=\"black\" text=\"white\">Loading......HandleMessage</body></html>";
var RefreshFrame = "<html><body bgcolor=\"black\" text=\"white\">Loading......Refresh</body></html>";

function chatroom(){
	this.room = <%=iRoom%>;
	this.roomid = <%=iRoomID%>;
	this.roomname = "<%=sRoomName%>";
	this.roomstate = <%=iRoomState%>;
	this.welcome = "<%=sWelcome%>";
	this.description = "<%=sDescription%>";
	this.capacity = <%=iCapacity%>;
	this.opentime = "<%=dtOpenTime%>";
	this.emote = <%=bEmote%>;
	this.html = "<%=sHTML%>";
	this.version = "<%=sVersion%>";
}

function user(){
	this.guid = <%=iGUID%>;
	this.userid = "<%=sUserID%>";
	this.nickname = "<%=Session("NickName")%>";
	this.portrait = "<%=Session("Portrait")%>";
	this.sex = <%If Session("Sex") Then
		Response.Write 1
	Else
		Response.Write 0
	End If
	%>;
	this.age = <%=Session("Age")%>;
	this.chatgroup = "<%=Session("ChatGroup")%>";
	this.ip = "<%=Request.ServerVariables("REMOTE_ADDR")%>";
}

var thisChatRoom = new chatroom;
document.title = thisChatRoom.roomname + " - <%=g_SiteDomain%>";
//-->
</script>
<title>LSChat Version1.0</title>
</head>

<frameset framespacing="0" border="0" rows="*,90,0,0,0,0" frameborder="0">
	<frameset cols="*,120">
		<frameset name="Content" rows="*,0" frameSpacing="5" border="1" frameBorder="1">
			<frame name="Message" src="javascript:parent.MessageFrame" scrolling="auto" borderColor="Thistle" marginwidth="10" marginheight="10">
			<frame name="Private" src="javascript:parent.messageFrame" scrolling="auto" borderColor="Thistle" marginwidth="10" marginheight="10">
		</frameset>
		<frame name="UserList" src="UserList.asp?Room=<%=iRoom%>" scrolling="auto">
	</frameset>
	<frame name="Input" src="input.htm" scrolling="no" noresize target="_self">
	<frame name="HandleMessage" src="javascript:parent.HandleMessageFrame" noresize>
	<frame name="Refresh" src="javascript:parent.RefreshFrame" noresize>
	<frame name="Console" src="console.asp" noresize>
	<frame name="Sound" src="" noresize>
	<noframes>
		<body><p>此网页使用了框架，但您的浏览器不支持框架。</p></body>
	</noframes>
</frameset>
<body language="javascript" onerror="return window_onerror()" onload="return window_onload()">
</body>
</html>