<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_Popfun.asp -->

<!--#include file="conn.asp"-->
<%

DEF_BBS_HomeUrl = "../../"
opendatabase

dim stats
stats="<a href=admin_dg.asp>本地歌曲管理</a>"
BBS_SiteHead DEF_SiteNameString & " " & DEF_BBS_Name,GBL_board_ID," >> "&stats

'头部信息
If GBL_TableHeadString <> "" Then 
   response.write "<table width="&DEF_BBS_ScreenWidth&" border=0 cellspacing=0 cellpadding=0 align=center><tr><td>"& GBL_TableHeadString &"</td></tr></table>"
End If

dim Errmsg,master
Errmsg=""
dim rs,sql

if CheckSupervisorUserName = 1 or instr(DEF_SupervisorUserName,","&GBL_CHK_User&",")>0 then
   master=true
else
   master=false
end if

if not master then	
   Errmsg=Errmsg&"<li>本页面为管理员专用，你没有管理本页面的权限。</li>"
   Errormsg
Elseif GBL_CHK_User="" then
   Errmsg=Errmsg&"<li>您尚未登录，请先<a href="&DEF_BBS_HomeUrl&"user/login.asp><font color=blue>登录</FONT></a>！</li>"
   Errormsg
Else
  if request("action")="save" then
     call save()
  elseif request("action")="edit" then
     call edit()
  elseif request("action")="saveedit" then
     call saveedit()
  elseif request("action")="del" then
     call del()
  else
     call main()
  End if
End if
'尾部信息
If GBL_TableBottomString <> "" Then %>
 <table width=<%=DEF_BBS_ScreenWidth%> border=0 cellspacing=0 cellpadding=0 align=center>
   <tr><td><%=GBL_TableBottomString%></td></tr>
 </table>
<% End If 
  SiteBottom 
   If GBL_SiteBottomString <> "" Then Response.Write GBL_SiteBottomString
'关闭连接
CloseDB

Sub main()
if not master or GBL_CHK_User="" then
   exit sub
else
%>
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center class=tbhead2>
     <td><a href=listall.asp><font class=headfont><b>所有点歌列表</b></font></a></td>
     <td><a href=listme.asp><font class=headfont><b>我的点歌列表</b></font></a></td>
     <td><a href=write.asp><font class=headfont><b>我要点歌</b></font></a></td>
  </tr>
</table>
		
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center class=tbhead2> 
     <td colspan="2"><b>添加歌曲</b></td> 
  </tr> 
  
  <form name=myform action="admin_dg.asp?action=save" method=post> 

  <tr class=tbbg1>
     <td>
       <script language="javascript">
	  function setnum()
	  {
	  str='';
	  if(!window.myform.upcount.value)
	   window.myform.upcount.value=1;
 	  for(i=1;i<=window.myform.upcount.value;i++)
             str+='<table width=100% border=0 class=tbone cellspacing=1 cellpadding=5><tr class=tbbg1><td align=left colspan=2>第 <font color=red class=redfont><b>'+i+'</b></font> 首歌曲</td></tr><tr class=tbbg1><td align=right width=15% class=tbbg9>歌曲名称：</td><td><input type=text name=dgname size=40 class=fminpt></td></tr><tr class=tbbg1><td align=right width=15% class=tbbg9>歌曲路径：</td><td><input type=text name=dgurl size=40 class=fminpt value="http://"><font color=red class=redfont>*</font><font color=blue class=bluefont>歌曲路径请填全称</font>如：<font color="#0000ee">http://bbs.henau.edu.cn/04.mp3</font></td></tr></table>';
	  window.upid.innerHTML=str;
	  }
	</script>
        <li> 需要添加的歌曲的个数 
          <input type="text" name="upcount" value="1">
          <input type="button" name="Button" class="fmbtn" onclick="setnum();" value="· 设定 ·">
        </li>
     </td>
   </tr>
  <tr class=tbbg1>
     <td align=center id=upid>
        <table width=100% border=0 class=tbone cellspacing=1 cellpadding=5 >
           <tr class=tbbg1> 
              <td align=left colspan=2>第 <font color=red class=redfont><b>1</b></font> 首歌曲</td>
           </tr>
           <tr class=tbbg1> 
              <td align=right width=15% class=tbbg9>歌曲名称：</td>
              <td><input type=text name=dgname size=40></td>
           </tr>
           <tr class=tbbg1>
              <td align=right width=15% class=tbbg9>歌曲路径：</td>
              <td><input type=text name=dgurl size=40 value="http://"> 
                  <font color=red class=redfont>*</font> 
                  歌曲路径请填全称
                  如：http://bbs.henau.edu.cn/04.mp3
              </td>
           </tr>
        </table>
     </td>
  </tr>
  <tr class=tbbg1>
     <td colspan=2 align=center><input type=submit value=" 确 定 " class=fmbtn>&nbsp&nbsp&nbsp<input type=reset value=" 重 填 " class=fmbtn></td>
  </tr>
  </form>
</table>
<%
end if
end sub

'===========
Sub save()
if not master or GBL_CHK_User ="" then
   exit sub
else
   dim name,url,upcount
   upcount=request("upcount")

   dim i,m
   m=0
   for i=1 to upcount 
       name=trim(request.form("dgname")(i))
       url=trim(request.form("dgurl")(i))
       if name="" or url="" or i>upcount then exit for
       connDG.execute("insert into dgname(name,url) values ('"&name&"','"&url&"')")
       m=m+1
      
   next
   
    
%>
<script language=vbscript>
msgbox "添加成功！本次共添加 <%=m%> 首歌曲"
location.href="admin_dg.asp"
</script>
<%
  
end if
End sub

'==========================
Sub Edit()
if not master or GBL_CHK_User ="" then
   exit sub
else
  dim id 
  id=request("id")
  set rs=conndg.execute("select * from dgname where id="&id)
  if rs.eof or rs.bof then
    Errmsg=Errmsg&"<li>找不到这首歌曲，请确认该歌曲是否已被删除！</li>"
    Errormsg
  else
%> 
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center class=tbhead2>
     <td><a href=listall.asp><font class=headfont><b>所有点歌列表</b></font></a></td>
     <td><a href=listme.asp><font class=headfont><b>我的点歌列表</b></font></a></td>
     <td><a href=write.asp><font class=headfont><b>我要点歌</b></font></a></td>
  </tr>
</table>
		
<table width="<%=DEF_BBS_ScreenWidth%>" border=0 cellspacing=1 cellpadding=5 align=center bgcolor=<%=DEF_BBS_DarkColor%> class=TBone>
  <tr bgcolor=<%=DEF_BBS_LightDarkColor%> align=center class=tbhead2> 
     <td colspan="2"><b>添加歌曲</b></td> 
  </tr> 
  <form name=myform action="admin_dg.asp?action=saveedit&id=<%=id%>" method=post> 
  <tr class=tbbg1> 
     <td align=right width=60 class=tbbg9>歌曲名称：</td>
     <td><input type=text name=dgname size=40 class=fminpt value=<%=rs("name")%>></td>
  </tr>
  <tr class=tbbg1>
     <td align=right width=60 class=tbbg9>歌曲路径：</td>
     <td><input type=text name=dgurl size=40 class=fminpt value=<%=rs("url")%>> 
         <font color=red class=redfont>*</font> 
         <font color=blue class=bluefont>歌曲路径请填全称</font>
         如：<font color="#0000ee">http://bbs.henau.edu.cn/data/04.mp3</font>
     </td>
  </tr>
  <tr class=tbbg1>
     <td colspan=2 align=center><input type=submit value=" 确 定 " class=fmbtn>&nbsp&nbsp&nbsp<input type=reset value=" 重 填 " class=fmbtn></td>
  </tr>
  </form>
</table>
<%
  end if
end if
end sub

'==========
sub saveedit()
if not master or GBL_CHK_User ="" then
   exit sub
else
  dim id 
  id=request("id")

 dim name,url
   name=Replace(Replace(htmlEncode(trim(request("dgname"))),"\","\\"),"'","''")
   url=htmlEncode(trim(request("dgurl")))
   
   connDG.execute("update dgname set name='"&name&"',url='"&url&"' where id="&id)
%>
<script language=vbscript>
msgbox "修改成功！"
location.href="admin_dg.asp"
</script>
<%
  
end if
End sub

'=========================
sub del()
if not master or GBL_CHK_User ="" then
   exit sub
else
  dim id
  id=request("id")
  connDG.execute("delete from dgname where id="&id)
%>
<script language=vbscript>
msgbox "删除成功！"
location.href="list.asp"
</script>
<%
end if
end sub
%>