<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<!--#include file="../Cache/QvodCms.Player.asp"-->
<%
Dim action,del_id,server_id,server_playerid,server_orderid,server_name,server_all,server_typeid
action=Trim(Request.QueryString("action"))
del_id=QvodCms_CLng(Request.QueryString("del_id"))
server_id=QvodCms_CLng(Request.Form("server_id"))
server_playerid=QvodCms_CLng(Request.Form("server_playerid"))
server_orderid=QvodCms_CLng(Request.Form("server_orderid"))
server_name=Trim(Request.Form("server_name"))
server_all=Trim(Request.Form("server_all"))
server_typeid=QvodCms_CLng(Request.Form("server_typeid"))
'打开数据库连接
Call OpenConn()
'
If action="add" Then
    Call server_add
Elseif action="edit" Then
    Call server_edit
ElseIf action="del" Then
    Call server_del
Else
%><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>管理页面</TITLE>
<link href="skins/css/jaja_main.css" rel="stylesheet" type="text/css" />
<script language = "javaScript" src = "QvodCms_All.js" type="text/javascript"></script>
<style type="text/css">input{color: #555}</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th colspan=7 class="title">服务器组管理</th>
</tr>
<tr style="text-align:center;">
<td width="30" class="td2">ID</td>
<td width="120" class="td2">播放器选择</td>
<td width="130" class="td2">服务器组名称描述</td>
<td width="150" class="td2">服务器组共用部份</td>
<td width="60" class="td2">前台排序</td>
<td class="td2" style="text-align:left">相关操作</td>
</tr><%
	'Dim maxid:maxid=QvodCms_MaxId("server")'通过调用函数得到当前最大ID
	Set rs = Server.CreateObject("adodb.recordset")
	sql = "select * from qvodcms_server order by server_orderid asc"
	rs.Open sql, Conn, 1, 1
	If Not(rs.bof And rs.eof) Then
		Do while not rs.eof
	%>
<form method="post" action="?action=edit" name="编辑">
<tr bgcolor="#FFFFFF" onMouseOver="javascript:this.bgColor='#E3E1D7'" onMouseOut="javascript:this.bgColor='#FFFFFF'">
  <td style="text-align:center;height:28px;"><%=rs("server_id")%>.<input name="server_id" type="hidden" value="<%=rs("server_id")%>" /></td>
  <td ><%Call server_list_playerid%></td>
  <td ><input size=15 type="text" name="server_name" value="<%=rs("server_name")%>"></td>
  <td ><input size=18 type="text" name="server_all" value="<%=rs("server_info")%>"></td>
  <td ><input size=5 type="text" name="server_orderid" value="<%=rs("server_orderid")%>"></td>
  <td ><input type="submit" value="更 新">&nbsp;&nbsp;<input type="button" value="删 除" onClick="javascript:QvodCmsimdel('?action=del&del_id=<%=rs("server_id")%>','你将删除这个服务器组,并且连同删除该组下的所有播放地址!','该操作不可恢复，确认吗？');" name="Input"> <select name="server_typeid" ><option value="1">显示</option><option value="0" <%If rs("server_typeid")<>1 Then Response.Write("selected=""selected""")%>>隐藏</option></select></td>
  </tr>
</form><%
		rs.movenext  
		loop
	Else
		Response.Write("暂未添加任何服务组,请在下方添加！")	 
	End If
	rs.Close
	Set rs=nothing
	%>
<form method="post" action="?action=add" name="添加">
<tr style="text-align:center;">
  <td class="td1"><span class="addnew">加→</span></td>
  <td class="td1"><%Call server_add_playerid%></td>
  <td class="td1"><input size=15 type="text" name="server_name" onFocus="if(this.value=='前台说明')this.value='';" value="前台说明" style="color: #999"></td>
  <td class="td1"><input size=18  type="text" name="server_all"  onfocus="if(this.value=='共用地址部份')this.value='';" value="共用地址部份" style="color: #999"></td>
  <td class="td1"><input size=5 type="text" name="server_orderid" value="<%=QvodCms_MaxId("server")%>" style="color: #999"></td>
  <td class="td1" style="text-align:left"><input type="submit" value="添 加" name="Submit"> <select name="server_typeid" ><option value="1">后台添加影片时显示该组</option><option value="2">后台添加影片时隐藏该组</option></select></td>
  </tr>
</form>
<tr>
<th colspan=7>注1:隐藏后的服务器组将不会出现在<font color="#FF0000">后台</font>添加影片时的表单列表里!<br>注2:将排序ID设为0后,前台与后台将不会显示该组的播放地址与添加表单!</th>
</tr>
</table>
</body>
</html>
<%End If
'关闭数据库连接
Call CloseConn()
Sub server_add
	If server_name="" Then 
		Call QvodCms_Err("服务器组名字不能为空！")
	Else
	    Conn.Execute(" Insert Into [QvodCms_server] (server_id,server_playerid,server_orderid,server_name,server_all,server_typeid) values ("&QvodCms_MaxId("server")&","&server_playerid&","&server_orderid&",'"&server_name&"','"&server_all&"',"&server_typeid&") ")
	End If
	Response.Redirect "QvodCms_server.asp"
End Sub
Sub server_edit
    If server_name="" Then Call QvodCms_Err("服务器组名字不能为空！")
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from QvodCmsim_server where server_id="&server_id&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
	    rs("server_playerid")=server_playerid
		rs("server_orderid")=server_orderid
		rs("server_name")=server_name
		rs("server_all")=server_all
		rs("server_typeid")=server_typeid
		rs.update
	End If
	rs.Close
	set rs=nothing
	Response.Redirect "QvodCms_server.asp"
End Sub
Sub server_del
	'delfolder"../"&zt_en
	Dim del_server_id
	Conn.Execute(" delete from QvodCmsim_server where server_id="&del_id&" ")'删除服务器表
	Conn.Execute(" delete from QvodCmsim_url where server_id="&del_id&" ")   '删除地址表
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select data_id,server_id from QvodCmsim_data where server_id like '%"&del_id&"|%' order by data_id asc "
	rs.Open sql, Conn, 1, 1
	If Not (rs.bof And rs.eof) Then
	    Do while not rs.eof
	    del_server_id=replace(rs("server_id"),del_id&"|","")
	    'rs("server_id")=del_server_id
	    'rs.update'修改每部影片所属服务器组的属性
	    Conn.Execute(" Update [QvodCmsim_data] Set server_id='"&del_server_id&"' Where data_id="&rs("data_id")&" ")'修改每部影片所属服务器组的属性
	    rs.movenext
	    Loop
	End if
	rs.Close
	Set rs=nothing
	Response.Redirect "QvodCms_server.asp"
End Sub
%>
<%Sub server_list_playerid %>
<select name="server_playerid" style=" width:95px;">
	<%For i=1 to playerid(0)%>
		<%if i=rs("server_playerid") then%>
        <option value="<%=rs("server_playerid")%>" selected="selected"><%=playerid(i)%></option>
		<%else%>
		<option value="<%=i%>"><%=playerid(i)%></option>
		<%end if%>
	<%Next%>	
</select>
<%End Sub%>
<%Sub server_add_playerid %>
<select name="server_playerid" style=" width:95px;">
	<%For i=1 to playerid(0)%>
		<option value="<%=i%>" style="color:#0033FF"><%=i&"-"&playerid(i)%></option>
	<%Next%>
</select>
<%End Sub%>