<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="admin_music_config.asp" -->
<%

del_user_true=true
del_upload_true=true
tit="歌曲管理"
index_url="msong"
call admin_master(0,0)
data_name="music_song"
call admin_header(0,0)
select case jk_mod
case "istop"
  ntit="推荐"&tit_fir
  sql_add=" where hidden=1 and istop=1"
case "sh"
  ntit="待审核"&tit_fir
  sql_add=" where hidden=0"
case else
  jk_mod=""
  ntit=tit_fir&"列表"
  sql_add=" where hidden=1"
end select
%>
<tr><td colspan=2 align=center>
 <table border=0>
  <tr>
  <td><a href='?'><%response.write tit_fir%>列表</a></td>
  <td width=10></td>
  <td><a href='?jk_mod=sh'<%if jk_mod="sh" then response.write " class=red"%>>待审核<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=istop'<%if jk_mod="istop" then response.write " class=red"%>>推荐<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?action=add&c_id=<%=c_id%>&s_id=<%=s_id%>&n_id=<%=n_id%>&d_id=<%=d_id%>'<%if action="add" then response.write " class=red"%>>添加<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='admin_music_singer.asp'>歌手管理</a></td>
  <td width=10></td>
  <td><a href='admin_music_disk.asp'>专辑管理</a></td>
  <td width=10></td>
  <td><a href='?action=clear' onclick="javascript:return click_return('清空所有歌曲',0);">清空所有歌曲</a></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='?' method=get>
  <tr>
  <td>搜索（点歌列表）关键字：</td>
  <td><input type=text name=keyword value='<%response.write trim(request.querystring("keyword"))%>' size=15 maxlength=20></td>
  <td><select name=sea_type size=1>
  <option value='name'>按歌曲名称</option>
  <option value='singer'>按所属歌手</option>
  </select></td>
  <td><select name=sea_term size=1>
  <option value='all'>满足所有条件</option>
  <option value='only'>满足一个条件</option>
  </select></td>
  <td><input type=submit value='搜索'></td>
  </tr>
  </form>
  </table>
</td></tr>
<%
call admin_table(1)
if action="handle" then call joekoe_go_handle()
select case action
  case "add"
    call song_add()
  case "edit"
    call song_edit()
  case "clear"
    call joekoe_go_clear()
  case else
    call song_list_main()
end select
call admin_ender(1)
'-----------------------------------删除歌曲-------------------------------------------
sub song_del()
  dim sel_id,sdim,snum,del_type
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  if sel_id="" then
    call web_js_msg(1,"没有可删除的歌曲！","?")
  end if
  sdim=split(sel_id,",")
  snum=ubound(sdim)
  for i=0 to snum
    if isnumeric(sdim(i)) then
      sql="delete from music_song where id="&sdim(i)
      call joekoe_cms.exec(sql,0)
    end if
  next
  erase sdim
  call admin_msg("已成功删除"&(snum+1)&"首歌曲！","?c_id="&c_id&"&s_id="&s_id&"&n_id="&n_id,0)
end sub
'-----------------------------------修改歌曲-------------------------------------------
sub song_edit()
  dim power,emoney,tim,musicserver,username,ispic,smi,hidden
  sql="select * from music_singer where id="&n_id
  set rs=joekoe_cms.exec(sql,1)
  singer=rs("name")
  rs.close
  sql="select * from music_song where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
      rs.close
      call admin_msg(tit_fir&"ID（"&id&"）不存在！","?",1)
      exit sub
    end if
  if chk() then
    if trim(request("MusicName"))="" then 
      rs.close
      call admin_error("歌曲名称不能为空！")
      exit sub
    end if
    musicserver=trim(request.form("musicserver"))
    if musicserver="" or isnull(musicserver) then musicserver=0
    musicserver=int(musicserver)
    if musicserver>0 and instr(trim(request.form("ListenUrl")),"://")<>0 then
      call admin_error("本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器相对路径！")
      exit sub
    end if
    if musicserver=0 and instr(trim(request.form("ListenUrl")),"://")<1 then
      call admin_error("非本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器绝对路径！")
      exit sub
    end if
    power=code_admin("power",1,50)
    power=replace(power," ","")
    power=replace(power,",",".")
    emoney=trim(request.form("emoney"))
    if not isnumeric(emoney) then emoney=0
    smi=code_admin("pic",1,100)
    rs("url")=trim(request.form("ListenUrl"))
    rs("urltype")=musicserver
    rs("Name")=trim(request.form("MusicName"))
    rs("c_id")=c_id
    rs("s_id")=s_id
    rs("n_id")=n_id
    rs("d_id")=d_id
    rs("power")=power
    rs("emoney")=emoney
    rs("username")=trim(request.form("username"))
    rs("singer")=trim(request.form("singer"))
    rs("words")=Request.Form("songwords")
    rs("smi")=smi
    tim=code_admin("tim",1,20)
    tim=joekoe_cms.time_type(tim,1)
    if tim="" then tim=joekoe_cms.now_time
    rs("tim")=tim
    isgood=trim(request.form("isgood"))
    hidden=trim(request.form("hidden"))
    if isgood="yes" then
      rs("istop")=true
    else
      rs("istop")=false
    end if
    if hidden="yes" then
      rs("hidden")=false
    else
      rs("hidden")=true
    end if
    rs.update
    rs.close
    sql="select * from music_fav where f_id="&id
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
    if not rs.eof then
      rs("Name")=trim(request.form("MusicName"))
      rs.update
    end if
    rs.close
    call admin_msg("已成功修改了一首歌曲！","?c_id="&cid&"&s_id="&sid&"&n_id="&n_id,0)
    exit sub
  end if
  call form_first()
  ispic=apart_filename(pic,1,"/")
  if ispic="" then ispic=joekoe_cms.rand_file(index_url)
%>
<tr><td colspan=2 class=td>修改歌曲&nbsp;<%=MusicName%>&nbsp;的资料</td></tr>
<form method="POST" action="?action=edit&types=chk&id=<%=id%>&c_id=<%=c_id%>&s_id=<%=s_id%>&n_id=<%=n_id%>&page=<%=page%>" name="edit_frm" onsubmit="return Form1_Validator(this)"><input type="hidden" name="singer" value="<%=singer%>">
<input type=hidden name=chk value='yes'>
<tr>
<td>所属专辑：</td><td><%response.write sel_c_id("?action=edit&id="&id)&sel_s_id("?action=edit&id="&id)&sel_n_id("?action=edit&id="&id)&sel_d_id("?action=edit&id="&id)%></td>
</tr>
<tr>
<td>歌曲名称：</td><td><input type="text" name="MusicName" size="60" maxlength="50" value="<%=rs("Name")%>"></td>
</tr>
<tr><td>服务器设置：</td><td>
<select size=1 name=musicserver>
<option value=0>非本地服务器</option>
<%
dim servername,serurl
servername=split(web_dim(28),"$")
for i=1 to ubound(servername)+1
serurl=split(servername(i-1),"|")
%>
<option value='<%=i%>' <%if rs("urltype")=i then%> selected<%end if%>>音频服务器<%=i&serurl(0)%></option>
<%
erase serurl
next
erase servername
%>
</select>
<% response.write redx %></td></tr>
<tr>
<td width="15%">试听地址：</td><td width="85%"><input type="text" name="ListenUrl" value="<%=rs("url")%>" size="60"><br><font class=red>（注意：如果选择了非本地服务器，请输入歌曲绝对地址）</font></td>
</tr>
<tr>
<td>发布时间：</td><td><input type="text" name="tim" value="<%=rs("tim")%>" size=20 maxlength=40>&nbsp;<input type=button name=st_btn value="选择" onclick="javascript:select_time(tim);return false;">&nbsp;&nbsp;浏览：<input type="text" name="hits" value="<%=rs("hits")%>" size=5 maxlength=40>&nbsp;人次&nbsp;&nbsp;推荐：<input type=checkbox name=isgood<%if rs("istop")=true then response.write " checked"%> value='yes'>&nbsp;&nbsp;隐藏/审核：<input type=checkbox name=hidden<%if rs("hidden")=false then response.write " checked"%> value='yes'></td>
</tr>
<%call chk_power("试听",rs("power"),0)%>
<tr>
<td>歌曲发布人：</td><td><input type="text" name="username" value="<%=rs("username")%>" size=20 maxlength=40>&nbsp;&nbsp;<%call chk_emoney(rs("emoney"))%></td>
</tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("edit_frm","remark","&nbsp;&nbsp;",0)%></td>
</tr>
<tr>
<td valign=top>歌词内容：</td>
<td>
<table border=0><tr>
<td><textarea name=songwords rows=6 cols=65><%response.write joekoe_cms.code_word(rs("words"))%></textarea></td>
<td width=5></td>
<td valign=bottom><%call textarea_resize("songwords")%></td>
</tr></table>
</td>
</tr>
<tr>
<td>SMI歌词：</td><td><input type="text" name="pic" size="50" value="<%=rs("smi")%>"></td>
</tr>
<tr>
<td>上传歌词：</td><td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td>
</tr>
<%
  call submit_edit()
  rs.close
end sub
'-----------------------------------添加歌曲-------------------------------------------
sub song_add()
  if chk() then
    dim power,emoney,musicserver,no,url,urlname,tim,username,hits,hidden,istop,counter,smi,ispic
    songwords=request.form("songwords")
    power=code_admin("power",1,50)
    power=replace(power," ","")
    power=replace(power,",",".")
    emoney=trim(request.form("emoney"))
    if not isnumeric(emoney) then emoney=0
    smi=code_admin("pic",1,100)
    tim=code_admin("tim",1,20)
    tim=joekoe_cms.time_type(tim,1)
    if tim="" then tim=joekoe_cms.now_time
    counter=trim(request.form("counter"))
    if not isnumeric(counter) then counter=0
    hidden=true
    if trim(request.form("hidden"))="yes" then hidden=false
    istop=false
    if trim(request.form("isgood"))="yes" then istop=true
    username=code_admin("username",1,20)
    if symbol_name(username)=false then username=login_username
    no=trim(request.form("no"))
    no=int(no)
    hits=trim(Request.Form("hits"))
    if not isnumeric(hits) then hits=0
    musicserver=trim(request.form("musicserver"))
    if musicserver="" or isnull(musicserver) then musicserver=0
    musicserver=int(musicserver)
    for i=1 to no
      url=code_admin("url"&i&"",1,255)
      if url="" then
        call admin_error(tit_fir&"地址"&i&" 不能为空！")
        exit sub
      end if
      if musicserver>0 and instr(url,"://")<>0 then
        call admin_error("本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器相对路径！")
        exit sub
      end if
      if musicserver=0 and instr(url,"://")<1 then
        call admin_error("非本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器绝对路径！")
        exit sub
      end if
      urlname=code_admin("urlname"&i&"",1,20)
      if urlname="" or isnull(urlname) then
        call admin_error(tit_fir&"名称"&i&" 不能为空！")
        exit sub
      end if
    next
    sql="select name from music_singer where id="&n_id
    set rs=joekoe_cms.exec(sql,1)
    singer=rs("name")
    rs.close
    sql="select * from music_song" 
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
    for i=1 to no
    rs.addnew
    rs("Name")=code_admin("urlname"&i&"",1,20)
    rs("url")=code_admin("url"&i&"",1,255)
    rs("urltype")=musicserver
    rs("c_id")=c_id
    rs("s_id")=s_id
    rs("n_id")=n_id
    rs("d_id")=d_id
    rs("hits")=hits
    rs("smi")=smi
    rs("counter")=counter
    rs("power")=power
    rs("emoney")=emoney
    rs("username")=username
    rs("singer")=singer
    rs("words")=songwords
    rs("tim")=tim
    isgood=trim(request.form("isgood"))
    hidden=trim(request.form("hidden"))
    if isgood="yes" then
      rs("istop")=true
    else
      rs("istop")=false
    end if
    if hidden="yes" then
      rs("hidden")=false
    else
      rs("hidden")=true
    end if
    rs.update
    next
    rs.close
    call admin_msg("已成功添加了"&no&"首歌曲！","?c_id="&c_id&"&s_id="&s_id&"&n_id="&n_id,0)
  else
    call form_first()
    if ispic="" then ispic=joekoe_cms.rand_file(index_url)
%>
<form method=post name=add_frm action="?action=add&types=chk&c_id=<%=c_id%>&s_id=<%=s_id%>&n_id=<%=n_id%>" onsubmit="return Form1_Validator(this)">
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<tr>
<td colspan=2 class=td>添加歌曲</td>
</tr>
<tr>
<td>所属专辑：</td>
<td><%response.write sel_c_id("?action=add")&sel_s_id("?action=add")&sel_n_id("?action=add")&sel_d_id("?action=add")%></td>
</tr>
<script language=javascript>
<!--
function seturl()
{
	var str="";
	var temname1=add_frm.temname1.value
	var temname2=add_frm.temname2.value
	if (!window.add_frm.no.value) window.add_frm.no.value=1;
	for(i=1;i<=window.add_frm.no.value;i++)
	str+='&nbsp;'+i+'：&nbsp;<input type=text name="url'+i+'" style="padding-left:1pt" size=40 value="'+temname1+i+temname2+'">&nbsp;歌曲名称：&nbsp;<input type=text name="urlname'+i+'" style="padding-left:1pt" size=10 maxlength=20 value="歌曲名称'+i+'"><BR>';
	window.addid.innerHTML=str;
}
function music_server()
{
    var tmp1,sn,server,str;
    str="&nbsp;<font class=red>非本地服务器</font>";
    server='<%=web_dim(28)%>';
    server=server.split('$')
    if (window.add_frm.musicserver.value>0)
    {
    sn=window.add_frm.musicserver.value;
    sn-=1;
    tmp1=server[sn].split('|');
    str='&nbsp;<font class=red>播放服务器：</font>'+tmp1[0]+'&nbsp;&nbsp;&nbsp;<font class=red>下载服务器：</font>'+tmp1[1];
    }
    window.addid.innerHTML=str;
}
-->
</script>
<tr><td>服务器设置：</td><td>
<select size=1 name=musicserver onclick="music_server(this.options[this.selectedIndex].value);">
<option value=0>非本地服务器</option>
<%
dim servername
servername=split(web_dim(28),"$")
for i=1 to ubound(servername)+1
response.write "<option value='"&i&"'>音频服务器"&i&"</option>"
next
erase servername
%>
</select>
前缀：<input type=text name=temname1 value='' size=20>
歌曲数：<input type=text name=no value=1 size=2>
后缀：<input type=text name=temname2 value='' size=5>
<input type=button name=Button onclick="seturl();" value='设置'> <% response.write redx %></td></tr>
<tr><td>歌曲地址：</td><td id="addid">(若是本地影片请选择服务器)</td></tr>
<tr>
<td>发布时间：</td><td><input type="text" name="tim" value="<%=now()%>" size=20 maxlength=40>&nbsp;<input type=button name=st_btn value="选择" onclick="javascript:select_time(tim);return false;">&nbsp;&nbsp;浏览：<input type="text" name="hits" value="0" size=5 maxlength=40>&nbsp;人次&nbsp;&nbsp;推荐：<input type=checkbox name=isgood value='yes'>&nbsp;&nbsp;隐藏/审核：<input type=checkbox name=hidden value='yes'></td>
</tr>
<%call chk_power("试听","1.2.3.4.5",0)%>
<tr>
<td>歌曲发布人：</td><td><input type="text" name="username" value="<%=login_username%>" size=20 maxlength=40>&nbsp;&nbsp;<%call chk_emoney(0)%></td>
</tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("add_frm","remark","&nbsp;&nbsp;",0)%></td>
</tr>
<tr>
<td valign=top>歌词内容：</td>
<td>
<table border=0><tr>
<td><textarea name=songwords rows=6 cols=65></textarea></td>
<td width=5></td>
<td valign=bottom><%call textarea_resize("songwords")%></td>
</tr></table>
</td>
</tr>
<tr>
<td>SMI歌词：</td><td><input type="text" name="pic" size="50"></td>
</tr>
<tr>
<td>上传歌词：</td><td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td>
</tr>
<%
  call submit_add()
  end if
end sub
'-----------------------------------歌曲列表-------------------------------------------
sub song_list_main()
  response.write "<form name=del_form action='?jk_mod="&jk_mod&"&action=handle&c_id="&c_id&"&s_id="&s_id&"&n_id="&n_id&"' method=post>" & _
             vbcrlf&"<tr align=center>" & _
             vbcrlf&"<td class=td width='7%'>序号</td>" & _
             vbcrlf&"<td class=td width='52%'>歌曲名字</td>" & _
             vbcrlf&"<td class=td width='12%'>所属歌手</td>" & _
             vbcrlf&"<td class=td width='7%'>点击</td>" & _
             vbcrlf&"<td class=td width='15%'>相关属性</td>" & _
             vbcrlf&"<td class=td width='7%'><input type=checkbox name=sel_all value='yes' onclick=""javascript:select_all(this.form);""></td>" & _
             vbcrlf&"</tr>"
  pageurl="?action=songlist&c_id="&c_id&"&s_id="&s_id&"&n_id="&n_id&"&"
  if c_id<>"" then
    if n_id<>"" then
      sql_add=sql_add&" and n_id="&n_id&" and s_id="&s_id&" and c_id="&c_id
    elseif s_id<>"" then
      sql_add=sql_add&" and s_id="&s_id&" and c_id="&c_id
    else
      sql_add=sql_add&" and c_id="&c_id
    end if
  end if
  if d_id<>"" then
    sql_add=" where d_id="&d_id
  end if
  call format_search("name","name,singer",2,1)
  sql="select count(id) from music_song"&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from music_song"&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    response.write "<tr align=center>" & _
             vbcrlf&"<td>"&i&"</td>" & _
             vbcrlf&"<td><table border=0 cellspacing=0 cellpadding=0 width='100%'><tr>" & _
             vbcrlf&"<td><a href='?jk_mod="&jk_mod&"&action=edit&id="&rs("id")&"&c_id="&rs("c_id")&"&s_id="&rs("s_id")&"&n_id="&rs("n_id")&"'>"&rs("name")&"</a></td>" & _
             vbcrlf&"<td align=right><font class=tims>"&joekoe_cms.time_type(rs("tim"),4)&"</font></td>" & _
             vbcrlf&"</tr></table></td>" & _
             vbcrlf&"<td>"&rs("singer")&"</td>" & _
             vbcrlf&"<td>"&rs("hits")&"</td>" & _
             vbcrlf&"<td align=center>"&pro_edit("?jk_mod="&jk_mod&"&action=edit&id="&rs("id")&"&c_id="&rs("c_id")&"&s_id="&rs("s_id")&"&n_id="&rs("n_id"),"编辑该歌曲") &"&nbsp;"&pro_hidden(rs("hidden"),1)&"&nbsp;"& pro_istop(rs("istop"))&"</td>" & _
             vbcrlf&"<td><input type=checkbox name=sel_id value='"&rs("id")&"' class=bg_tds></td>" & _
             vbcrlf&"</tr>"
    rs.movenext
  next
    rs.close
  set rs=nothing
  response.write "<tr class=tr1>" & _
             vbcrlf&"<td colspan=3>&nbsp;现有<font class=red>"&rssum&"</font>首歌曲，页次：<font class=red>"&viewpage&"</font>/<font class=red>"&thepages&"</font>分页："&jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")&"</td>" & _
             vbcrlf&"<td colspan=3 align=center>执行&nbsp;&nbsp;<select name=sel_type size=1><option value='推荐'>推荐</option><option value='取消推荐'>取消推荐</option><option value='审核'>审核</option><option value='待审核'>待审核</option><option value='删除'>删除</option></select>&nbsp;&nbsp;<input type=submit value='操作' onclick=""return sel_click(this.form);""></td>" & _
             vbcrlf&"</tr>" & _
             vbcrlf&"</form>" & _
             vbcrlf&"</table></td></tr>"
end sub

%>

