<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/util.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<HTML>
<HEAD>
<TITLE>管理直播</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 12pt;
}
</style>
<script language="JavaScript" src="../js/PublicJS.js"></script>
</HEAD>
<BODY>
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p17")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,content,flag,styleStr,liveid,livename
if not isEmpty(request("flag")) then
	flag=Cint(request("flag"))
else
	flag=1
end if
if(flag=1) then
	styleStr=" class=""style1"""
	flag=0
elseif(flag=0) then
	styleStr=" class=""style2"""
	flag=1
end if
act=request.QueryString("act")
if(request.QueryString("id")<>"") then
	liveid=Cint(request.QueryString("id"))
end if
livename=request.QueryString("title")
if(act="add") then	
	content=request.Form("content1")
	'替换快捷键
	set rs=server.createobject("adodb.recordset")
	sql="select key_s,key_c from t_live_key where liveid="&liveid&" or liveid=0 order by id desc"
	rs.open sql,conn,3,1
	while not rs.eof
		content=replace(content,rs(0),rs(1))
		rs.movenext
	wend
	rs.close
	set rs=nothing
	'
	content="<li"&styleStr&">"&now&"直播员说：<br>"&content&" ["&now&"]</li>"&Chr(10)
	application.Lock()
	application("msg"&liveid)=application("msg"&liveid)&content
	application.UnLock()
	if isempty(application("expireTime")) then
		application.Lock()
		application("expireTime")=DateAdd("s",30,now)
		application.UnLock()
	end if
	if(CDate(application("expireTime"))<now) then
		'response.Write("add xml")'记录到服务器文件
		Set fs=Server.CreateObject("Scripting.FileSystemObject")
		Set file_w = fs.CreateTextFile(server.mappath("../live/"&liveid&".txt"),true)	
		file_w.WriteLine(application("msg"&liveid))		
		file_w.close
		set file_w=nothing
		set fs=nothing
		application.Lock()
		application("expireTime")=DateAdd("s",30,now)
		application.UnLock()
	end if
	response.Write("<script>parent.frames[""live_topFrame""].location='/live.asp?id="&liveid&"';parent.frames[""live_topFrame""].window.scroll(0,3000000);</script>")
elseif(act="clear") then
	application.Lock()
	application("msg"&liveid)=""
	application.UnLock()
	Set fs=Server.CreateObject("Scripting.FileSystemObject")
	Set file_w = fs.CreateTextFile(server.mappath("../live/"&liveid&".txt"),true)	
	file_w.WriteLine("")		
	file_w.close
	set file_w=nothing
	set fs=nothing
	response.Write("成功清除")
	response.Write("<script>parent.frames[""live_topFrame""].location='/live.asp?id="&liveid&"';parent.frames[""live_topFrame""].window.scroll(0,3000000);</script>")
end if
%>
<FORM method="POST" name="form1" action="?act=add&id=<%=liveid%>&title=<%=livename%>&flag=<%=flag%>" style="margin:0 0 0 0;">
<TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#F5F5F5">
  <TD height="50" align=right valign="top" bgcolor="#F5F5F5">
  <h5>==快捷键==</h5>
  <div style="overflow:scroll">
  <ul>
  	<%
	set rs=server.createobject("adodb.recordset")
	rs.open "select key_s,key_c from t_live_key where liveid=0 or liveid="&liveid&" order by id desc",conn,3,1
	while not rs.eof
		response.Write("<Li><a href=""#"" title="""&rs(1)&""" onclick=""pasteKey('"&rs(0)&"')"">"&rs(0)&"</a></Li>"&Chr(10))
		rs.movenext
	wend
	rs.close
	set rs=nothing
	%>  	
  </ul>
  </div></TD>
  <TD align=right bgcolor="#F5F5F5">
    <div align="left">
      <INPUT type="hidden" name="content1" value="">
    </div>
    <div align="left">
      <iframe id="eWebEditor1" src="webedit/editor.html" frameborder="0" scrolling="no" width="98%" height="350"></iframe>
    </div>    </TD>
</TR>
<TR bgcolor="#F5F5F5">
	<TD width="14%" height="50" align=right bgcolor="#F5F5F5">&nbsp;	  </TD>
    <TD width="86%" align=right bgcolor="#F5F5F5"><div align="left"> 
        <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
        <input type=reset name=b2 value="重 填">    
		<a href="?act=clear&id=<%=liveid%>" onClick="return confirm('确认清空该直播内容吗?')">清除该直播内容</a>
    </div></TD>
</TR>
</TABLE>
</FORM>
<script type="text/javascript">
function pasteKey(str){
	//var sel = eWebEditor1.eWebEditor.document.selection.createRange();
	//sel.pasteHTML(str);
	var html = eWebEditor1.eWebEditor.document.body.innerHTML;
	eWebEditor1.eWebEditor.document.body.innerHTML=html+str;
}
</script>
</BODY>
</HTML>
<%
call connclose()
%>