<!-- #include file="VT_Config.asp" -->
<!--#include file="../../../Include/Class_Safe.asp" -->

<%
dim VT_RoomM_VName,VT_RoomM_VName_AV
VT_RoomM_VName = "VT_RoomM_VName"
VT_RoomM_VName_AV = "VT_RoomM_VName_AV"

dim Glb_0,Glb_1,Glb_2,Glb_3,Glb_4,Glb_5
dim Glb_WaitID,Glb_RoomID,Glb_RoomName,Glb_RoomPWD,Glb_MaxMemberNum,Glb_MemberNum,Glb_Mode
dim Glb_cnn,Glb_rs

Glb_0 = ""
Glb_1 = ""
Glb_2 = ""
Glb_3 = ""
Glb_4 = ""
Glb_5 = ""

%>

<%
'//检测用户名是否有非法字符
Function NameCheck(data,promptstr)
	dim data_len,temp,is_continue,i
	data_len = Len(data)

	if data_len<=0 then
	  NameCheck = promptstr & "不能为空"
	elseif data_len>50 then
	  NameCheck = promptstr & "超过最大长度"
	else
	  is_continue = 1
	  i = 1
	  while i<=data_len and is_continue=1
	    temp = mid(data,i,1)
	    if ( temp="~"  or temp="#" or temp="$" or temp="""" or temp="'" or temp="\" or temp="<" or temp=">") then
		is_continue = 0
	    else
	      i = i+1
	    end if
	  wend
	  if i>data_len then
  		NameCheck = "1"
	  else
		NameCheck = promptstr & "包含非法字符"
	  end if
	end if
End Function
%>



<%
Function PWDCheck(data,promptstr)
	dim data_len,temp,is_continue,i
	data_len = Len(data)

	if data_len>20 then
	  PWDCheck = promptstr & "超过最大长度"
	else
	  is_continue = 1
	  i = 1
	  while i<=data_len and is_continue=1
	    temp = mid(data,i,1)
	    if (temp="'" or temp="""") then
		is_continue = 0
	    else
	      i = i+1
	    end if
	  wend
	  if i>data_len then
  		PWDCheck = "1"
	  else
		PWDCheck = promptstr & "包含非法字符"
	  end if
	end if
End Function
%>

<% 
Function PrintTime()
	j = 1000
	i = year(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = month(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = day(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = hour(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = minute(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = second(now)
	while j>0
		response.write int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend
End Function
%>



<% 
'//日期字符串
Function GetTime()
	dim Result
	Result = ""

	j = 1000
	i = year(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = month(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = day(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = hour(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = minute(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	j = 10
	i = second(now)
	while j>0
		Result = Result & int(i/j)
		i=int(i mod j)
		j=int(j/10)
	wend

	GetTime = Result
End Function
%>



<%
Function GetRanCode()
j = ""
RANDOMIZE
i = int(rnd()*100000)
j = j & i
i = int(rnd()*100000)
j = j & i
i = int(rnd()*100000)
j = j & i
i = int(rnd()*1000)
j = j & i
i = int(rnd()*100)
j = j & i
GetRanCode = j
End Function
%>



<%
Function TimeBetween(Time_1,Time_2)
	TimeLen = 4+2+2+2+2+2
	if (len(Time_1)<>TimeLen) or (len(Time_2)<>TimeLen) then
		TimeBetween = -1
	else
		Date_1 = mid(Time_1,1,4) & "-" & mid(Time_1,5,2) & "-" & mid(Time_1,7,2)
		Date_2 = mid(Time_2,1,4) & "-" & mid(Time_2,5,2) & "-" & mid(Time_2,7,2)
		TimeBetween = datediff("s",Date_1,Date_2)		
		TimeBetween = TimeBetween + 3600*( int(mid(Time_2,9,2)) - int(mid(Time_1,9,2)) )
		TimeBetween = TimeBetween + 60*( int(mid(Time_2,11,2)) - int(mid(Time_1,11,2)) )
		TimeBetween = TimeBetween + ( int(mid(Time_2,13,2)) - int(mid(Time_1,13,2)) )
	end if		
End Function
%>



<% 
Function StrTimeToIntTime(StrTime)
	dim BaseTime
	BaseTime = "19700101000000"
	StrTimeToIntTime = TimeBetween(BaseTime,StrTime)
End Function
%>



<%
Function CreateRoom(RoomName,RoomPWD,MaxMemberNum,Mode,Mode_2,Perm)
	Application.Lock

	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")
	cnn.Open db_cnn_str
	str = "select RoomID from RoomTable where RoomTable.RoomName='" & RoomName & "'"
	set rs = cnn.Execute (str, , adCmdText)
	if not rs.eof then
		CreateRoom = "该房间已存在"
	else
		rs.close
		str = "insert into RoomTable(RoomName,RoomPWD,MemberNum,MaxMemberNum,Mode,Mode_2,Perm,ServerTime) values ('" & RoomName & "','" & RoomPWD & "'," & 0 & "," & MaxMemberNum & "," & Mode & "," & Mode_2 & "," & Perm & "," & StrTimeToIntTime(GetTime()) & ")"
		cnn.Execute str,affected, adCmdText

		str = "select RoomID from RoomTable where RoomTable.RoomName='" & RoomName & "'"
		set rs = cnn.Execute (str, , adCmdText)
		if rs.eof then
			CreateRoom = "数据库操作出错"
		else
			Glb_0 = rs("RoomID")
			CreateRoom = "1"
		end if
	end if
	rs.close
	cnn.close

	Application.Unlock
End Function
%>



<% 
Function ApplyEnter(RoomID,MemberName,Type_2)
	Application.Lock

	dim cnn
	dim rs,rs1,rs2
	dim str
	set cnn = server.createobject("adodb.connection")
	cnn.Open db_cnn_str
	str = "select * from WaitTable where WaitTable.RoomID=" & RoomID & " and WaitTable.MemberName='" & MemberName & "'"
	set rs = cnn.Execute (str, , adCmdText)
	
	if not rs.eof then
		Glb_0 = rs("WaitID")
		Glb_1 = rs("EnterVerify")
		Glb_2 = rs("ServerCode")
		Glb_3 = rs("ExitVerify")
		ApplyEnter = "1"
	else
		str = "select * from RoomTable where RoomTable.RoomID=" & RoomID
		set rs1 = cnn.Execute (str, , adCmdText)
		
		str = "select MemberID from MemberTable where MemberTable.RoomID=" & RoomID & " and MemberTable.MemberName='" & MemberName & "'"
		set rs2 = cnn.Execute (str, , adCmdText)

		if rs1.eof then
			ApplyEnter = "该房间不存在"
		elseif not rs2.eof then
			ApplyEnter = "用户已在房间内"
		elseif rs1("MemberNum") >= rs1("MaxMemberNum") then
			ApplyEnter = "房间已满"
		else
			rs.close
			str = "insert into WaitTable(MemberName,Type_2,RoomID,EnterVerify,ExitVerify,ServerCode,ServerTime) values ('" & MemberName & "'," & Type_2 & "," & RoomID & ",'" & GetRanCode() & "','" & GetRanCode() & "','" & GetRanCode() & "'," & StrTimeToIntTime(GetTime()) & ")"
			cnn.Execute str,affected, adCmdText

			str = "select * from WaitTable where WaitTable.RoomID=" & RoomID & " and WaitTable.MemberName='" & MemberName & "'"
			set rs = cnn.Execute (str, , adCmdText)
			if rs.eof then
				ApplyEnter = "数据库操作出错"
			else
				Glb_0 = rs("WaitID")
				Glb_1 = rs("EnterVerify")
				Glb_2 = rs("ServerCode")
				Glb_3 = rs("ExitVerify")
				ApplyEnter = "1"
			end if
			
		end if

		rs1.close
		rs2.close
	end if
	rs.close
	cnn.close
	Application.Unlock
End Function
%>



<%
'//获得放房主
Function GetRoomM(RoomID)
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	'str = "select MemberName from MemberTable where MemberID in (select min(MemberID) from MemberTable where RoomID=" & RoomID & ")"
	Str = "Select M.MemberName From MemberTable As M,RoomTable As R Where R.RoomId=M.Roomid And R.RoomRenName=M.MemberName"
	set rs = cnn.Execute (str, , adCmdText)	

	if rs.eof then
		GetRoomM = ""
	else
		GetRoomM = rs("MemberName")
	end if

	rs.close
	cnn.close		
End Function
%>



<%
Function EnterRoom(WaitID,ClientID,Type_1,EnterVerify)
	Application.Lock

	dim IsEnterOK
	IsEnterOK = 0
	dim RoomID
	RoomID = 0

	dim cnn
	dim rs,rs1,rs2
	dim str
	set cnn = server.createobject("adodb.connection")
	cnn.Open db_cnn_str
	str = "select * from WaitTable where WaitTable.WaitID=" & WaitID
	set rs = cnn.Execute (str, , adCmdText)

	if rs.eof then
		EnterRoom = -1
	elseif rs("EnterVerify") <> EnterVerify then
		EnterRoom = -1
	else
		RoomID = rs("RoomID")

		str = "select * from RoomTable where RoomTable.RoomID=" & rs("RoomID")
		set rs1 = cnn.Execute (str, , adCmdText)
		str = "select MemberID from MemberTable where MemberTable.WaitID=" & rs("WaitID")
		set rs2 = cnn.Execute (str, , adCmdText)

		if rs1.eof then
			rs1.close
			rs2.close
			EnterRoom = -2
		elseif not rs2.eof then
			rs1.close
			rs2.close
			EnterRoom = -3
		elseif rs1("MemberNum")>=rs1("MaxMemberNum") then
			rs1.close
			rs2.close
			EnterRoom = -4
		else
			rs1.close
			rs2.close

			Glb_1 = GetTime()
			str = "insert into MemberTable(WaitID,MemberName,Type_2,RoomID,ClientID,Type,ServerCode,ExitVerify,ServerTime,MemberNum) values (" & WaitID & ",'" & rs("MemberName") & "'," & rs("Type_2") & "," & rs("RoomID") & ",'" & ClientID & "'," & Type_1 & ",'" & rs("ServerCode") & "','" & rs("ExitVerify") & "'," & StrTimeToIntTime(Glb_1) & "," & 0 & ")"
			cnn.Execute str,affected, adCmdText

			str = "update RoomTable set RoomTable.MemberNum = RoomTable.MemberNum + 1 where RoomTable.RoomID =" & rs("RoomID")
			cnn.Execute str, , adCmdText

			rs.close

			str = "delete from WaitTable where WaitTable.WaitID=" & WaitID
			cnn.Execute str, , adCmdText

			str = "select MemberID from MemberTable where MemberTable.WaitID=" & WaitID
			set rs = cnn.Execute (str, , adCmdText)
			if rs.eof then
				EnterRoom = -5
			else
				Glb_0 = rs("MemberID")
				EnterRoom = 1
				IsEnterOK = 1
			end if
		end if
	end if
	rs.close
	cnn.close

	if IsEnterOK=1 then
		Application(VT_RoomM_VName & "_" & RoomID & "_" & VT_SysNum) = GetRoomM(RoomID)
		Application(VT_RoomM_VName_AV & "_" & RoomID & "_" & VT_SysNum) = 1		
	end if

	Application.Unlock
End Function
%>



<%
Function ExitRoom(MemberID,ExitVerify)

	dim cnn
	dim rs
	dim str
	dim RoomID
	RoomID = 0

	set cnn = server.createobject("adodb.connection")
	cnn.Open db_cnn_str
	str = "select * from MemberTable where MemberTable.MemberID=" & MemberID
	set rs = cnn.Execute (str, , adCmdText)

	if rs.eof then
		rs.close
		ExitRoom = -1
	elseif rs("ExitVerify") <> ExitVerify then
		rs.close
		ExitRoom = -1
	else	
		RoomID = rs("RoomID")
		str = "update RoomTable set RoomTable.MemberNum = RoomTable.MemberNum - 1 where RoomTable.RoomID =" & rs("RoomID")
		cnn.Execute str, , adCmdText

		str = "update RoomTable set RoomTable.ServerTime = " & StrTimeToIntTime(GetTime()) & " where RoomTable.RoomID =" & rs("RoomID")
		cnn.Execute str, , adCmdText
	
		rs.close
		str = "delete from MemberTable where MemberTable.MemberID=" & MemberID
		cnn.Execute str, , adCmdText

		ExitRoom = 1
	end if
	
	cnn.close

	if RoomID<>0 then
		Application.Lock
		Application(VT_RoomM_VName & "_" & RoomID & "_" & VT_SysNum) = GetRoomM(RoomID)
		Application(VT_RoomM_VName_AV & "_" & RoomID & "_" & VT_SysNum) = 1
		Application.Unlock
	end if
End Function
%>



<%
Function MemberList(MemberID,ServerCode)
	Application.Lock

	dim cnn
	dim rs
	dim str
	dim RoomID
	set cnn = server.createobject("adodb.connection")
	cnn.Open db_cnn_str
	str = "select MemberID,RoomID,ServerCode from MemberTable where MemberTable.MemberID=" & MemberID
	set rs = cnn.Execute (str, , adCmdText)
	
	response.write "#"
	if rs.eof then
		rs.close
		response.write "-1$"
	elseif rs("ServerCode") <> ServerCode then
		rs.close
		response.write "-1$"
	else
		RoomID = rs("RoomID")
		rs.close
		
		str = "select ClientID from MemberTable where MemberTable.RoomID=" & RoomID
		set rs = cnn.Execute (str, , adCmdText)

		response.write "1"
		while not rs.eof
			response.write "#" & rs("ClientID")
			rs.MoveNext
		wend
		rs.close

		response.write "$"
	end if

	cnn.close
	Application.Unlock
End Function
%>



<%
Function Report(MemberID,ServerCode)
	Application.Lock
	
	dim ServerTime
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select MemberID,ServerCode from MemberTable where MemberTable.MemberID=" & MemberID
	set rs = cnn.Execute (str, , adCmdText)	

	if rs.eof then
		Report = -1
		rs.close
	elseif rs("ServerCode") <> ServerCode then
		Report = -1
		rs.close
	else
		rs.close

		ServerTime = GetTime()
		str = "update MemberTable set MemberTable.ServerTime=" & StrTimeToIntTime(ServerTime) & " where MemberTable.MemberID=" & MemberID
		cnn.Execute str, , adCmdText

		Glb_0 = ServerTime
		Report = 1
	end if

	cnn.close
	Application.Unlock
End Function
%>



<%
Function Member(WaitID,ServerCode)
	Application.Lock
	
	dim MemberID
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select MemberID,ServerCode from MemberTable where MemberTable.WaitID=" & WaitID
	set rs = cnn.Execute (str, , adCmdText)	

	if rs.eof then
		rs.close
		str = "select WaitID,ServerCode from WaitTable where WaitTable.WaitID=" & WaitID
		set rs = cnn.Execute (str, , adCmdText)
	end if

	if rs.eof then
		rs.close
		Member = -1
	elseif rs("ServerCode") <> ServerCode then
		rs.close
		Member = -1
	else
		rs.close

		str = "select MemberID,ClientID from MemberTable where MemberTable.Type=1 and MemberTable.MemberNum in (select Min(MemberNum) from MemberTable where MemberTable.Type=1)"
		set rs = cnn.Execute (str, , adCmdText)
		if rs.eof then
			rs.close
			Member = -2
		else
			Glb_0 = rs("ClientID")
			MemberID = rs("MemberID")
			rs.close

			str = "update MemberTable set MemberTable.MemberNum = MemberTable.MemberNum + 1 where MemberTable.MemberID=" & MemberID
			cnn.Execute str, , adCmdText

			Member = 1
		end if
	end if

	cnn.close
	Application.Unlock	
End Function
%>



<%
Sub CleanWaitTable()
	Application.Lock
		
	Threshold_1 = StrTimeToIntTime(GetTime())-WaitTableDelSec

	dim cnn
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str

	str = "delete from WaitTable where WaitTable.ServerTime<" & Threshold_1
	cnn.Execute str, , adCmdText

	cnn.close
	Application.Unlock	
End Sub
%>



<%
Sub CleanMemberTable()
	Application.Lock
		
	Threshold_1 = StrTimeToIntTime(GetTime())-MemberTableDelSec

	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select MemberID,ExitVerify from MemberTable where MemberTable.ServerTime<" & Threshold_1
	set rs = cnn.Execute (str, , adCmdText)
	
	while not rs.eof
		ExitRoom rs("MemberID"),rs("ExitVerify")
		rs.MoveNext
	wend

	rs.close
	cnn.close		
	Application.Unlock	
End Sub
%>



<%
Sub CleanRoomTable()
	Application.Lock
		
	Threshold_1 = StrTimeToIntTime(GetTime())-RoomTableDelSec

	dim cnn
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str

	str = "delete from RoomTable where RoomTable.MemberNum<=0 and RoomTable.Perm=0 and RoomTable.ServerTime<" & Threshold_1
	cnn.Execute str, , adCmdText	
	
	cnn.close		
	Application.Unlock	
End Sub
%>



<%
Function DeleteRoom(RoomName)
	Application.Lock
		
	dim cnn
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "delete from RoomTable where RoomTable.RoomName='" & RoomName & "' and RoomTable.MemberNum<=0"
	cnn.Execute str, affected, adCmdText
	if affected>0 then
		DeleteRoom = 1
	else
		DeleteRoom = 0
	end if

	cnn.close		
	Application.Unlock	
End Function
%>



<%
Function GetRoomInfo(RoomID)
	Application.Lock
	
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select RoomName,RoomPWD,MemberNum,MaxMemberNum,Mode from RoomTable where RoomTable.RoomID=" & RoomID
	set rs = cnn.Execute (str, , adCmdText)	

	if rs.eof then
		rs.close
		GetRoomInfo = "无此房间"
	else
		Glb_RoomName = rs("RoomName")
		Glb_RoomPWD = rs("RoomPWD")
		Glb_MaxMemberNum = rs("MaxMemberNum")
		Glb_MemberNum = rs("MemberNum")
		Glb_Mode = rs("Mode")
		rs.close
		GetRoomInfo = "1"
	end if

	cnn.close		
	Application.Unlock	
End Function
%>



<%
Function PrintRoomList()
	Application.Lock
		
	dim cnn
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select RoomID,RoomName,RoomPWD,MemberNum,MaxMemberNum,Mode from RoomTable order by RoomID"
	set rs = cnn.Execute (str, , adCmdText)	
%>

<table width="80%" border=0 align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr bgcolor="eeeeee"> 
    <td>房间ID</td> 
    <td>房间名称</td> 
    <td>房间人数</td> 
    <td>房间类型</td> 
    <td>操作</td> 
  </tr>

<%
	while not rs.eof
%>

  <tr bgcolor="#FFFFFF"> 
    <td><%=rs("RoomID")%></td>
	<td><%=rs("RoomName")%></td>
	<td><%=rs("MemberNum")%>/<%=rs("MaxMemberNum")%></td>
	<td>视频聊天</td>
	<td align="center"> 
      <%if rs("MemberNum")<rs("MaxMemberNum") then%>
	<form method="POST" action="talk.asp">
		<%if rs("RoomPWD")<>"" then%>
			密码:<input type="password" name="RoomPWD" size="20">
		<%end if%>
		<input type="hidden" name="RoomID" value="<%=rs("RoomID")%>">
		<input type="hidden" name="RoomName" value="<%=rs("RoomName")%>">
		<input type="submit" value="进入" name="B1">
	</form>
<%else%>
房间已满<br><br>
<%end if%>

	</td>
	</tr>
<%
		rs.MoveNext
	wend
%>

</table>

<%
	rs.close
	cnn.close		
	Application.Unlock	
End Function
%>



<%
Function User_ApplyEnter(RoomID,MemberName)
	Type_2 = 0

	dim cnn
	dim rs
	dim str

	nReturn = ApplyEnter(RoomID,MemberName,Type_2)
	if nReturn="1" then
		set cnn = server.createobject("adodb.connection")

		cnn.Open db_cnn_str
		str = "select * from RoomTable where RoomTable.RoomID=" & RoomID
		set rs = cnn.Execute (str, , adCmdText)	
		
		if rs.eof then
			User_ApplyEnter = "无此房间"
		else
%>
<object id="n1" classid="CLSID:06043483-955B-4051-992B-D792A0907953"
width=0% height=0%>
</object>
<script language="javascript">
n1.Init("<%=SiteURL%>", <%=RoomID%>, "<%=rs("RoomName")%>", <%=rs("Mode")%>, <%=rs("Mode_2")%>, <%=rs("MaxMemberNum")%>, <%=Glb_ReportTime%>, <%=Glb_MemberListTime%>, <%=Glb_0%>, "<%=MemberName%>", "<%=Glb_1%>", "<%=Glb_2%>", "<%=Glb_3%>", 0, "");
</script>

<%
			User_ApplyEnter = "1"
			Glb_WaitID = Glb_1
			Glb_RoomID = RoomID
		end if
		rs.close
		cnn.close
	elseif nReturn="用户已在房间内" then
		set cnn = server.createobject("adodb.connection")

		cnn.Open db_cnn_str
		str = "select * from RoomTable where RoomTable.RoomID=" & RoomID
		set rs = cnn.Execute (str, , adCmdText)	
		
		if rs.eof then
			User_ApplyEnter = "无此房间"
		else
%>

<object ID="n1" classid="CLSID:06043483-955B-4051-992B-D792A0907953"
width=0% height=0%>
</object>
<script language="javascript">
n1.Init("<%=SiteURL%>", <%=RoomID%>, "<%=rs("RoomName")%>", <%=rs("Mode")%>, <%=rs("Mode_2")%>, <%=rs("MaxMemberNum")%>, <%=Glb_ReportTime%>, <%=Glb_MemberListTime%>, 1	 , "<%=MemberName%>", "~"	  , "~"		, "~"	      , 0, "");
</script>
<%
			User_ApplyEnter = nReturn
			Glb_WaitID = 1
			Glb_RoomID = RoomID
		end if
		rs.close
		cnn.close
	else
		User_ApplyEnter = nReturn
	end if
End Function
%>



<%
Function User_CreateRoom(RoomName,RoomPWD,MaxMemberNum,Mode,Perm)
	User_CreateRoom = CreateRoom(RoomName,RoomPWD,MaxMemberNum,Mode,0,Perm)
	Glb_RoomID = Glb_0
End Function
%>



<%
Function User_Screen(RoomID,Num,Width,Height)
%>
<TABLE borderColor=#e8e8e8 
                                align=center border=10>
  <TBODY>
    <TR> 
      <TD align="center" bgColor=#999999>
<object id="Screen_n<%=Num%>" classid="CLSID:80215441-26D5-4644-9ACE-2C48C352485A"
width=<%=Width%> height=<%=Height%>>
        </object>
      </TD>
    </TR>
  </TBODY>
</TABLE>
<script language="javascript">
Screen_n<%=Num%>.Init("<%=SiteURL%>",<%=RoomID%>,<%=Num%>);
</script>
<%
End Function
%>



<%
Sub GetMemberOfRoomBegin(RoomID)
	dim str
	set Glb_cnn = server.createobject("adodb.connection")

	Glb_cnn.Open db_cnn_str
	str = "select MemberName from MemberTable where MemberTable.RoomID=" & RoomID
	set Glb_rs = Glb_cnn.Execute (str, , adCmdText)	
End Sub
%>



<%
Function GetNextMemberOfRoom()
	if not Glb_rs.eof then
		GetNextMemberOfRoom = Glb_rs("MemberName")
		Glb_rs.MoveNext
	else
		GetNextMemberOfRoom = ""
	end if
End Function
%>



<%
Sub GetMemberOfRoomEnd()
	Glb_rs.close
	Glb_cnn.close		
End Sub
%>



<%
Function DelMemberOfRoom(MemberName,RoomID)
	Application.Lock
		
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select MemberID,ExitVerify from MemberTable where MemberTable.MemberName='" & MemberName & "' and MemberTable.RoomID=" & RoomID
	set rs = cnn.Execute (str, , adCmdText)	

	if not rs.eof then
		ExitRoom rs("MemberID"),rs("ExitVerify")
		DelMemberOfRoom = "1"
	else
		DelMemberOfRoom = "此用户不在该房间内"
	end if

	rs.close
	cnn.close		
	Application.Unlock	
End Function
%>



<%
Function IsInRoom(MemberName,RoomID)
	dim cnn
	dim rs
	dim str
	set cnn = server.createobject("adodb.connection")

	cnn.Open db_cnn_str
	str = "select MemberID from MemberTable where MemberTable.MemberName='" & MemberName & "' and MemberTable.RoomID=" & RoomID
	set rs = cnn.Execute (str, , adCmdText)	

	if not rs.eof then
		IsInRoom = "1"
	else
		IsInRoom = "0"
	end if

	rs.close
	cnn.close		
End Function 
%>



<%
Sub User_CleanTable()
	Application.Lock
	dim TimeName_1,TimeName_2
	dim time_1
	TimeName_1 = "VT_IsCleanTableTimeV" & VT_SysNum
	TimeName_2 = "VT_CleanTableTime" & VT_SysNum
	if Application(TimeName_1)=1 then
		time_1 = StrTimeToIntTime(GetTime())
		if time_1-Application(TimeName_2)>MinCleanTableSpanSec then
			CleanWaitTable
			CleanMemberTable
			CleanRoomTable
			Application(TimeName_2) = StrTimeToIntTime(GetTime())
			Application(TimeName_1) = 1
		end if
	else
		Application(TimeName_2) = 0
		Application(TimeName_1) = 1
	end if
	Application.Unlock	
End Sub
%>



<%
Function User_GetRoomM(RoomID)
	if Application(VT_RoomM_VName_AV & "_" & RoomID & "_" & VT_SysNum) = 1 then
		User_GetRoomM = Application(VT_RoomM_VName & "_" & RoomID & "_" & VT_SysNum)
	else
		User_GetRoomM = ""
	end if
End Function
%>
