<?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" /> 
<link type="text/css" rel="stylesheet" href="css/up.css" /> 
<?php if($view==""){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pic" class="on tag-item"><span>全部照片</span></a>
	<a href="index.php?ac=pic&view=up" class="tag-item"><span>上传照片</span></a>
	<a href="index.php?ac=pic&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div> 
<div class="pic-up">
<div class="head"><strong>全部照片</strong></div>
 </div>
<script src="js/jquery.js" type="text/javascript"></script>
<style>body{ background-color: #f2f2f2;}</style>
  <div class="wrapper"> 
   <ul class="wall"> 
<?php
$query="select cd_url,cd_id,cd_hits,cd_addtime from " . tname('pic') . " where cd_uid='".$CcTvAi_com_userid."' order by cd_theorder desc";
$Arr=getuserpage($query, 20); 
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<center>No.album</center>';
} else {
	if($result) {
		while($pic=$db->fetch_array($result)) {
		echo '<li class="article"><a href="../singer/index.php?ac=album&id='.$CcTvAi_com_userid.'&iid='.$pic['cd_id'].'"><img src="' . getalbumthumb($pic['cd_url'], 2) . '" /><p>'.date('Y-m-d',$pic['cd_addtime']).'</p><small>'.$pic['cd_hits'].'</small></a></li>';
}
} 
}
?>
   </ul> 
  </div> 
  	<div class="pic-page"><?php echo $Arr[0];?></div>
  <script src="js/jaliswall.js" type="text/javascript"></script> 
  <script type="text/javascript">$(function(){$('.wall').jaliswall({ item: '.article' });});</script> 
<?php }elseif($view=="up"){?>
  <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=pic");
        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 {
			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="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pic" class="tag-item"><span>全部照片</span></a>
	<a href="index.php?ac=pic&view=up" class="on tag-item"><span>上传照片</span></a>
	<a href="index.php?ac=pic&view=help" class="tag-item"><span>帮助</span></a>
    </div>  	
   </div> 
<div class="pic-up">
<div class="head"><strong>上传照片</strong></div>
 <div style="padding: 10px;line-height: 25px;">
 <p>请选择您手机上的<?php echo cd_uppictype?>照片文件</p>
 <p>单个文件限制：<?php echo cd_uppicsize?>MB以内</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=pic">
			<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 }elseif($view=="help"){?>
   <div class="tag-list"> 
    <div class="tag-section">
	<a href="index.php?ac=pic" class="tag-item"><span>全部照片</span></a>
	<a href="index.php?ac=pic&view=up" class="tag-item"><span>上传照片</span></a>
	<a href="index.php?ac=pic&view=help" class="on tag-item"><span>帮助</span></a>
    </div>  	
   </div> 
<div class="pic-up">
<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>上传照片：金币+<?php echo cd_useruppicpoints?> 经验+<?php echo cd_useruppicrank?> 每天上限<?php echo cd_useruppicceiling?></p>
  <p>删除照片：金币-<?php echo cd_userdeletepicpoints?> 经验-<?php echo cd_userdeletepicrank?></p>
  <p>审核时间：24小时内</p>
  </div>
 </div>
<?php }?>