<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="Ex_Cls/Ex_FsoCls.asp"-->
<!--#include file="Ex_Cls/Ex_CommonCls.asp"-->
<!--#include file="Ex_Cls/Ex_SplitPageCls.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #0000FF}
-->
</style>
<script>
	String.prototype.trim = function ()  
{ 
	return this.replace(/(^[\s]*)|([\s]*$)/g, ""); 
}; 
var upnum=10;//最大上传音乐数量
function count(){//计算上传数量
	var n=0;
	for(var i=1;i<=10;i++){
		var musicurl=document.getElementById("musicurl"+i).value.trim();
		if(musicurl==''){
			n=n+1;
		}
	}
	upnum=n;
}
//添加音乐
function uploadmusic(obj){
	for(var m=0;m<obj.length;m++){
		var flag=0;
		for(var i=1;i<=10;i++){
			var musicurl=document.getElementById("musicurl"+i).value.trim();
			if(musicurl=='' && flag==0){
				var localname=obj[m].localname;
				localname=localname.split('.');
				localname=localname[0];
				document.getElementById("musicname"+i).value=localname;
				document.getElementById("musicurl"+i).value=obj[m].name;
				flag=1;
			}
		}
	}
}
//添加歌词
function addsmi(i){
	document.getElementById("addmusicnum").innerHTML=i;
	document.getElementById("smicontent").value='';
	document.getElementById("smiobj").style.display='';
}
function returnsmi(){
	var i=document.getElementById("addmusicnum").innerHTML;
	var content=document.getElementById("smicontent").value;
	if (content!="" && content.toLowerCase().indexOf("<sami>")==-1)
	{
		alert("歌词格式必须是SMI格式");
		return false;
	}	
	document.getElementById("msiurl"+i).value=content;
	document.getElementById("addmusicnum").innerHTML='';
	document.getElementById("smiobj").style.display='none';
}
//歌词转换
function search(string) {
var text  = string.substring(string.lastIndexOf("]")+1);
string    = string.substring(0,string.lastIndexOf("]")+1);
var i     = 0;
var start;
var end;
var num;
var data = new Array();
do {
start   = string.indexOf("[");
end     = string.indexOf("]");
if(start==-1)break;
num     = dataTrans(string.substring(start+1,end));
if(!isNaN(num)){
data[i] = new Array(num,text);
i++;}
string  = string.substring(end+1);
}
while(start!=-1)
return data;
}

function dataTrans(data) {
var array  = stringsplit(data,":");
var temp   = stringsplit(array[1],".");
var string = "";
if(!isNaN(array[0]))
{array[0]=array[0]*60000;}
else
{return data;}
if(temp.length>1) {
for(var i=0;i<temp.length;i++)
{
string=string.concat(temp[i]);
}
string=string+"0";
}else{
string=array[1]+"000";
}
string=Number(string)+Number(array[0]);
return string;
}

function stringsplit(string1,string2) {
var n;
var i=0;
var temp=new Array();
do {
n=string1.indexOf(string2);
temp[i]=string1.substring(0,n);
string1=string1.substring(n+1);
i++;
}
while(n!=-1)
temp[i-1]=string1;
return temp;
}

function clip(string1,string2) {
for(var i=0;i<string1.length;i++)
if(string1.charAt(i)==string2)
string1=string1.substring(i+1);
else
break;
return string1;
}

function change() {
var content=document.getElementById("smicontent").value;
if(content.indexOf('[')==-1 && content.toLowerCase().indexOf("<sami>")==-1){
	alert('请填写lrc格式歌词');
	return false;
}
if(content.toLowerCase().indexOf("<sami>")!=-1){
	alert('您填写的歌词已经是smi格式,无需转换');
	return false;
}
var line = readall(content);
var list2=document.getElementById("smicontent");
var tmp  = "";
var tmp2 = "";
var tmp3 = "";
for(var i=0;i<line.length;i++)
 tmp = tmp + search(line[i]);
document.getElementById("smicontent").value = tmp;
tmp = readall(list2.value);
for(var i=0;i<tmp.length;i++)
 tmp2 = tmp2 + tmp[i];
list2.value  = tmp2;
tmp2         = clipline(list2.value);
tmp2         = issort(tmp2,tmp2.length);
list2.value  = tmp2;
tmp2 =  "<SAMI>" + "\n" + 
 "<HEAD>" + "\n" + 
 "<Title>Close Captioning Sample</Title>" + "\n";
tmp2 =  tmp2 + 
 "<STYLE TYPE='text/css'>" + "\n" + 
 "<!-" + "-" + "\n" +
 "P {margin-top:3pt; margin-left:5pt; font-size: 10pt; font-family: tahoma, sans-serif; font-weight: normal; color: #ffffff;}" + "\n" + 
 ".ENUSCC {Name:'English Captions' lang: en-US; SAMIType:CC;}" + "\n" + 
 "--" + ">" + "\n" +
 "</Style>" + "\n" + 
 "</HEAD>" + "\n" + 
 "<BODY>" + "\n";
tmp  = readall(document.getElementById("smicontent").value);
for(var i=0;i<tmp.length;i++) 
{
 tmp3 = stringsplit(tmp[i],",");
 if(tmp3[1]!="")
 tmp2 = tmp2 + "<SYNC Start=" + tmp3[0] + "><P Class=ENUSCC>" + tmp3[1];
}
tmp2 = tmp2 + "</BODY>" + "\n" + "</SAMI>";
document.getElementById("smicontent").value  = tmp2;
}

function readall(text) {
var line = new Array();
var n    = 0;
var newline;
while(newline!=-1){
 newline = text.indexOf("\n");
 if(newline!=-1)
 {
  line[n] = clip(text.substring(0,newline),",");
  text    = text.substring(newline+1);
  n++;
 }
 else
 line[n] = text;
}
return line;
}

function issort(a,size) {
var b = a;
var inserter;
var index;
var text;
for(var i=1;i<size;i++)
{
 inserter = a[i][0];
 text     = a[i][1];
 index    = i-1;
 while(index>=0&&Number(inserter)<Number(a[index][0]))
 {
  a[index+1][0] = a[index][0];
  a[index+1][1] = a[index][1];
  index--;
 }
 a[index+1][0] = inserter;
 a[index+1][1] = text;
}
return b;
}
function clipline(text) {
var line = new Array();
var n    = 0;
var newline;
while(newline!=-1){
 newline = text.indexOf("\n");
 if(newline!=-1)
 {
  var tmp = stringsplit(clip(text.substring(0,newline),","),",");
  line[n] = new Array(tmp[0],tmp[1]);
  text    = text.substring(newline+1);
  n++;
 }
 else
 line[n] = text;
}
return line;
}
</script>
<script type="text/javascript" src="AienUpload/init.js"></script>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor" >
<%
Dim ExComm
Set ExComm=new Ex_CommonCls
ExComm.IsAdLogin 
ExComm.IsIpAllow
dim action
action=request.querystring("action")
Select Case Action
	Case "addfall"
		AddfAll
	Case "addfsingle"
		Addfsingle
	Case "addall"
		AddAll
	Case "addsingle"
		AddSingle
	Case "editsingle"
		EditSingle
	Case "show"
		Show
	Case "del"
		Del
	Case "domore"
		DoMore
	Case "createlist"
		CreateList
		ExComm.ShowMsg "播放列表更新成功","?action=addfall"
end select
Sub AddfAll()
%>
<SCRIPT language=javascript>
function checkall() 
{
	for (var i=1;i<=10 ;i++ )
	{
		var musicname=document.getElementById("musicname"+i).value.trim();
		var musicurl=document.getElementById("musicurl"+i).value.trim();
		var smiurl=document.getElementById("smiurl"+i).value.trim();
		if (musicname.toLowerCase().indexOf("\"")!=-1)
		{
			alert("歌曲名中请不要有双引号");
			return false;
		}
		if (musicname!="" && musicurl=="")
		{
			alert("请填写歌曲"+i+"地址");
			return false;
		}
		if (musicname=="" && musicurl!="")
		{
			alert("请填写歌"+i+"曲名称");
			return false;
		}
		if (musicurl!="" && musicurl.toLowerCase().indexOf("/")!=-1 && musicurl.toLowerCase().indexOf("http://")==-1)
		{
			alert("非上传歌曲"+i+"的地址必须以http://开头");
			return false;
		}
		if (smiurl!="" && smiurl.toLowerCase().indexOf(".smi")==-1)
		{
			alert("歌曲"+i+"的歌词必须是SMI格式。在单曲添加方式中有歌词格式LRC转SMI工具。");
			return false;
		}
		if (smiurl!="" && smiurl.toLowerCase().indexOf("http://")==-1)
		{
			alert("歌曲"+i+"的歌词地址必须以http://开头");
			return false;
		}
	}
	
} 
</script>
<div id="smiobj" style="display:none;position:absolute;width:410px;height:185px;background:#E4EDF9;left:200px;top:150px;border:1px solid #003399;padding:5px">
<div><span style="float:left"><b>给歌曲<span id="addmusicnum"></span>添加歌词</b></span><span style="float:right;margin-right:5px;cursor:pointer" title="关闭" onClick="document.getElementById('smiobj').style.display='none';">关闭</span></div>
<textarea name="smicontent" id="smicontent" style="width:400px;height:150px"></textarea>
<span style="float:left"><input type="button" name="Submit3" value="添加歌词" onClick="returnsmi()"/></span>
<span style="float:right"><input type="button" name="Submit3" value="歌词格式转化LRC到SMI" onClick="change()"/></span>
</div>
<form id="form1" name="form1" method="post" action="?action=addall" onSubmit="return checkall()">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <td height="24" colspan="7" class="topbg"><center>
        歌曲添加
      </center></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称1：
      </center></td>
      <td width="17%"><input type="text" name="musicname1" id="musicname1"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址1：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl1" id="musicurl1"size="40" maxlength="250"/>
		   <input type="text" name="msiurl1" id="msiurl1"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onClick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onClick="addsmi(1)">
	  </td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称2：
      </center></td>
      <td width="17%"><input type="text" name="musicname2" id="musicname2"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址2：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl2" id="musicurl2"size="40" maxlength="250"/>
		  <input type="text" name="msiurl2" id="msiurl2"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(2)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称3：
      </center></td>
      <td width="17%"><input type="text" name="musicname3" id="musicname3"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址3：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl3" id="musicurl3"size="40" maxlength="250"/>
		  <input type="text" name="msiurl3" id="msiurl3"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(3)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称4：
      </center></td>
      <td width="17%"><input type="text" name="musicname4" id="musicname4"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址4：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl4" id="musicurl4"size="40" maxlength="250"/>
		  <input type="text" name="msiurl4" id="msiurl4"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(4)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称5：
      </center></td>
      <td width="17%"><input type="text" name="musicname5" id="musicname5"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址5：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl5" id="musicurl5"size="40" maxlength="250"/>
		  <input type="text" name="msiurl5" id="msiurl5"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(5)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称6：
      </center></td>
      <td width="17%"><input type="text" name="musicname6" id="musicname6"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址6：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl6" id="musicurl6"size="40" maxlength="250"/>
		  <input type="text" name="msiurl6" id="msiurl6"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(6)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称7：
      </center></td>
      <td width="17%"><input type="text" name="musicname7" id="musicname7"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址7：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl7" id="musicurl7"size="40" maxlength="250"/>
		  <input type="text" name="msiurl7" id="msiurl7"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(7)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称8：
      </center></td>
      <td width="17%"><input type="text" name="musicname8" id="musicname8"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址8：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl8" id="musicurl8"size="40" maxlength="250"/>
		  <input type="text" name="msiurl8" id="msiurl8"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(8)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称9：
      </center></td>
      <td width="17%"><input type="text" name="musicname9" id="musicname9"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址9：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl9" id="musicurl9"size="40" maxlength="250"/>
		  <input type="text" name="msiurl9" id="msiurl9"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(9)"></td>
    </tr>
    <tr class="tdbg">
      <td width="15%"><center>
        歌曲名称10：
      </center></td>
      <td width="17%"><input type="text" name="musicname10" id="musicname10"size="20" maxlength="250"/></td>
      <td width="13%">歌曲地址10：</td>
      <td colspan="2"><div align="left">
          <input type="text" name="musicurl10" id="musicurl10"size="40" maxlength="250"/>
		  <input type="text" name="msiurl10" id="msiurl10"size="40" maxlength="250" style="display:none"/>
      </div></td>
      <td colspan="2"><input name="btup1" type="button" id="btup1" value="上传音乐" onclick="count();showUpload(null,'musicname1','cache/uploads',upnum,function(obj){uploadmusic(obj);});">
		<input name="btup1" type="button" value="添加歌词" onclick="addsmi(10)"></td>
    </tr>
    <tr class="tdbg">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit2" value="提交"></td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
<%end Sub
Sub AddfSingle()
	Dim id,Sql,Rs,MusicName,MusicUrl,Ac
	id=CLng(Request.QueryString("id"))
	ac="add"
	If id<>0 Then 
		Sql="select * from Ex_Music where id="&id
		Set Rs=Conn.Execute(Sql)
		MusicName=Rs(1)
		MusicUrl=Rs(2)
		ac="edit"
	End If 
%>
<SCRIPT language=javascript>
function checkall() 
{
		var musicname=document.getElementById("musicname").value.trim();
		var musicurl=document.getElementById("musicurl").value.trim();
		var smicontent=document.getElementById("smicontent").value.trim();
		if (musicname=="")
		{
			alert("请填写歌曲名称");
			return false;
		}
		if (musicname.toLowerCase().indexOf("\"")!=-1)
		{
			alert("歌曲名中请不要有双引号");
			return false;
		}
		if (musicurl=="")
		{
			alert("请填写歌曲地址");
			return false;
		}
		if (musicurl.toLowerCase().indexOf("http://")==-1)
		{
			alert("歌曲的地址必须以http://开头");
			return false;
		}
		if (smicontent=="")
		{
			alert("歌词不能为空");
			return false;
		}
		if (smicontent!="" && smicontent.toLowerCase().indexOf("<sami>")==-1)
		{
			alert("歌词格式必须是SMI格式");
			return false;
		}	
} 
</script>
<form id="form1" name="form1" method="post" action="?action=<%=Ac%>single&id=<%=id%>" onSubmit="return checkall()">
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border" align="center">
  <tr>
    <td height="27" colspan="2" class="topbg"><div align="center">歌曲添加</div></td>
  </tr>
  <tr class="tdbg">
    <td>歌曲名称：</td>
    <td><input name="musicname" type="text" id="musicname" size="30" value="<%=MusicName%>">
      &nbsp;</td>
  </tr>
  <tr class="tdbg">
    <td>歌曲地址：</td>
    <td><input name="musicurl" type="text" id="musicurl" size="50" value="<%=MusicUrl%>"></td>
  </tr>
  <tr class="tdbg">
    <td>歌词内容：</td>
    <td><textarea name="smicontent" cols="60" rows="10" id="smicontent"></textarea>
      <input type="button" name="Submit3" value="歌词格式转化LRC到SMI" onClick="change()"></td>
  </tr>
  <tr class="tdbg">
    <td>&nbsp;</td>
    <td><input name="Submit4" type="submit" value="提交"></td>
  </tr>
</table>
</form>
<%
end sub 
Sub CreateList()
	'If Request.QueryString("action")<>"createlist" Then 
		'Response.Write "<script>if(!confirm('歌曲添加成功。现在更新播放列表请选确定；继续添加歌曲请选取消。'))self.location='?action=addfall';</script>"
	'End If 
	Dim Rs,Sql,Temp,Fso,MusicUrl,SmiUrl
	Set Fso=new Ex_FsoCls
	Sql="select * from Ex_Music order by id desc"
	Set Rs=Conn.Execute(Sql)
	Do While Not Rs.eof 
		If Rs("smiurl")="" Then 
			If InStr(Rs("musicurl"),"http://")=0 Then 
				MusicUrl=Application(Sn&"blogurl")&"/music/"&Rs("musicurl")
			Else
				MusicUrl=Rs("musicurl")
			End If 
			Temp=Temp&"mkList("""&MusicUrl&""","""&Rs("musicname")&""");"&vbcrlf
		Else 
			If InStr(Rs("smiurl"),"http://")=0 Then 
				MusicUrl=Application(Sn&"blogurl")&"/"&Rs("smiurl")
			Else
				MusicUrl=Rs("musicurl")
			End If 
			Temp=Temp&"mkList("""&Rs("musicurl")&""","""&Rs("musicname")&""","""&Rs("smiurl")&""");"&vbcrlf
		End If 
		Rs.movenext
	Loop 
	Set Rs=Nothing 
	Fso.CreateFile "js/MusicList.Js",Temp
	Set Fso=Nothing 
End Sub 
Sub AddAll()
	Dim MusicName,MusicUrl,SmiUrl,i,Sql,Fname,Fso
	Set Fso=new Ex_FsoCls
	For i=1 To 10
		MusicName=ExComm.F(Request.Form("musicname"&i))
		MusicUrl=ExComm.F(Request.Form("musicurl"&i))
		SmiUrl=ExComm.G(Request.Form("msiurl"&i))
		If InStr(MusicUrl,"/")=0 Then 
			Fso.CopyOneFile "cache/uploads/"&musicurl,"music/"&musicurl
		End If 
		If MusicUrl<>"" And SmiUrl<>"" Then 
			Fname="music/smi/"&Replace(Replace(Replace(now," ",""),":",""),"-","")&".smi"
			Fso.CreateFile Fname,SmiUrl
			Sql="insert into Ex_Music(musicname,musicurl,smiurl) values('"&musicname&"','"&musicurl&"','"&Fname&"')"
			Conn.Execute Sql
		ElseIf MusicUrl<>"" And SmiUrl="" Then 
			Sql="insert into Ex_Music(musicname,musicurl) values('"&musicname&"','"&musicurl&"')"
			Conn.Execute Sql
		End If 
	Next 
	CreateList
	ExComm.ShowMsg "歌曲添加成功","?action=addfall"
End Sub
Sub AddSingle()
	Dim MusicName,MusicUrl,SmiContent,Fso,Sql,Fname
	MusicName=ExComm.F(Request.Form("musicname"))
	MusicUrl=ExComm.F(Request.Form("musicurl"))
	SmiContent=ExComm.G(Request.Form("SmiContent"))
	Fname="music/smi/"&Replace(Replace(Replace(now," ",""),":",""),"-","")&".smi"
	Set Fso=new Ex_FsoCls
	Fso.CreateFile Fname,SmiContent
	SmiContent=Application(sn&"blogurl")&Fname	
	Sql="insert into Ex_Music(musicname,musicurl,smiurl) values('"&musicname&"','"&musicurl&"','"&SmiContent&"')"
	Conn.Execute Sql
	CreateList
	ExComm.ShowMsg "歌曲添加成功","?action=addfall"
End Sub 
Sub EditSingle
	Dim MusicName,MusicUrl,SmiContent,Fso,Sql,Fname,id
	MusicName=ExComm.F(Request.Form("musicname"))
	MusicUrl=ExComm.F(Request.Form("musicurl"))
	SmiContent=ExComm.G(Request.Form("SmiContent"))
	id=CLng(Request.QueryString("id"))
	Fname="music/Smi/"&MusicName&Replace(Replace(now," ",""),":","")&".Smi"
	Set Fso=new Ex_FsoCls
	Fso.CreateFile Fname,SmiContent
	SmiContent=Application(sn&"blogurl")&Fname	
	Sql="update Ex_Music set musicname='"&MusicName&"',musicurl='"&MusicUrl&"',smiurl='"&SmiContent&"' where id="&id
	Conn.Execute Sql
	CreateList
	ExComm.ShowMsg "修改成功","?action=show"
End Sub 
Sub Show()
Dim Rs,Sql
Dim ExPages,page
Dim st,keyword
keyword=ExComm.F(Request.Form("keyword"))
st=ExComm.F(Request.Form("st"))
Set ExPages=new  Ex_SplitPageCls
Expages.letConn=Conn
Expages.letColumns="select *"
ExPages.letDataFrom="from Ex_Music"
If keyword<>"" Then 
	ExPages.LetWhere="where "&st&" like '%"&keyword&"%'"
End If 
ExPages.LetOrder="order by id desc"
Set Rs=server.CreateObject("adodb.recordset")
Expages.letPageSize="15"
If ExComm.G(request("page"))="" Then
	page=1
Else
	page=ExComm.G(request("page"))
End if
ExPages.letPage=CInt(page)
ExPages.letStrPage="&action=show&st="&st&"&keyword="&keyword
ExPages.Execute()
%>
<script language="javascript">
function checkall(theform)
{for(var i=0;i<theform.elements.length;i++)
 { var e = theform.elements[i];
    if (e.Name != "selectall")
       e.checked = theform.selectall.checked;
 }
}
</script>
<form name="form2" method="post" action="?action=show">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <td colspan="6" class="topbg"><div align="center">歌曲搜索</div></td>
    </tr>
    <tr class="tdbg">
      <td width="13%" height="23">&nbsp;</td>
      <td width="12%">关键字：</td>
      <td width="22%"><input name="keyword" type="text" id="keyword"></td>
      <td width="11%">搜索类型：</td>
      <td width="12%"><select name="st">
        <option value="musicname" selected>歌曲名称</option>
        <option value="musicurl">歌曲地址</option>
      </select>
      </td>
      <td width="30%"><input type="submit" name="Submit5" value="搜索"></td>
    </tr>
  </table>
</form>
<form id="form1" name="form1" method="post" action="?action=domore">
 <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <td height="21" colspan="6" class="topbg"><CENTER>
        歌曲管理
      </CENTER></td>
    </tr>
    <tr class="tdbg">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr class="tdbg">
      <td width="7%">选中</td>
      <td width="17%"><CENTER>
        歌曲名
      </CENTER></td>
      <td width="16%"><div align="center">歌曲地址</div></td>
      <td><div align="center">歌词地址</div></td>
      <td colspan="2"><CENTER>
        操作
      </CENTER></td>
    </tr>
	<%
	 Set Rs=ExPages.getRs
		If ExPages.getRsCount<>0 Then
			Dim musicid
			Do While Not rs.eof
				musicid=Rs("id")
  %>
    <tr class="tdbg">
      <td><input type="checkbox" name="ids" id="ids" value="<%=musicid%>" /></td>
      <td><CENTER>
        <input type="text" name="musicname<%=musicid%>" id="musicname<%=musicid%>"size="20" maxlength="250" value="<%=Rs("musicname")%>"/>
      </CENTER></td>
      <td><div align="center">
        <input type="text" name="musicurl<%=musicid%>" id="musicurl<%=musicid%>"size="20" maxlength="250" value="<%=Rs("musicurl")%>"/>
      </div></td>
      <td><div align="center">
        <input type="text" name="smiurl<%=musicid%>" id="smiurl<%=musicid%>"size="20" maxlength="250" value="<%=Rs("smiurl")%>"/>
      </div>        <div align="center"></div></td>
      <td width="10%"><a href="?action=addfsingle&id=<%=musicid%>"><CENTER>
        修改
      </CENTER></a></td>
      <td width="10%"><div align="center"><a href="?action=del&id=<%=musicid%>" onClick="return confirm('是否要删除?')">删除</a></div></td>
    </tr>
	<%
				Rs.movenext
			Loop 
		End If 
	%>
    <tr class="tdbg">
      <td><input type="checkbox" name="selectall" value="checkbox" onClick="checkall(this.form)"/>
      全选</td>
      <td colspan="2">删除
      <input name="dotype" type="radio" value="delall" />
      修改 
      <input name="dotype" type="radio" value="editall" /></td>
      <td><input type="submit" name="Submit" value="确定" /></td>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
<center>
<%=ExPages.Show%>
<center>
<%
End Sub
Sub Del()
	Dim id
	id=CLng(request.querystring("id"))
	Conn.execute("delete * from Ex_Music where id="&id)
	CreateList
	ExComm.ShowMsg "删除成功",request.servervariables("http_referer")
End Sub
Sub DoMore()
	Dim ids,i,Sql,MusicName,MusicUrl,SmiUrl,DoType
	DoType=Request.Form("dotype")
	ids=request.Form("ids")
	ids=Split(ids,",")
	for i=0 To UBound(ids)
		MusicName=ExComm.F(Request.Form("musicname"&Trim(ids(i))))
		MusicUrl=ExComm.F(Request.Form("musicurl"&Trim(ids(i))))
		SmiUrl=ExComm.F(Request.Form("smiurl"&Trim(ids(i))))
		If DoType="delall" Then 
			Sql="Delete * from Ex_Music where id="&ids(i)
		ElseIf SmiUrl="" Then 
			Sql="update Ex_Music set musicname='"&MusicName&"',musicurl='"&MusicUrl&"' where id="&ids(i)
		Else 
			Sql="update Ex_Music set musicname='"&MusicName&"',musicurl='"&MusicUrl&"',smiurl='"&SmiUrl&"' where id="&ids(i)
		End If 
		Conn.execute(Sql)
	Next
	CreateList
	ExComm.ShowMsg "操作成功",request.servervariables("http_referer")
End sub%>
</body>
</html>
