<?php
if(empty($op)) $op='list';
?>
  <!--- content -->
  <div class="neir">
    <div class="top">音乐分享</div>
      <div class="content">
		<div class="main_nav">
			<ul>
				<li class="<?php if($op=='ds'){ echo 'nava_4';}else{ echo 'navb_5';}?>"><a href="?ac=music&op=ds">待审音乐</a></li>
				<li class="<?php if($op=='list'){ echo 'nava_4';}else{ echo 'navb_5';}?>"><a href="?ac=music&op=list">音乐列表</a></li>
			</ul>
			<div class="action"><a href="?ac=music&op=add">上传音乐</a></div>
		</div>
		<div class="main_nav2">
<?php if($op=="add"){?>
<script type="text/javascript" charset="utf-8" src="../public/editor/kindeditor.js"></script>
<script type="text/javascript"> KE.show({
	id : 'CS_Content',
	resizeMode : 1,
	allowPreviewEmoticons : false,
	allowUpload : false,
	items : [
	'source', '|', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
	'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
	'insertunorderedlist', '|', 'image', 'link', 'unlink']
	});
</script>
<script type="text/javascript" src="../public/scripts/swfobject.js"></script>
<script type="text/javascript" src="../public/scripts/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#uploadify").uploadify({
		'uploader'       : '<?php echo CS_WebPath;?>public/scripts/uploadify.swf',
		'script'         : '<?php echo CS_WebPath;?>public/scripts/uploadify.php',
		'cancelImg'      : '<?php echo CS_WebPath;?>public/images/cancel.png',
		'folder'         : '<?php echo CS_WebPath;?>annex/music',
		'queueID'        : 'fileQueue',
		'queueSizeLimit' : 1,
		'fileDesc'       : '支持格式:mp3,wma,flv,mp4', 
    	        'fileExt'        : '*.mp3;*.wma;*.flv;*.mp4' ,
		'auto'           : true,
		'multi'          : true,
		'height'         : 26,
		'width'          : 82,
		'onComplete'  	 : function(event, ID, fileObj, response, data) {
                                      if(response=="no"){
					document.getElementById('CS_PlayUrl').value = '';	
                                        document.getElementById('fileQueue').innerHTML = '<font color=red><b>抱歉，上传失败!</b></font>';
                                      }else{
					document.getElementById('CS_PlayUrl').value = response;	
					document.getElementById('CS_DownUrl1').value = response;	
                                        document.getElementById('upp').style.height="0px";
                                        document.getElementById('Msg').innerHTML = '<font color=#0000ff><b>恭喜您，上传成功,请完成信息发布!</b></font>';
                                        document.getElementById('fileQueue').style.display='none';	
                                      }
    				   }
	});
});
function SelectUpload1(){ //FTP
  Popsboxif('FTP上传歌曲',470,200,'../public/scripts/ftpup.php');
}
function SelectUpload2(){  //飞速
  window.open('../public/scripts/rayfileup.php','newwindow','height=200,width=600,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
function SelectUpload3(){  //威盘
  window.open('http://www.vdisk.cn/api/webupload?success=http://<?php echo $_SERVER['HTTP_HOST'].CS_WebPath?>public/scripts/kimi.php','newwindow','height=100,width=700,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
function SelectUpload4(){  //官方盘
  window.open('http://csdj.so/api/?url=http://<?php echo $_SERVER['HTTP_HOST'].CS_WebPath?>public/scripts/csdj.php&user=<?php echo CS_CsName?>','newwindow','height=100,width=600,top=80,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}

function MM_jumpMenu(selObj,restore){
         var ary = ''; 
         var str = ''; 
         var id = selObj.options[selObj.selectedIndex].value; 
<?php 
      $sqlclass="select * from ".Getdbname('class')." where CS_FID<>0 and CS_SID=1";
      $results=$db->query($sqlclass);
	if($results){
	while ($row3=$db->fetch_array($results)){
?>
	 ary=ary+'<?php echo $row3['CS_FID']?>|<?php echo $row3['CS_ID']?>|<?php echo $row3['CS_Name']?>$$$';
<?php
 	}
	}
?>
        strs=ary.split('$$$');
        for ( var i=0 ; i < strs.length-1 ; ++i ) {
              strss=strs[i].split('|');
             if(strss[0]==id){
                   str=str+'<option value="'+strss[1]+'">'+strss[2]+'</option>';
             }
        }
		if(str==''){
           str='<option value="0">该分类没有风格</option>';
		}
        var strr = '<select name="CS_FID" id="CS_FID">'+str+'</select>'; 
        document.getElementById('CS_FG').innerHTML=strr;
}
</script>
<script language="javascript">
$(document).ready(function(){
	$("#adddj").click(function(){
		var CS_Name=$("#CS_Name").val();
		var CS_CID=$("#CS_CID").val();
		var CS_Tags=$("#CS_Tags").val();
		var CS_PlayUrl=$("#CS_PlayUrl").val();
	$("#CS_Name").css("border-color","#666 #ccc #ccc #666");
	if(CS_PlayUrl==""){
		$("#Msg").text("出错了，请先上传音乐！").css("color","red");
                alert("请先上传音乐！");
		return false;
		}
	else if(CS_Name==""){
		$("#CS_Name").css("border","1px solid red");
		$("#Msg").text("出错了，请填写音乐名称！").css("color","red");
                alert("请填写音乐名称！");
		return false;
		}
	else if(CS_CID=="0"){
		$("#Msg").text("出错了，请选择音乐分类！").css("color","red");
                alert("请选择音乐分类！");
		return false;
		}
	else if(CS_Tags==""){
		$("#Msg").text("出错了，请选择音乐标签！").css("color","red");
                alert("请选择音乐标！");
                Popsboxif('选择标签',530,380,'../public/tags.php?f=form.CS_Tags');
		return false;
		}
	});
});
</script>
	<form action="do.php?ac=music" id="form" name="form" method="post">
	<table class="user_mod_list" cellpadding="0" cellspacing="0">
		<tr><td id="upp" style="clear:both; height:0px;">
			<span class="t"><i>*</i>选择歌曲：</span>
			<div class="demo-box" id="custom-demo" style="width:500px; float:left;">
                               <?php if(CS_DjMode==0){ ?>	
				<input type="file" name="uploadify" id="uploadify"/>
				<div id="fileQueue" style="width:435px; height:60px; float:left;display:none;"></div>
                               <?php }elseif(CS_DjMode==1){ ?>	
				<span class="button-main"><span><button type="button" onClick="SelectUpload1();" >选择文件</button></span></span>
                               <?php }elseif(CS_DjMode==2){ ?>	
				<span class="button-main"><span><button type="button" onClick="SelectUpload2();" >选择文件</button></span></span>
                               <?php }elseif(CS_DjMode==3){ ?>	
				<span class="button-main"><span><button type="button" onClick="SelectUpload3();" >选择文件</button></span></span>
                               <?php }elseif(CS_DjMode==4){ ?>	
				<span class="button-main"><span><button type="button" onClick="SelectUpload4();" >选择文件</button></span></span>
                               <?php }else{ ?>	
				<span class="button-main"><span><button type="button" onClick="alert('本站已经关闭上传,如有需要请联系管理员!');" >选择文件</button></span></span>
                               <?php } ?>	
			</div>
	                <input type="hidden" class="user_reg_input" name="CS_PlayUrl" id="CS_PlayUrl">
	                <input type="hidden" class="user_reg_input" name="CS_DownUrl1" id="CS_DownUrl1">
	                <input type="hidden" class="user_reg_input" name="CS_Dx" id="CS_Dx">
		</td></tr>
		<tr><td height='50'><span class="t"><i>*</i>上传分区：</span><span class="select"><select name="CS_CID" id="CS_CID" onchange="MM_jumpMenu(this,0)">
<option value="0">--请选择--</option>
<?php 
      $sqlc="select * from ".Getdbname('class')." where CS_FID=0 and CS_SID=1";
      $results=$db->query($sqlc);
	if($results){
	   while ($row1=$db->fetch_array($results)){
             echo '<option value="'.$row1['CS_ID'].'">'.$row1['CS_Name'].'</option>';
           }
        }
?>
</select></span><span class="reg_msg" id="cid_info">请选择歌曲的分区。</span></td></tr>
		<tr><td height='50'><span class="t">音乐风格：</span><span class="select" id="CS_FG"><select name="CS_FID" id="CS_FID"><option value="0">--请选择--</option></select></span><span class="reg_msg" id="sid_info">请选择歌曲的风格，可以留空。</span></td></tr>
		<tr><td height='50'><span class="t">音乐专集：</span><span class="select"><select name="CS_TID" id="CS_TID"><option value="0">--请选择--</option>
<?php 
      $sqlt="select * from ".Getdbname('topic')." where CS_User='".$cscms_name."' and CS_YID=0";
      $results=$db->query($sqlt);
	if($results){
	   while ($row2=$db->fetch_array($results)){
             echo '<option value="'.$row2['CS_ID'].'">'.$row2['CS_Name'].'</option>';
           }
        }
?>
</select></span><span class="reg_msg" id="sid_info">请选择歌曲的专集，可以留空。</span></td></tr>
		<tr><td height='50'><span class="t"><i>*</i>名称：</span><input type="text" class="user_reg_input" id="CS_Name" name="CS_Name"><span class="reg_msg" id="title_info">请输入歌曲的名称。</span></td></tr>
		<tr><td height='50'><span class="t"><i>*</i>标签：</span><input type="text" class="user_reg_input" id="CS_Tags" name="CS_Tags" style="cursor:hand;" onclick="Popsboxif('选择标签',530,380,'../public/tags.php?f=form.CS_Tags');" readonly/><span class="reg_msg" id="tags_info">多个标签，请用英文逗号隔开。</span></td></tr>	
		<tr><td style="clear:both; height:140px;"><span class="t">歌曲介绍：</span><textarea style="width:450px; height:140px;" id="CS_Content" name="CS_Content"></textarea></td></tr>
	</table>
	<div style="padding-top:10px;margin-left:150px;"><span class="button-main"><span><button type="submit" id="adddj" >确定发布</button></span></span><div id="Msg"></div></div>
	</form>
<?php }else{ ?>
			<ul>
			       <li class='<?php if(empty($id)) echo 'nav2a_4';?>'><a href="?ac=music&op=<?php echo $op?>">全部音乐</a></li>
<?php
	global $db;
	$sqlw="select * from ".Getdbname('class')." where cs_sid=1 order by CS_sid desc";
	$rs=$db->query($sqlw);
	$num=$db->num_rows($rs);
	$nums=7;
	if($num<$nums){
		$j=$num;
	}else{
		$j=$nums;
	}
	for($i=0;$i<$j;$i++){
		$rowc=$db->fetch_array($rs);
                if($id==$rowc['CS_ID']){
                      $CSS="nav2a_4";
                }else{
                      $CSS="";
                }
           echo '<li class="'.$CSS.'"><a href="?ac=music&op='.$op.'&id='.$rowc['CS_ID'].'">'.$rowc["CS_Name"].'</a></li>';
	}
?> 
			</ul>
		</div>
		<div  class="favoritesList" id="list">
<?php
        $j=1;
	$sql="select * from ".Getdbname('dance')." where cs_user='".$cscms_name."'";
        if(!empty($id)) $sql.=' and cs_cid='.$id;
        if($op=='list'){
              $sql.=' and cs_yid=0';
        }else{
              $sql.=' and cs_yid=1';
        }
        $sql.=' order by cs_addtime desc';
		$Arr=getuserpage($sql,"15");//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate="a";
		if($result){
			while ($row = $db ->fetch_array($result)){
		        $numdate="b";
                   echo '<li><span class="cbox"><input name="checked" type="checkbox" value="'.$row['CS_ID'].'" /></span><span class="mname"><a href="'.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID']).'" target="p">'.$j.'.'.$row['CS_Name'].'</a></span><span class="mclass">'.getclass($row['CS_CID']).'</span><span class="mrank appraise'.$row['CS_Reco'].'" title="推荐星际"></span><span class="mtime" title="发布时间">'.datetime($row['CS_AddTime']).'</span></li>';
                        $j=$j+1;
	                }
                }
        if($numdate=="a") echo '<li>没有相关记录!</li>';
?>
		</ul>
		</div>
		<div class="page">
		<span class="button2-main"><span><button type="button" onclick=clk('all','list');>全选</button></span></span>
		<span class="button2-main"><span><button type="button" onclick=clk('un','list');>反选</button></span></span>
		<span class="button3-main"><span><button type="button" onclick=clk('play','list');>连续播放</button></span></span></form>
		<div class="pages">
                       <?php echo $Arr[0];?>
               </div>

<?php } ?>
	</div>
      </div>
    <div class="end"></div>
  </div>
