<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once("../../lib/cs_label.php");
include_once("../loginstate.php");
SystemPer('0_1');
$ac=CS_Request("ac");
$op=CS_Request("op");
if(empty($ac)) $ac='main';
?>
<!doctype html>
<html>
<head>
<meta charset="gbk">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>chshdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<link href="../../public/css/webox.css" rel="stylesheet" />
<script type="text/javascript" src="../res/js/ajax.js"></script>
<script language="javascript" src="../res/js/jquery.js"></script>
<script src="../../public/js/webox.js"></script>
<?php if($ac=="main"){ ?>
<script language="javascript">

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
 
function chgclass(id,cid){
	$.get("../ajax/ajax.php?ac=chgclasslist&id="+id+"&cid="+cid+"&sid=1",function(R){
		$("#class_"+id).html(R);												
	})
}
	
function savechgclass(cid,id){
	$.get("../ajax/ajax.php?ac=savecls&id="+id+"&cid="+cid+"&sid=1",function(R){
		$("#class_"+id).html(R);													  
	});
}
  
function chgtopic(id,cid){
	$.get("../ajax/ajax.php?ac=chgtopiclist&id="+id+"&cid="+cid+"&sid=1",function(R){
		$("#topic_"+id).html(R);												
	})
}
	
function savechgtopic(cid,id){
	$.get("../ajax/ajax.php?ac=savectopic&id="+id+"&cid="+cid+"&sid=1",function(R){
		$("#topic_"+id).html(R);													  
	});
}

function ShowStar(level,ids){
		   var htmlStr=""
			if(level==0){level=0}
			if (level>0){htmlStr+="<img src='../res/images/starno.gif' border='0' style='cursor:pointer;margin-left:2px;' title='取消推荐' onclick='EditReco("+ids+",0)'/>"}
			for(i=1;i<=level;i++){
			htmlStr+= "<img src='../res/images/star0.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+i+"星级' id='star"+ids+"_"+i+"' onclick='EditReco("+ids+","+i+")' />"}
			for(j=level+1;j<=5;j++){
			htmlStr+= "<img src='../res/images/star1.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+j+"星级' id='star"+ids+"_"+j+"' onclick='EditReco("+ids+","+j+")' />"
	}
		   $("#CS_Reco"+ids).html(htmlStr);
		   }
		   
function EditReco(ids,level){
  $.get("../ajax/ajax.php?id="+ids+"&sid=0&tid="+level+"&ac=editreco", 
	  function(obj){
		  if(obj=='ok'){
			  ShowStar(level,ids);
		  }else{
			  $("#CS_Reco"+ids).html("<font color='red'>Error!</font>");		
		  }
	  }
  );
} 

function Htmlgo(id,url){
	$.get(''+url+'&id='+id,function (R){
		if(R!='no'){
			$('#html_'+id).remove();
		}				   
	});
}

function del(_id){ 
  if (confirm("确定删除吗？")){
    window.location='?op=del&id='+_id;
    return true;
  }else{
     return false;
  }		
}
</script>
<?php }else{ ?>
<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(){
	$("#adddance").click(function(){
		var CS_Name=document.getElementById('CS_Name').value;
		var CS_CID=document.getElementById('CS_CIDa').value;
		var CS_User=document.getElementById('CS_User').value;
		var CS_PlayUrl=document.getElementById('CS_PlayUrl').value;
	if(CS_Name==""){
		$("#Msg").text("请填写歌曲名称！").css("color","red");
		return false;
		}
	else if(CS_CID=="0"){
		$("#Msg").text("请选择歌曲分类！").css("color","red");
		return false;
		}
	else if(CS_User==""){
		$("#Msg").text("请填写歌曲所属会员！").css("color","red");
		return false;
		}
	else if(CS_PlayUrl==""){
		$("#Msg").text("请填写歌曲视听地址！").css("color","red");
		return false;
		}
	});
});
$(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 = '抱歉，上传失败!';	
                                      }else{
					document.getElementById('CS_PlayUrl').value = response;	
					document.getElementById('CS_DownUrl1').value = response;
					document.getElementById('fileQueue').style.display = 'none';	
					document.getElementById('upp').style.height="0px";
                                      }
    				   }
	});
});
function SelectUpload(){
  window.open('http://csdj.so/api/?url=http://<?php echo $_SERVER['HTTP_HOST']?>/public/scripts/csdj.php&user=<?php echo CS_CsName?>','newwindow','height=100,width=700,top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
}
</script>
<?php } ?>
</head>
<body>
<div class="wrap">
<?php
   //修改\增加
   if($ac=='edit'){
        global $db;
   	$CS_ID=CS_Request("id");
        if($CS_ID){
	   $row=$db->getrow("SELECT * FROM ".Getdbname('dance')." Where CS_ID='".$CS_ID."'");
	   if($row){
		$Arr=array($row['CS_Name'],$row['CS_Color'],$row['CS_Pic'],$row['CS_CID'],$row['CS_TID'],$row['CS_Singer'],$row['CS_User'],$row['CS_PID'],$row['CS_FID'],$row['CS_Year'],$row['CS_Reco'],$row['CS_Coin'],$row['CS_Vip'],$row['CS_Hits'],$row['CS_Yhits'],$row['CS_Zhits'],$row['CS_Rhits'],$row['CS_Dx'],$row['CS_Yz'],$row['CS_Sc'],$row['CS_Template'],$row['CS_PlayUrl'],$row['CS_DownUrl1'],$row['CS_DownUrl2'],$row['CS_Content'],$row['CS_Tags'],$row['CS_Title'],$row['CS_Keywords'],$row['CS_Description']);
                $title="编辑音乐";
	   }
        }else{
		$Arr=array('','','','','','','','','',date('Y'),'','1','','0','0','0','0','','','','dance-play.html','','','','','','','','');
                $title="填加音乐";
        }
?>
<div class="nav">
	<ul class="cc">
		<li><a href="dance.php">音乐列表</a></li>
		<li class="current"><a href="dance.php?ac=edit"><?php echo $title?></a></li>
		<li><a href="dance.php?op=sh">音乐审核</a></li>
		<li><a href="dance.php?op=tid">推荐的音乐</a></li>
		<li><a href="dance.php?op=tid5">主页播放器</a></li>
		<li><a href="javascript:Popsboxif('歌曲批量操作',450,520,'dance_pl.php');">歌曲批量操作</a></li>
	</ul>
</div>
<form class="J_ajaxForm" data-role="edit" name="form" action="dance.php?ac=edit&op=editdata" method="post">
<div class="h_a"><?php echo $title?></div>
<div class="table_full">
	<table width="100%" class="J_check_wrap">
		<col class="th" />
		<col width="400" />
		<col />
		<tr><input name="id" type="hidden" value="<?php echo $CS_ID?>" />
			<th>音乐名称</th>
			<td>
				<input id="CS_Name" name="CS_Name" value="<?php echo $Arr[0]?>" type="text" class="input input_hd length_5">&nbsp;
				<input type="checkbox" name="CS_AddTime" class="checkbox" value="1" checked="checked"/>
				更新时间
			</td>
			<td><div class="fun_tips">填写音乐名称</div></td>
		</tr>
		<tr>
			<th>名称颜色</th>
			<td>
			<select class="select_2" name="CS_Color" >
  			<?php if(empty($Arr[1])){?>
  			<option  value="">选择颜色</option>
 			 <?php }else{?>
  			<option style="background-color:<?php echo $Arr[1]?>;color: <?php echo $Arr[1]?>" value="<?php echo $Arr[1]?>"></option>
  			<?php }?>
 			 <option style="background-color:#00FF00;color: #00FF00" value="#00FF00">绿色</option>
  			<option style="background-color:#0000CC;color: #0000CC" value="#0000CC">深蓝</option>
  			<option style="background-color:#FFFF00;color: #FFFF00" value="#FFFF00">黄色</option>
  			<option style="background-color:#FF33CC;color: #FF33CC" value="#FF33CC">粉红</option>
  			<option style="background-color:#FF0000;color: #FF0000" value="#FF0000">红色</option>
  			<option style="background-color:#660099;color: #660099" value="#660099">紫色</option>
 			 <option style="background-color:#FFFFFF;color: #FFFFFF" value="">无色</option>									
			</select>
			</td>
			<td><div class="fun_tips">选择名称颜色</div></td>
		</tr>
		<tr>
			<th>音乐图片</th>
			<td>
				<input name="CS_Pic" id="CS_Pic" value="<?php echo $Arr[2]?>" type="text" class="input input_hd length_4">
                                &nbsp;<input class="btn" type="button" onclick="Popsboxif('上传图片',470,100,'../upload.php?ac=dance');" value="上传图片" />
			</td>
			<td><div class="fun_tips">填写音乐图片,比如视频舞曲的图片</div></td>
		</tr>
		<tr>
			<th>音乐标签</th>
			<td>
				<input name="CS_Tags" id="CS_Tags" value="<?php echo $Arr[25]?>" type="text" class="input input_hd length_4">
                                &nbsp;<input class="btn" type="button" onclick="Popsboxif('选择标签',530,380,'../../public/tags.php?f=form.CS_Tags');" value="选择标签" />
			</td>
			<td><div class="fun_tips">填写音乐标签</div></td>
		</tr>
		<tr>
			<th>音乐分类</th>
			<td>
				<select class="select_2" name="CS_CID" id="CS_CIDa">
                                                <option value="0">选择分类</option>
            					 <?php
              						$sqlclass="select * from ".Getdbname('class')." where CS_YID=0 and CS_SID=1 and CS_FID=0";
									$results=$db->query($sqlclass);
									if($results){
										while ($row3=$db->fetch_array($results)){
                                                                                    if($row3['CS_ID']==$Arr[3]){
										         echo "<option value='".$row3['CS_ID']."' selected='selected'>".$row3['CS_Name']."</option>";
                                                                                    }else{
										         echo "<option value='".$row3['CS_ID']."' >".$row3['CS_Name']."</option>";
                                                                                    }
		                                                                     //处理此分类下的子分类
		                                                                     $sql2="select * from ".Getdbname('class')." where CS_FID=".$row3['CS_ID']."";
		                                                                     $class2=$db->query($sql2);
		                                                                     if($class2){
			                                                                     while($row2=$db->fetch_array($class2)){
                                                                                               if($row2['CS_ID']==$Arr[3]){
										                    echo "<option value='".$row2['CS_ID']."' selected='selected'>├ ".$row2['CS_Name']."</option>";
                                                                                               }else{
										                    echo "<option value='".$row2['CS_ID']."' >├ ".$row2['CS_Name']."</option>";
                                                                                               }
			                                                                     }
		                                                                     }
										}
									}
			  
			  			 ?>               
                                         </select>&nbsp;&nbsp;音乐专集：
				         <select class="select_2" name="CS_TID">
                                                <option value="0">选择专集</option>
            					 <?php
              						$sqlt="select * from ".Getdbname('topic')." where CS_YID=0 and CS_SID=1";
									$results=$db->query($sqlt);
									if($results){
										while ($row1=$db->fetch_array($results)){
                                                                                    if($row1['CS_ID']==$Arr[4]){
										         echo "<option value='".$row1['CS_ID']."' selected='selected'>".$row1['CS_Name']."</option>";
                                                                                    }else{
										         echo "<option value='".$row1['CS_ID']."' >".$row1['CS_Name']."</option>";
                                                                                    }
										}
									}
			  
			  			 ?>             
                                         </select>
			</td>
			<td><div class="fun_tips">选择音乐分类、专集</div></td>
		</tr>
		<tr>
			<th>音乐歌手</th>
			<td>
				<input name="CS_Singer" value="<?php echo $Arr[5]?>" type="text" class="input input_hd length_2">
                                &nbsp;&nbsp;所属会员：
				<input id="CS_User" name="CS_User" value="<?php echo $Arr[6]?>" type="text" class="input input_hd length_2">
			</td>
			<td><div class="fun_tips">填写音乐歌手、会员</div></td>
		</tr>
		<tr>
			<th>音乐播放器</th>
			<td>
				<select class="select_2" name="CS_PID">
                                                <option value="0" <?php if($Arr[7]==0) echo "selected='selected'";?>>wma播放器</option>
                                                <option value="7" <?php if($Arr[7]==7) echo "selected='selected'";?>>mp3,mp4播放器</option>
                                                <option value="1" <?php if($Arr[7]==1) echo "selected='selected'";?>>cmp播放器</option>
                                                <option value="2" <?php if($Arr[7]==2) echo "selected='selected'";?>>flv播放器</option>
                                                <option value="3" <?php if($Arr[7]==3) echo "selected='selected'";?>>优库播放</option>
                                                <option value="4" <?php if($Arr[7]==4) echo "selected='selected'";?>>土豆播放</option>
                                                <option value="5" <?php if($Arr[7]==5) echo "selected='selected'";?>>SWF播放</option>
                                                <option value="6" <?php if($Arr[7]==6) echo "selected='selected'";?>>音乐台播放</option>
                                         </select>&nbsp;&nbsp;播放服务器：
				         <select class="select_2" name="CS_FID">
                                                <option value="0">选择服务器</option>
            					 <?php
              						$sqlf="select * from ".Getdbname('fwqip')." ";
									$results=$db->query($sqlf);
									if($results){
										while ($row2=$db->fetch_array($results)){
                                                                                    if($row2['CS_ID']==$Arr[8]){
										         echo "<option value='".$row2['CS_ID']."' selected='selected'>".$row2['CS_Name']."</option>";
                                                                                    }else{
										         echo "<option value='".$row2['CS_ID']."' >".$row2['CS_Name']."</option>";
                                                                                    }
										}
									}
			  
			  			 ?>             
                                         </select>
			</td>
			<td><div class="fun_tips">选择音乐播放器、服务器</div></td>
		</tr>
		<tr>
			<th>发行年份</th>
			<td>
				<input name="CS_Year" value="<?php echo $Arr[9]?>" type="text" class="input input_hd length_2">
                                &nbsp;&nbsp;推荐星际：
				         <select class="select_2" name="CS_Reco">
                                                <option value="0">不推荐</option>
                                                <option value="1" <?php if($Arr[10]==1) echo "selected='selected'";?>>一星际</option>
                                                <option value="2" <?php if($Arr[10]==2) echo "selected='selected'";?>>二星际</option>
                                                <option value="3" <?php if($Arr[10]==3) echo "selected='selected'";?>>三星际</option>
                                                <option value="4" <?php if($Arr[10]==4) echo "selected='selected'";?>>四星际</option>
                                                <option value="5" <?php if($Arr[10]==5) echo "selected='selected'";?>>五星际</option>           
                                         </select>
			</td>
			<td><div class="fun_tips">选择发行年份、推荐星际</div></td>
		</tr>
		<tr>
			<th>下载金币</th>
			<td>
				<input name="CS_Coin" value="<?php echo $Arr[11]?>" type="text" class="input input_hd length_2">
                                &nbsp;个&nbsp;下载级别：
				         <select class="select_2" name="CS_Vip">
                                                <option value="0">游客下载</option>
                                                <option value="1" <?php if($Arr[12]==1) echo "selected='selected'";?>>普通会员</option>
                                                <option value="2" <?php if($Arr[12]==2) echo "selected='selected'";?>>VIP会员</option>          
                                         </select>
			</td>
			<td><div class="fun_tips">填写下载点数、级别</div></td>
		</tr>
		<tr>
			<th>音乐人气</th>
			<td>
				总：<input name="CS_Hits" value="<?php echo $Arr[13]?>" type="text" class="input input_hd length_1">
                                &nbsp;月：<input name="CS_Yhits" value="<?php echo $Arr[14]?>" type="text" class="input input_hd length_1">
                                &nbsp;周：<input name="CS_Zhits" value="<?php echo $Arr[15]?>" type="text" class="input input_hd length_1">
                                &nbsp;日：<input name="CS_Rhits" value="<?php echo $Arr[16]?>" type="text" class="input input_hd length_1">
			</td>
			<td><div class="fun_tips">填写音乐人气</div></td>
		</tr>
		<tr>
			<th>音乐属性</th>
			<td>
				大小：<input name="CS_Dx" id="CS_Dx" value="<?php echo $Arr[17]?>" type="text" class="input input_hd length_1">
                                &nbsp;音质：<input name="CS_Yz" value="<?php echo $Arr[18]?>" type="text" class="input input_hd length_1">
                                &nbsp;时长：<input name="CS_Sc" value="<?php echo $Arr[19]?>" type="text" class="input input_hd length_2">
			</td>
			<td><div class="fun_tips">填写音乐属性</div></td>
		</tr>
		<tr>
			<th>播放页模版</th>
			<td>
				<input name="CS_Template" id="CS_Template" value="<?php echo $Arr[20]?>" type="text" class="input input_hd length_2">
                                &nbsp;&nbsp;<input class="btn" type="button" value="浏览" style="width:60px" onclick="Popsboxif('选择模版',450,400,'../skins/skin_re.php');"/>
			</td>
			<td><div class="fun_tips">可以利用这个功能支持所有播放器</div></td>
		</tr>
		<tr>
			<th>视听地址</th>
			<td id="upp" style="clear:both; height:0px;">
				<input name="CS_PlayUrl" id="CS_PlayUrl" value="<?php echo $Arr[21]?>" type="text" class="input input_hd length_5">
                                <span id="fileQueue" style="width:435px; height:60px; float:left;display:none;"></span>
			</td>
			<td><div class="fun_tips"><input class="btn" type="file" name="uploadify" id="uploadify"/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="btn" type="button" value="上传到网盘"  onClick="SelectUpload();" />&nbsp;
			&nbsp;上传音乐</div></td>
		</tr>
		<tr>
			<th>下载地址</th>
			<td>
				<input name="CS_DownUrl1" id="CS_DownUrl1" value="<?php echo $Arr[22]?>" type="text" class="input input_hd length_5">
			</td>
			<td><div class="fun_tips">填写音乐下载地址</div></td>
		</tr>
		<tr>
			<th>备用下载一</th>
			<td>
				<input name="CS_DownUrl2" value="<?php echo $Arr[23]?>" type="text" class="input input_hd length_5">
			</td>
			<td><div class="fun_tips">填写音乐备用下载地址</div></td>
		</tr>
		<tr>
			<th>SEO标题</th>
			<td>
				<input type="text" name="CS_Title" class="input length_5" value="<?php echo $Arr[26]?>">
                        </td>
			<td><div class="fun_tips">SEO标题-title</div></td>
		</tr>
		<tr>
			<th>SEO关键词</th>
			<td>
				<input type="text" name="CS_Keywords" class="input length_5" value="<?php echo $Arr[27]?>">
                        </td>
			<td><div class="fun_tips">SEO关键词-Keywords</div></td>
		</tr>
		<tr>
			<th>SEO介绍</th>
			<td>
				<input type="text" name="CS_Description" class="input length_5" value="<?php echo $Arr[28]?>">
                        </td>
			<td><div class="fun_tips">SEO介绍-Description</div></td>
		</tr>
		<tr>
			<th>音乐歌词、简介</th>
			<td>
				<textarea class="length_6" name="CS_Content"><?php echo $Arr[24]?></textarea>

			</td>
			<td><div class="fun_tips">音乐歌词或者简介</div></td>
		</tr>
</div>
<div class="btn_wrap">
	<div class="btn_wrap_pd">
		<button type="submit" id="adddance" class="btn btn_submit mr10 J_ajax_submit_btn">提交</button>
                <div class="tips_error" id="Msg"></div>
	</div>
</div>
<?php
         //增加、修改
         if($op=='editdata'){
		global $db;
		$CS_ID=CS_Request("id");
		$CS_Name=CS_Request("CS_Name");
		$CS_Color=CS_Request("CS_Color");
		$CS_Pic=CS_Request("CS_Pic");
		$CS_CID=CS_Request("CS_CID");
		$CS_TID=CS_Request("CS_TID");
		$CS_Singer=CS_Request("CS_Singer");
		$CS_User=CS_Request("CS_User");
		$CS_PID=CS_Request("CS_PID");
		$CS_FID=CS_Request("CS_FID");
		$CS_Year=CS_Request("CS_Year");
		$CS_Reco=CS_Request("CS_Reco");
		$CS_Coin=CS_Request("CS_Coin");
		$CS_Vip=CS_Request("CS_Vip");
		$CS_Hits=CS_Request("CS_Hits");
		$CS_Yhits=CS_Request("CS_Yhits");
		$CS_Zhits=CS_Request("CS_Zhits");
		$CS_Rhits=CS_Request("CS_Rhits");
		$CS_Dx=CS_Request("CS_Dx");
		$CS_Yz=CS_Request("CS_Yz");
		$CS_Sc=CS_Request("CS_Sc");
		$CS_PlayUrl=CS_Request("CS_PlayUrl");
		$CS_DownUrl1=CS_Request("CS_DownUrl1");
		$CS_DownUrl2=CS_Request("CS_DownUrl2");
		$CS_Template=CS_Request("CS_Template");
		$CS_Content=CS_Request("CS_Content");
		$CS_AddTime=CS_Request("CS_AddTime");
		$CS_Tags=$_POST["CS_Tags"];
    		$CS_Title=CS_Request("CS_Title");
    		$CS_Keywords=CS_Request("CS_Keywords");
    	        $CS_Description=CS_Request("CS_Description");
                if(empty($CS_Name)||empty($CS_CID)||empty($CS_User)||empty($CS_PlayUrl)||empty($CS_DownUrl1)){
                          echo '<script>$("#Msg").text("抱歉，资料不完整!").css("color","red");</script>';
                          exit("<script>setTimeout(\"history.back(1);\",20000);</script>");
                }
		//判断增加还是修改
                if($CS_ID){
		            if(!$CS_Yz) $CS_Yz=DjData("yz",_CSDJ_ROOT_.$CS_DownUrl1);
		            if(!$CS_Dx) $CS_Dx =DjData("dx",_CSDJ_ROOT_.$CS_DownUrl1);
		            if(!$CS_Sc) $CS_Sc = DjData("sj",_CSDJ_ROOT_.$CS_DownUrl1);
                       if($CS_AddTime==1){
		            $sql="update ".Getdbname('dance')." set CS_Tags='".$CS_Tags."',CS_PlayUrl='".$CS_PlayUrl."',CS_DownUrl1='".$CS_DownUrl1."',CS_DownUrl2='".$CS_DownUrl2."',CS_AddTime='".date('Y-m-d H:i:s')."',CS_Name='".$CS_Name."',CS_Color='".$CS_Color."',CS_Pic='".$CS_Pic."',CS_CID=".$CS_CID.",CS_TID=".$CS_TID.",CS_Singer='".$CS_Singer."',CS_User='".$CS_User."',CS_PID=".$CS_PID.",CS_FID=".$CS_FID.",CS_Year='".$CS_Year."',CS_Reco=".$CS_Reco.",CS_Coin=".$CS_Coin.",CS_Vip=".$CS_Vip.",CS_Hits=".$CS_Hits.",CS_Yhits=".$CS_Yhits.",CS_Zhits=".$CS_Zhits.",CS_Rhits=".$CS_Rhits.",CS_Dx='".$CS_Dx."',CS_Yz='".$CS_Yz."',CS_Sc='".$CS_Sc."',CS_Template='".$CS_Template."',CS_Content='".$CS_Content."',CS_Title='".$CS_Title."',CS_Keywords='".$CS_Keywords."',CS_Description='".$CS_Description."' where CS_ID=".$CS_ID;
                       }else{
		            $sql="update ".Getdbname('dance')." set CS_Tags='".$CS_Tags."',CS_PlayUrl='".$CS_PlayUrl."',CS_DownUrl1='".$CS_DownUrl1."',CS_DownUrl2='".$CS_DownUrl2."',CS_Name='".$CS_Name."',CS_Color='".$CS_Color."',CS_Pic='".$CS_Pic."',CS_CID=".$CS_CID.",CS_TID=".$CS_TID.",CS_Singer='".$CS_Singer."',CS_User='".$CS_User."',CS_PID=".$CS_PID.",CS_FID=".$CS_FID.",CS_Year='".$CS_Year."',CS_Reco=".$CS_Reco.",CS_Coin=".$CS_Coin.",CS_Vip=".$CS_Vip.",CS_Hits=".$CS_Hits.",CS_Yhits=".$CS_Yhits.",CS_Zhits=".$CS_Zhits.",CS_Rhits=".$CS_Rhits.",CS_Dx='".$CS_Dx."',CS_Yz='".$CS_Yz."',CS_Sc='".$CS_Sc."',CS_Template='".$CS_Template."',CS_Content='".$CS_Content."',CS_Title='".$CS_Title."',CS_Keywords='".$CS_Keywords."',CS_Description='".$CS_Description."' where CS_ID=".$CS_ID;
                       }
                }else{
		            $CS_Yz=DjData("yz",_CSDJ_ROOT_.$CS_DownUrl1);
		            $CS_Dx =DjData("dx",_CSDJ_ROOT_.$CS_DownUrl1);
		            $CS_Sc = DjData("sj",_CSDJ_ROOT_.$CS_DownUrl1);
		            $sql="Insert ".Getdbname('dance')."  (CS_Tags,CS_PlayUrl,CS_DownUrl1,CS_DownUrl2,CS_Name,CS_Color,CS_Pic,CS_CID,CS_TID,CS_Singer,CS_User,CS_PID,CS_FID,CS_Year,CS_Reco,CS_Coin,CS_Vip,CS_Hits,CS_Yhits,CS_Zhits,CS_Rhits,CS_Dx,CS_Yz,CS_Sc,CS_Template,CS_Content,CS_AddTime,CS_Title,CS_Keywords,CS_Description) values ('".$CS_Tags."','".$CS_PlayUrl."','".$CS_DownUrl1."','".$CS_DownUrl2."','".$CS_Name."','".$CS_Color."','".$CS_Pic."',".$CS_CID.",".$CS_TID.",'".$CS_Singer."','".$CS_User."',".$CS_PID.",".$CS_FID.",'".$CS_Year."',".$CS_Reco.",".$CS_Coin.",".$CS_Vip.",".$CS_Hits.",".$CS_Yhits.",".$CS_Zhits.",".$CS_Rhits.",'".$CS_Dx."','".$CS_Yz."','".$CS_Sc."','".$CS_Template."','".$CS_Content."','".date('Y-m-d H:i:s')."','".$CS_Title."','".$CS_Keywords."','".$CS_Description."')";
                }

		if($db->query($sql)){
                    echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,数据操作成功!").css("color","#026E12");</script>';
	            echo "<script>setTimeout(\"window.location='dance.php'\",2000);</script>";
		}else{
                    echo '<script>$("#Msg").text("抱歉，操作失败!").css("color","red");</script>';
	            echo "<script>setTimeout(\"history.back(1);\",2000);</script>";
                }
         }
   }

   //音乐主列表
   if($ac=='main'){
                $op=CS_Request("op");
                $key=CS_Request("key");
                $cid=CS_Request("cid");
                $topic=CS_Request("topic");
		global $db;
                $sql="select * from ".Getdbname('dance')." where ";
                if($cid){
                      $sql.="cs_cid=".$cid." and ";
                }
                if($topic){
                      $sql.="cs_tid=".$topic." and ";
                }
                if($op=="sh"){
                      $sql.="cs_yid=1 ";
                }elseif($op=="tid"){
                      $sql.="cs_reco>1 ";
                }elseif($op=="tid5"){
                      $sql.="cs_reco=5 ";
                }else{
                      $sql.="cs_yid=0 ";
                }
                if($key){
                      $sql.="and (CS_Name like '%".$key."%' or CS_Singer like '%".$key."%') ";
                }
                $sql.=" order by CS_AddTime desc";
		$dancenum=$db->num_rows($db->query($sql));
		$Arr=getpagerow($sql,20);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$adminnum=$db->num_rows($result);

?>
<div class="nav">
	<ul class="cc">
		<li<?php if($ac=="" && $op=="") echo ' class="current"';?>><a href="dance.php">音乐列表</a></li>
		<li<?php if($ac=="edit") echo ' class="current"';?>><a href="dance.php?ac=edit">添加音乐</a></li>
		<li<?php if($op=="sh") echo ' class="current"';?>><a href="dance.php?op=sh">音乐审核</a></li>
		<li<?php if($op=="tid") echo ' class="current"';?>><a href="dance.php?op=tid">推荐的音乐</a></li>
		<li<?php if($op=="tid5") echo ' class="current"';?>><a href="dance.php?op=tid5">主页播放器音乐</a></li>
		<li><a href="javascript:Popsboxif('歌曲批量操作',450,520,'dance_pl.php');">歌曲批量操作</a></li>
	</ul>
</div>
	<div class="h_a">搜索<?php if($op=="tid5") echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#ff6600>《推荐5星际即可自动到主页播放器》</font>';?></div>	<form method="get" action="dance.php">
	<div class="search_type cc mb10">
		<div class="ul_wrap">
			<ul class="cc">
				<li>
					<label>关键字：</label><input name="key" value="" type="text" class="input length_3" placeholder="支持音乐名称和作者搜索">&nbsp;&nbsp;<button class="btn mr20" type="submit">搜索</button>
				</li>
				<li>
					<label>按分类：</label><select class="select_3" onchange="MM_jumpMenu('self',this,0)">
                                                <option value="dance.php">选择分类</option>
            					 <?php
              						$sqlclass="select * from ".Getdbname('class')." where CS_YID=0 and CS_SID=1 and CS_FID=0";
									$results=$db->query($sqlclass);
									if($results){
										while ($row3=$db->fetch_array($results)){
       
										         echo "<option value='?cid=".$row3['CS_ID']."' >".$row3['CS_Name']."</option>";

		                                                                     //处理此分类下的子分类
		                                                                     $sql2="select * from ".Getdbname('class')." where CS_FID=".$row3['CS_ID']."";
		                                                                     $class2=$db->query($sql2);
		                                                                     if($class2){
			                                                                     while($row2=$db->fetch_array($class2)){
										                    echo "<option value='?cid=".$row2['CS_ID']."' >├ ".$row2['CS_Name']."</option>";
			                                                                     }
		                                                                     }
										}
									}
			  
			  			 ?>            
                                         </select>
				</li>
				<li>
					<label>按专集：</label><select class="select_3" onchange="MM_jumpMenu('self',this,0)">
                                                <option value="dance.php">选择专集</option>
            					 <?php
              						$sqltopic="select * from ".Getdbname('topic')." where CS_SID=1 ";
									$results=$db->query($sqltopic);
									if($results){
										while ($row5=$db->fetch_array($results)){
										    echo "<option value='?topic=".$row5['CS_ID']."' >".$row5['CS_Name']."</option>";
										}
									}
			  
			  			 ?>             
                                         </select>
				</li>
			</ul>
		</div>
	</div>
</form>
<form class="J_ajaxForm" action="dance.php?op=delall" method="post" name="formb">
<div class="table_list">
<?php
	if($adminnum==0){
                echo "<table width=\"100%\">
				<tbody>
					<tr><td class=\"tac\">啊哦，没有符合条件的内容！</td></tr>
				</tbody>
		</table>";

        }else{
                echo "<table width=\"100%\" id=\"dellist\">
		<thead>
			<tr>
				<td><label>选</label></td>
				<td>名称</td>
				<td><span>会员</span></td>
				<td><span>日人气</span></td>
				<td><span>总人气</span></td>
				<td><span>音乐分类</span></td>
				<td><span>专集</span></td>
				<td><span>推荐星际</span></td>
				<td><span>审核</span></td>
				<td><span>发布时间</span></td>
				<td>编辑/删除</td>
			</tr>
		</thead>";
        }
        if($result){
	     while ($row = $db ->fetch_array($result)){
                $class=$db->getrow("select CS_Name from ".Getdbname('class')." where CS_ID=".$row['CS_CID']."");
			if(date("Y-m-d",strtotime($row['CS_AddTime']))==date('Y-m-d')){
				$addtime="<font color=red>".date("Y-m-d",strtotime($row['CS_AddTime']))."</font>";
			}else{
				$addtime=date("Y-m-d",strtotime($row['CS_AddTime']));
			}
                        if($row['CS_TID']!=0){
				$tpic="<img src=\"../res/images/topicyes.gif\" onclick=\"chgtopic(".$row['CS_ID'].",".$row['CS_TID'].")\" title=\"修改专集\" style=\"cursor:pointer\">";
			}else{
				$tpic="<img src=\"../res/images/topicno.gif\" onclick=\"chgtopic(".$row['CS_ID'].",".$row['CS_TID'].")\" title=\"修改专集\" style=\"cursor:pointer\">";
			}
			if($row['CS_YID']==1){
                                $shenhe='<a href="dance.php?op=shenhe&id='.$row["CS_ID"].'&yid=0" title="点击审核音乐"><img src="../res/images/no.gif"/></a>';
                        }else{
                                $shenhe='<a title="点击取消审核该音乐" href="dance.php?op=shenhe&id='.$row["CS_ID"].'&yid=1"><img src="../res/images/yes.gif"/></a>';
                        }
                        if($op!="sh" && CS_Webmode==3){
		             $html=HtmlShow($row['CS_ID'],'../html/html_dance.php?ac=ids&id='.$row['CS_ID'].'',LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID']));
                        }else{
		             $html='';
                        }
                        if($op=="sh"){
                              $dlink="dplay.php?id=".$row['CS_ID'];
                        }else{
                              $dlink=LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID']);
                        }
                  echo "<tr>
				<td><input type=\"checkbox\" class=\"J_check\" name=\"CS_ID[]\" value=\"".$row['CS_ID']."\" id=\"CS_ID\"/>&nbsp;".$row['CS_ID']."</td>
				<td><a href=\"".$dlink."\" target=\"play\"><font color=".$row['CS_Color'].">".getlen('len',35,$row['CS_Name'])."</font></a>".$html."</td>
				<td><a href=\"".userlink('index',getuser('uid',$row['CS_User']))."\" target=\"user\">".$row['CS_User']."</a></td>
				<td>".$row['CS_Rhits']."</td>
				<td>".$row['CS_Hits']."</td>
				<td><span id=\"class_".$row['CS_ID']."\">".$class['CS_Name']."<img src=\"../res/images/edit.gif\" title=\"修改分类\" onclick=\"chgclass(".$row['CS_ID'].",".$row['CS_CID'].")\" style=\"cursor:pointer\"></span></td>
				<td><span id=\"topic_".$row['CS_ID']."\">".$tpic."</span></td>
				<td id=\"CS_Reco".$row['CS_ID']."\"><script language=\"javascript\">ShowStar(".$row['CS_Reco'].",".$row['CS_ID'].")</script></td>
				<td>".$shenhe."</td>
				<td>".$addtime."</td>
				<td><a href=\"?ac=edit&id=".$row['CS_ID']."\">编辑</a> &nbsp;&nbsp;<a style=\"cursor:pointer;\"  onclick=\"del(".$row['CS_ID'].")\">删除</a></td>
			</tr>";
             }
        }
?>
	</table>
			<div class="p10">
				<div class="pages">
				     <?php if($dancenum>20) echo $Arr[0];?>
                                </div>
			</div>
</div>
<div class="btn_wrap">
	<div class="btn_wrap_pd">
                <label class="mr20"><input type="checkbox" class="J_check_all" id="chkall" onClick="return CheckAll(this.form)" value="on">全选</label>
		<input name="button1" type="button" class="btn J_ajax_submit_btn" value="批量删除" onClick="DelInfo(this.form)">
            <?php if(CS_Webmode==3){ ?>
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="批量生成" onClick="MarkInfo(this.form,'dance')">
            <?php } ?>
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="批量修改" onClick="EditInfo(this.form,'dance')">
                <div class="tips_error" id="Msg"></div>
	</div>
</div>
</form>
<?php
          //审核
          if($op=='shenhe'){
		global $db;
		$CS_ID=CS_Request("id");
		$CS_YID=CS_Request("yid");
                $sql="update ".Getdbname('dance')." set CS_YID=".$CS_YID." where CS_ID=".$CS_ID;
		if($db->query($sql)){
			echo "<script>window.location='javascript:history.go(-1);';</script>";
		}
          }

          //删除
          if($op=='del'){
		global $db;
		$CS_ID=CS_Request("id");
                $clsid=$db->Getrow("select CS_CID from ".Getdbname('dance')." where CS_ID=".$CS_ID."");
                $sql="delete from ".Getdbname('dance')." where CS_ID=".$CS_ID;
		if($db->query($sql)){
			if(CS_Webmode==3){
				$fileurl=LinkUrl('play','dance','id',$clsid['CS_CID'],$CS_ID);
				$fileurl="../../".substr($fileurl,strlen(CS_WebPath));
				if(file_exists($fileurl)){
					unlink($fileurl);
				}	
			}
			if(file_exists("../..".$clsid['CS_PlayUrl'])){  //删除歌曲本地数据
					@unlink("../..".$clsid['CS_PlayUrl']);
			}
                        $db->query("delete from ".Getdbname('dt')." where CS_DID=".$CS_ID." and (CS_CID=3 or CS_CID=2 or CS_CID=6)");
                        $db->query("delete from ".Getdbname('down')." where CS_DID=".$CS_ID."");
                        $db->query("delete from ".Getdbname('fav')." where CS_DID=".$CS_ID."");
                        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,删除成功!").css("color","#026E12");</script>';
	                echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
		}
          }

          //批量删除
          if($op=='delall'){
		global $db;
		$CS_ID=CS_RequestBox("CS_ID");
	        $Arr=explode(',',$CS_ID);
		for($i=0;$i<count($Arr);$i++){
			if(CS_Webmode==3){
		          $clsid=$db->Getrow("select CS_CID from ".Getdbname('dance')." where CS_ID=".$Arr[$i]."");
				$fileurl=LinkUrl('play','dance','id',$clsid['CS_CID'],$Arr[$i]);
				$fileurl="../../".substr($fileurl,strlen(CS_WebPath));
				if(file_exists($fileurl)){
					unlink($fileurl);
				}	
			}
			if(file_exists("../..".$clsid['CS_PlayUrl'])){  //删除歌曲本地数据
					@unlink("../..".$clsid['CS_PlayUrl']);
			}
			$db->query("delete from ".Getdbname('dt')." where CS_DID=".$Arr[$i]." and (CS_CID=3 or CS_CID=2 or CS_CID=6)");
			$db->query("delete from ".Getdbname('fav')." where CS_DID=".$Arr[$i]."");
			$db->query("delete from ".Getdbname('down')." where CS_DID=".$Arr[$i]."");
			$db->query("delete from ".Getdbname('dance')." where CS_ID=".$Arr[$i]."");
		}
                        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,删除成功!").css("color","#026E12");</script>';
	                echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
          }
   }
?>
</div>
</body>
</html>