<?php
/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
?>
<link type="text/css" rel="stylesheet" href="css/list.css" />
<?php if($view==""){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=malbum" class="on tag-item"><span>已审专辑</span></a>
	<a href="index.php?ac=malbum&view=passed" class="tag-item"><span>未审专辑</span></a>
	<a href="index.php?ac=malbum&view=upload" class="tag-item"><span>创建专辑</span></a>
	<a href="index.php?ac=malbum&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div>  
   <div class="malbum"> 
    <div class="head"><strong>已用过审核的音乐专辑</strong></div> 
<?php
$malbumsql="select CD_ID,CD_Name,CD_Pic,CD_YuYan,CD_GongSi from ".tname('malbum')." where CD_Passed=0 and CD_User='" . $CcTvAi_com_username . "' order by UNIX_TIMESTAMP(CD_AddTime) desc";
$Arr=getuserpage($malbumsql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>没有已审专辑</center>';
} else {
	if($result) {
		while($malbum=$db->fetch_array($result)) {
	echo'<div class="list"> 
    <ul class="list_con" id="yc_list_tj"> 
     <li> 
	 <a href="../malbum_p.php?id='.$malbum['CD_ID'].'" class="m_head"><img alt="" src="'.LinkPicUrl($malbum['CD_Pic'],"malbum").'" width="60" height="60" /></a> 
	 <a href="index.php?ac=malbum&view=song&classid='.$malbum['CD_ID'].'"> <h4>'.$malbum['CD_Name'].'</h4> <p><span>'.$malbum['CD_YuYan'].'</span><span>添加音乐</span></p> </a> </li> 
    </ul> 
    <div> 
    </div> 
   </div>';
}
} 
} 
?> 
<div class="page"><?php echo $Arr[0];?></div>
   </div>  
<?php }elseif($view=="passed"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=malbum" class="tag-item"><span>已审专辑</span></a>
	<a href="index.php?ac=malbum&view=passed" class="on tag-item"><span>未审专辑</span></a>
	<a href="index.php?ac=malbum&view=upload" class="tag-item"><span>创建专辑</span></a>
	<a href="index.php?ac=malbum&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div>  
   <div class="malbum"> 
    <div class="head"><strong>正在审核中的音乐专辑</strong></div> 
<?php
$malbumsql="select CD_ID,CD_Name,CD_Pic,CD_YuYan,CD_GongSi from ".tname('malbum')." where CD_Passed=1 and CD_User='" . $CcTvAi_com_username . "' order by UNIX_TIMESTAMP(CD_AddTime) desc";
$Arr=getuserpage($malbumsql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>没有待审专辑</center>';
} else {
	if($result) {
		while($malbum=$db->fetch_array($result)) {
	echo'<div class="list"> 
    <ul class="list_con" id="yc_list_tj"> 
     <li> 
	 <a href="../malbum_p.php?id='.$malbum['CD_ID'].'" class="m_head"><img alt="" src="'.LinkPicUrl($malbum['CD_Pic'],"malbum").'" width="60" height="60" /></a> 
	 <a href="index.php?ac=malbum&view=song&classid='.$malbum['CD_ID'].'"> <h4>'.$malbum['CD_Name'].'</h4> <p><span>'.$malbum['CD_YuYan'].'</span><span>添加音乐</span></p> </a> </li> 
    </ul> 
    <div> 
    </div> 
   </div>';
}
} 
} 
?> 
<div class="page"><?php echo $Arr[0];?></div>
   </div> 
<?php }elseif($view=="upload"){?>
<link type="text/css" rel="stylesheet" href="css/up.css" /> 
<script type="text/javascript" src="js/jquery.js"></script>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=malbum" class="tag-item"><span>已审专辑</span></a>
	<a href="index.php?ac=malbum&view=passed" class="tag-item"><span>未审专辑</span></a>
	<a href="index.php?ac=malbum&view=upload" class="on tag-item"><span>创建专辑</span></a>
	<a href="index.php?ac=malbum&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div>
<?php $editor=SafeRequest("editor", "get"); if($editor==""){?>
  <script type="text/javascript">
      function fileSelected() {
        var file = document.getElementById('Filedata').files[0];
        if (file) {
          var fileSize = 0;
          if (file.size > 1024 * 1024)
            fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
          else
            fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
          document.getElementById('fileName').innerHTML = '文件名: ' + file.name;
          document.getElementById('fileSize').innerHTML = '文件大小: ' + fileSize;
          document.getElementById('fileType').innerHTML = '文件类型: ' + file.type;
		  var cd_name=/\.[^\.]+/.exec(file.name);
		  var cd_type = "<?php echo cd_uppictype?>";
		  if(cd_type.indexOf(''+cd_name+'') > 0 ){}else{sweetAlert({title: "上传提醒",text: "文件格式错误，请重新选择",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});}
		  
		  var cd_size=document.getElementById('Filedata').files[0].size;
		  var cd_uppicsize="<?php echo (cd_uppicsize*1024*1024); ?>";
		  if(cd_size > cd_uppicsize){sweetAlert({title: "上传提醒",text: "文件太大，请重新选择",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});}
        }
      }
      function uploadFile() {
        var fd = new FormData();
        fd.append("Filedata", document.getElementById('Filedata').files[0]);
        var xhr = new XMLHttpRequest();
        xhr.upload.addEventListener("progress", uploadProgress, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.addEventListener("abort", uploadCanceled, false);
        xhr.open("POST", "upload.php?ac=addpic&op=malbum&id=<?php echo date('YmdHis', time()).rand(2, pow(2, 24))?>");
        xhr.send(fd);
      }
      function uploadProgress(evt) {
        if (evt.lengthComputable) {
          var percentComplete = Math.round(evt.loaded * 100 / evt.total);
		  if(percentComplete==100){
			  document.getElementById('progressNumber').innerHTML = "<div id=\"percent\" style=\"left: -"+ percentComplete.toString() +"%;\">服务器正在处理中,请稍等....</div><div id=\"line\" w=\"100\" style=\"width: "+ percentComplete.toString() +"%;\"></div>";
		  }else{
			  document.getElementById('progressNumber').innerHTML = "<div id=\"percent\" style=\"left: -"+ percentComplete.toString() +"%;\">"+ percentComplete.toString() +"%</div><div id=\"line\" w=\"100\" style=\"width: "+ percentComplete.toString() +"%;\"></div>";
		  }
        }
        else {
          document.getElementById('progressNumber').innerHTML = '未知大小';
        }
      }
      function uploadComplete(evt) {
        var uploadok=evt.target.responseText;
		if(uploadok==10000){
			sweetAlert({title: "上传提醒",text: "请先登录后操作",type: "",confirmButtonColor: "#1abc9c"});
		} else if(uploadok==10001){
			sweetAlert({title: "上传提醒",text: "请上传正确的照片文件",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
		} else if(uploadok==10002){
			sweetAlert({title: "上传提醒",text: "保存文件失败",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
		} else if(uploadok==10003){
			sweetAlert({title: "上传提醒",text: "请选择要上传的文件",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
		} else if(uploadok==10004){
			sweetAlert({title: "上传提醒",text: "照片文件太大",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
		} else if(/[\u4E00-\u9FA5]/g.test(uploadok)){
			sweetAlert({title: "上传提醒",text: "上传成功,请完善专辑信息",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = 'index.php?ac=malbum&view=upload&editor=1&'+uploadok+'';});
		} else {
			sweetAlert({title: "上传提醒",text: "未知错误",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
		}
		
      }
	  
      function uploadFailed(evt) {
        sweetAlert({title: "上传提醒",text: "文件错误",type: "",confirmButtonColor: "#1abc9c"}, function() {location.href = location.href;});
      }
      function uploadCanceled(evt) {
        sweetAlert({title: "上传提醒",text: "文件上传中断",type: "",confirmButtonColor: "#1abc9c"});
      }
    </script>   
   <div class="malbum"> 
    <div class="head"><strong>上传封面图片</strong></div> 
   </div> 
<div class="malbum-up">
 <div style="padding: 10px;line-height: 25px;">
 <p>为您的音乐专辑选一张封面图片</p>
     <div id="fileName"></div>
    <div id="fileSize"></div>
    <div id="fileType"></div>
</div>
<form class="form" enctype="multipart/form-data" method="post" action="upload.php?ac=malbum&op=dancepic">
	<input type="file" name="Filedata" class="file" id="Filedata" onchange="fileSelected();"/>
	<input type="button" value="上传" onclick="uploadFile()" class="form-btn"/>
</form>
 </div>
<div class="up-barline"><div id="progressNumber"></div></div>
<?php
 }else{ 
$CD_Pic=SafeRequest("cd_pic", "get");
if($CD_Pic==""){showmessage("请先上传专辑封面图片", "index.php?ac=malbum&view=upload", 0);}
?>
   <div class="malbum"> 
    <div class="head"><strong>完善专辑信息</strong></div> 
   </div> 
  <div class="x5-tc">
    <div class="x5-tc-popover"> 
     <div class="x5-tc-poptit"> 
      <b title="关闭" class="close" onclick="shareclose();">&times;</b> 
      <h3>为专辑选择一个分类</h3> 
     </div> 
     <div class="x5-tc-popbod"> 
  <div class="popDiyTags-form form-box"> 
<?php
$classq='malbumclass';
function Get_Fclass($id,$classq) { 
global $db;
$Fsql="select CD_ID,CD_Name from " . tname($classq) . " where CD_FatherID='".$id."' and CD_IsHide=0 order by CD_TheOrder asc";
$Fresult=$db->query($Fsql);
    if($Fresult && $db->num_rows($Fresult)){
        while($Frow=$db->fetch_array($Fresult)) { 
            $str .= '<dd><a onclick="document.getElementById(\'CD_ClassID\').value=\''.$Frow['CD_ID'].'\';document.getElementById(\'ClassID\').value=\''.$Frow['CD_ID'].'\';shareclose();">'.$Frow['CD_Name'].'</a></dd>';
            Get_Fclass($Frow['CD_ID']); 
        } 
    } 
    return $str; 
}
global $db;
$sql="select CD_ID,CD_Name from " . tname($classq) . " where CD_FatherID=0 and CD_IsHide=0 order by CD_TheOrder asc";
$result=$db->query($sql);
$classnum=$db->num_rows($result);
if($result) {
	while($row=$db->fetch_array($result)) {
?>
   <dl class="popDiyTags-list clearfix">
    <dt><?php echo $row['CD_Name']?></dt>
    <dd><a onclick="document.getElementById('CD_ClassID').value='<?php echo $row['CD_ID']?>';document.getElementById('ClassID').value='<?php echo $row['CD_ID']?>';shareclose();"><?php echo $row['CD_Name']?></a></dd>
<?php
echo get_Fclass($row['CD_ID'],$classq);
echo'</dl>';
}
}
?>
  </div> 
     </div> 
    </div> 
    </div> 
<div class="x5-tc-popover-mask"></div>
  <div class="dance-content"> 
   <form action="do.php?ac=malbumadd" method="post"> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">所属分类：</label> 
     <div class="inputOuter"  style="border: 0px solid #D7D7D7;"> 
<select class="select_normal" name="ClassID" id="ClassID" disabled> <option value="0">请选择→</option> 
<?php
$classsql="select CD_ID,CD_Name from " . tname('malbumclass') . " where CD_FatherID=0 and CD_IsHide=0 order by CD_TheOrder asc";
$result=$db->query($classsql);
//$classnum=$db->num_rows($result);
if($result) {
	while($class=$db->fetch_array($result)) {
			echo "<option value='" . $class['CD_ID'] . "' >&nbsp;|—" . $class['CD_Name'] . "</option>";
echo Get_Fclass_select($class['CD_ID'],'malbumclass');				
}
}
?></select><a onclick="shareready();" style="margin-left: 5px;padding: 4px;background: #1abc9c;color: #fff;border-radius: 4px;">点我选择分类</a>
     </div> 
    </div> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">专辑名称：</label> 
     <div class="inputOuter"> 
      <input type="text" name="SpecialName" class="inputstyle" placeholder="请认真填写" value="<?php echo SafeRequest("SpecialName", "get");?>"/> 
     </div> 
    </div> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">所属歌手：</label> 
     <div class="inputOuter"> 
      <input type="text" name="SingerID" class="inputstyle" placeholder="请认真填写" value="<?php echo SafeRequest("SingerID", "get");?>"/> 
     </div> 
    </div> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">发行公司：</label> 
     <div class="inputOuter"> 
      <input type="text" name="GongSi" class="inputstyle" placeholder="请用英文逗号隔开" value="<?php echo SafeRequest("GongSi", "get");?>"/> 
     </div> 
    </div> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">所属语言：</label> 
     <div class="inputOuter" style="border: 0px solid #D7D7D7;"> 
      <select style="width: 110px;" class="select_normal" name="YuYan" id="YuYan"> <option value="">选择所属语言</option> <option value="国语">国语</option> <option value="粤语">粤语</option> <option value="闽语">闽语</option> <option value="英语">英语</option> <option value="日语">日语</option> <option value="韩语">韩语</option> <option value="其它">其它</option> </select>
     </div> 
    </div> 
    <div class="uinArea"> 
     <label class="input-tips" style="width: 80px;">专辑简介：</label> 
     <div class="inputOuter" style="border: 0px solid #D7D7D7;"> 
      <textarea name="Intro" cols="30" rows="7" style="margin-bottom: 20px;"><?php echo SafeRequest("Intro", "get");?></textarea>
     </div> 
    </div> 
           <input type="hidden" name="Pic" id="Pic" value="<?php echo $CD_Pic?>" /> 
		   <input type="hidden" name="CD_ClassID" id="CD_ClassID" value="" />
    <div class="ptm-btn-row"> <button class="ptm-btn ptm-btn-primary ptm-btn-block">保存发布</button> </div>
   </form> 
  </div> 
<?php }?>
<?php }elseif($view=="song"){?>
  <script type="text/javascript">
function EditInfo(theform,sid) {
    var v = [];
    var checkCount = 0;
    var ids = document.getElementsByName("CD_ID[]");

    for(i=0; i<ids.length; i ++) {
        if (ids[i].checked) {
            checkCount ++;
            v.push(ids[i].value);
        }
    }
    if (checkCount == 0) {
        alert("您还没有选择");
        return false;

    } else {
        var idss=v.join(',')
        window.location=''+sid+'&songid='+idss;
    }
}	
    </script>  
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=malbum" class="tag-item"><span>已审专辑</span></a>
	<a href="index.php?ac=malbum&view=passed" class="tag-item"><span>未审专辑</span></a>
	<a href="index.php?ac=malbum&view=upload" class="tag-item"><span>创建专辑</span></a>
	<a href="index.php?ac=malbum&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div>
<?php
$malbum=$db->getrow("select CD_User,CD_Name,CD_ID from ".tname('malbum')." where CD_ID=".$classid);
if($malbum['CD_User']!==$CcTvAi_com_username){showmessage("专辑不存在", "index.php?ac=malbum", 0);}
$tmid=SafeRequest("tmid", "get");
if($tmid){
?> 
   <div class="malbum"> 
    <div class="head">
	<strong>移除音乐</strong>
<span style="float: right;">
<a href="index.php?ac=malbum&view=song&classid=<?php echo $classid?>">添加</a> 
<a style="background: rgba(47, 148, 97, 0.57);" href="index.php?ac=malbum&view=song&classid=<?php echo $classid?>&tmid=2">移除</a>
</span>
	</div> 
  <div style="padding: 10px;line-height: 25px;">
  <p>已加入该专辑的歌曲</p>
  <p><?php echo $malbum['CD_Name']; ?></p>
	</div>
   </div> 
  <div class="song-list"> 
<form class="J_ajaxForm" method="get" name="formb"> 
  <ul>
<?php

$djsql="select CD_ID,CD_Name from " . tname('dj') . " where CD_SpecialID=" . $classid . " and CD_Deleted=0 order by CD_AddTime desc";
$Arr=getuserpage($djsql, 30); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>暂时没有音乐</center>';
} else {
	if($result) {
		while($dj=$db->fetch_array($result)) {
	echo '<li> <a href="../play_p.php?id='.$dj['CD_ID'].'" target="songs"> <span class="songname">&middot;'.$dj['CD_Name'].'</span></a><i class="play"><input type="checkbox" class="J_check" name="CD_ID[]" value="'.$dj['CD_ID'].'" id="CD_ID"></i> </li>';
}
} 
}
?>
  </ul>
<div style="overflow: hidden;"><input name="button2" type="button" class="x5-btn x5-btn-warning" style="float: right;margin-top: 20px;margin-right: 15px;" value="移除专辑" onclick="EditInfo(this.form,'do.php?ac=malbumsongdel&malbumid=<?php echo $malbum['CD_ID']?>')" /></div>
  <div class="page"><?php echo $Arr[0];?></div>
</form>
  </div>
<?php }else{?>
   <div class="malbum"> 
    <div class="head">
	<strong>添加音乐</strong>
<span style="float: right;">
<a style="background: rgba(47, 148, 97, 0.57);" href="index.php?ac=malbum&view=song&classid=<?php echo $classid?>">添加</a> 
<a href="index.php?ac=malbum&view=song&classid=<?php echo $classid?>&tmid=2">移除</a>
</span>
	</div> 
  <div style="padding: 10px;line-height: 25px;">
  <p>您上传且未加入任何专辑的歌曲</p>
  <p><?php echo $malbum['CD_Name']; ?></p>
	</div>
   </div> 
  <div class="song-list"> 
<form class="J_ajaxForm" method="get" name="formb"> 
  <ul>
<?php

$djsql="select CD_ID,CD_Name from " . tname('dj') . " where CD_User='" . $CcTvAi_com_username . "' and CD_Deleted=0 and CD_SpecialID=0 order by CD_AddTime desc";
$Arr=getuserpage($djsql, 30); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>暂时没有音乐</center>';
} else {
	if($result) {
		while($dj=$db->fetch_array($result)) {
	echo '<li> <a href="../play_p.php?id='.$dj['CD_ID'].'" target="songs"> <span class="songname">&middot;'.$dj['CD_Name'].'</span></a><i class="play"><input type="checkbox" class="J_check" name="CD_ID[]" value="'.$dj['CD_ID'].'" id="CD_ID"></i> </li>';
}
} 
}
?>
  </ul>
<div style="overflow: hidden;"><input name="button2" type="button" class="x5-btn x5-btn-warning" style="float: right;margin-top: 20px;margin-right: 15px;" value="添加进专辑" onclick="EditInfo(this.form,'do.php?ac=malbumsong&malbumid=<?php echo $malbum['CD_ID']?>')" /></div>
  <div class="page"><?php echo $Arr[0];?></div>
</form>
  </div>
<?php }?>
<?php }elseif($view=="help"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=malbum" class="tag-item"><span>已审专辑</span></a>
	<a href="index.php?ac=malbum&view=passed" class="tag-item"><span>未审专辑</span></a>
	<a href="index.php?ac=malbum&view=upload" class="tag-item"><span>创建专辑</span></a>
	<a href="index.php?ac=malbum&view=help" class="on tag-item"><span>帮助</span></a>
    </div>  	
   </div>  
   <div class="malbum"> 
    <div class="head"><strong>帮助说明</strong></div> 
  <div style="padding: 10px;line-height: 25px;">
  <p>禁止上传违法图片，您上传的每张图片都会审核，一旦发现将封号处理，谢谢合作！</p>
  <p>封面图片格式：<?php echo cd_uppictype?></p>
  <p>封面图片大小：<?php echo cd_uppicsize?>MB</p>
  <p>审核时间：24小时内</p>
	</div>
   </div> 
<?php }?>