<?php 
error_reporting(0);
if(!$userlogined==true){exit("<script type=\"text/javascript\">location.href='".cd_webpath."user/login.php?login_referer=".cd_webpath."user/".rewrite_url('space.php?do=pic')."';</script>");}
?>
  <div class="user"> 
   <div class="user_center"> 
<?php
include_once('source/space_menu.php');
?>
<?php if($view==""){?>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="me"> <a class="on" href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
        <li class="friend"> <a href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
       </ul> 
       <div class="action"> 
        <a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
       </div> 
      </div> 
      <div class="big_list"> 
        <li> <a  class="current" href="<?php echo rewrite_url('space.php?do=pic');?>">照片列表</a> </li> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic&view=imageSpaceSort');?>">首页显示</a> </li> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic&view=imageSort');?>">重新排序</a> </li> 
      </div> 
      <div id="imageList" class="minHeight500"> 
       <form id="list"> 
<?php
global $db;
$a=0;
$sql="select * from " . tname('pic') . " where cd_uid='" . $CcTvAi_com_userid . "' order by cd_theorder desc";
$Arr=getuserpage($sql, 35); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<div class="nothing">暂时还没有照片啊！</div>';
} else {
		if($result) {
				echo '<div class="image_me">';
				echo '<ul>';
				while($row=$db->fetch_array($result)) {
						$a=$a+1;
						//$user = $db->getrow("select cd_nicheng from ".tname('user')." where cd_id='".$row['cd_uid']."'");
						echo '<li>';
						echo '<div class="pic" id="row' . $row['cd_id'] . '">';
						echo '<a href="' . cd_webpath .cd_webmlsinger. '/index.php?ac=album&id=' . $row['cd_uid'] . '&day=' . $row['cd_id'] . '" name="w' . $row['cd_id'] . '" target="_blank"><img class="avatar" src="' . getalbumthumb($row['cd_url'], 1) . '" height="80" width="80" onerror="$call(function(){libs.imageError(this);}, this)"/></a>';
						echo '</div>';
						echo '<div class="option">';
						echo '<span><input id="validate' . $row['cd_id'] . '" type="checkbox" value="select" pid="' . $row['cd_id'] . '" /></span>';
						echo '<label for="validate' . $row['cd_id'] . '">选择</label>';
						echo '<label style="color:#FF0000;" class="delete" for="delete' . $row['cd_id'] . '" pid="' . $row['cd_id'] . '" uid="' . $row['cd_uid'] . '" title="删除此照片">删除</label>';
						echo '</div>';
						echo '</li>';
				}
				echo '</ul>';
				echo '</div>';
		}
}
?>
<?php if($num>0){?>
        <div class="page"> 
         <span class="button2-main"><span><button id="selectAll" type="button">全选</button></span></span>
         <span class="button2-main"><span><button id="selectOther" type="button">反选</button></span></span>
         <span class="button-main"><span><button id="delButton" type="button">批量删除</button></span></span>
         <div class="pages"> 
<?php echo $Arr[0]; ?><input type="text" maxlength="5" onkeydown="function c(event,val){e = event ? event :(window.event ? window.event : null);if(e.keyCode==13){val = parseInt(val);val=isNaN(val)||(val<=0)?1:val;window.location.href=zone_domain+'space.php?do=pic&pages='+val;return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/>
         </div> 
        </div> 
<?php } ?>
       </form> 
      </div> 
     </div> 
    </div> 
<?php }elseif($view=="imageSpaceSort"){?>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="me"> <a class="on" href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
        <li class="friend"> <a href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
       </ul> 
       <div class="action"> 
        <a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
       </div> 
      </div> 
      <div class="big_list"> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic');?>">照片列表</a> </li> 
        <li> <a  class="current" href="<?php echo rewrite_url('space.php?do=pic&view=imageSpaceSort');?>">首页显示</a> </li> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic&view=imageSort');?>">重新排序</a> </li> 
      </div> 
      <div class="minHeight500"> 
       <div class="imageSort"> 
<?php
global $db;
$a=0;
$sql="select * from " . tname('pic') . " where cd_uid='" . $CcTvAi_com_userid . "' order by cd_weborder desc";
$Arr=getuserpage($sql, 70); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<div class="nothing">还没有上传照片啊，快上传您喜欢的照片吧！</div>';
} else {
		if($result) {
				echo '<div id="imageSort1" class="sortable">';
				while($row=$db->fetch_array($result)) {
						$a=$a+1;
						echo '<img id="' . $row['cd_id'] . '" class="imgfile" src="' . getalbumthumb($row['cd_url'], 1) . '" uid="' . $row['cd_uid'] . '" height="80" width="80" onerror="$call(function(){libs.imageError(this);}, this)"/>';
				}
				echo '</div>';
				echo '<div class="space_sort_utton">';
				echo '<span class="button-main">';
				echo '<span><button id="saveButton">保存结果</button></span>';
				echo '</span>';
				echo '</div>';
				echo '<div id="imageSort2" class="sortable"></div>';
		}
}
?>
       </div> 
      </div> 
     </div> 
    </div> 
<?php }elseif($view=="imageSort"){?>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="me"> <a class="on" href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
        <li class="friend"> <a href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
       </ul> 
       <div class="action"> 
        <a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
       </div> 
      </div> 
      <div class="big_list"> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic');?>">照片列表</a> </li> 
        <li> <a href="<?php echo rewrite_url('space.php?do=pic&view=imageSpaceSort');?>">首页显示</a> </li> 
        <li> <a class="current" href="<?php echo rewrite_url('space.php?do=pic&view=imageSort');?>">重新排序</a> </li> 
      </div> 
      <div class="minHeight500"> 
       <div class="imageSort"> 
<?php
global $db;
$a=0;
$sql="select * from " . tname('pic') . " where cd_uid='" . $CcTvAi_com_userid . "' order by cd_theorder desc";
$Arr=getuserpage($sql, 70); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<div class="nothing">还没有上传照片啊，快上传您喜欢的照片吧！</div>';
} else {
		if($result) {
				echo '<div id="imageSort" class="sortable">';
				while($row=$db->fetch_array($result)) {
						$a=$a+1;
						echo '<img id="' . $row['cd_id'] . '" class="avatar" src="' . getalbumthumb($row['cd_url'], 1) . '" uid="' . $row['cd_uid'] . '" height="80" width="80" onerror="$call(function(){libs.imageError(this);}, this)"/>';
				}
				echo '</div>';
				echo '<div class="sort_button">';
				echo '<span class="button-main">';
				echo '<span><button id="saveButton">保存结果</button></span>';
				echo '</span>';
				echo '</div>';
		}
}
?>
        </div>
       </div> 
      </div> 
     </div> 
<?php }elseif($view=="praise"){?>
<div class="user_main"> 
<div class="uMain_content"> 
<div class="main_nav"> 
<ul> 
<li class="me"> <a href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
<li class="friend"> <a href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
</ul> 
<div class="action"> 
<a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
</div> 
</div> 
<div class="main">
<div id="tooltip" class="refresh">
</div>
</div>
<?php }elseif($view=="following"){?>
  <div class="user_main"> 
   <div class="uMain_content"> 
    <div class="main_nav"> 
     <ul> 
      <li class="me"> <a href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
      <li class="friend"> <a class="on" href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
     </ul> 
     <div class="action">  
      <a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
     </div> 
    </div> 
    <div class="main"> 
     <div id="tooltip" class="refresh"> 
     </div> 
    </div> 
<?php
global $db;
$a=0;
$sql="select * from " . tname('pic') . " where cd_uid in(" . GetFolloWing($CcTvAi_com_userid, 0) . ") order by cd_addtime desc";
$Arr=getuserpage($sql, 100); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
$lpids="";
if($num==0) {
		echo '<div class="nothing">您关注的人暂时还没有照片啊！</div>';
} else {
		if($result) {
				echo '<ul id="imageList" class="image_following"></ul>';
				echo '<div id="imgLoading" class="image_loading"></div>';
				echo '<div id="imgPages" class="album_button page" style="display:none;">';
				while($row=$db->fetch_array($result)) {
						$a=$a+1;
						$user=$db->getrow("select cd_nicheng from " . tname('user') . " where cd_id='" . $row['cd_uid'] . "'");
						$lpids=$lpids . "{'pid': " . $row['cd_id'] . ",'src':'" . getalbumthumb($row['cd_url'], 2) . "','create_time':'" . datetime(date('Y-m-d', $row['cd_addtime'])) . "','uid':" . $row['cd_uid'] . ",'praiseNum':" . $row['cd_praisenum'] . ",'replyNum':" . $row['cd_replynum'] . ",'width':" . $row['cd_width'] . ",'height':" . $row['cd_height'] . ",'avatar':'" . linkuserphoto($row['cd_uid'], 48) . "','nickname':'" . $user['cd_nicheng'] . "'},";
				}
				$lpids=$lpids . ']';
				$lpids=ReplaceStr($lpids, ",]", "");
				if($num>0) {
?>
     <div class="pages"> 
<?php
						echo $Arr[0];
?><input type="text" maxlength="5" onkeydown="function c(event,val){e = event ? event :(window.event ? window.event : null);if(e.keyCode==13){val = parseInt(val);val=isNaN(val)||(val<=0)?1:val;window.location.href=zone_domain+'space.php?do=pic&view=following&pages='+val;return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/>
     </div> 
<?php
				}
				echo '</div>';
		}
}
?>
    </div>
   </div> 
<?php }elseif($view=="add"){?>
<script type="text/javascript">
var _userid = '<?php echo $CcTvAi_com_userid; ?>'; _username = '<?php echo base64_encode($CcTvAi_com_userid); ?>';
</script>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="me"> <a href="<?php echo rewrite_url('space.php?do=pic');?>">我的照片</a> </li> 
        <li class="friend"> <a href="<?php echo rewrite_url('space.php?do=pic&view=following');?>">好友的照片</a> </li> 
       </ul> 
       <div class="action"> 
        <a href="<?php echo rewrite_url('space.php?do=pic&view=add');?>">上传照片</a> 
       </div> 
      </div> 
      <div class="main"> 
       <div id="tooltip" class="refresh"> 
       </div> 
      </div> 
      <div class="minHeight500"> 
       <div class="imageUp_Title">上传照片</div>
       <div class="imageUpNote">禁止上传违法图片，您上传的每张图片都会审核，一旦发现将封号处理，谢谢合作！</div>
       <div class="imageUp_uploadWrap">
        <div id="upButton" class="btn-upload">
         <input id="file_upload" width="100" type="file" height="32" name="file_upload" style="display: none;">
        </div>
        <div id="uploadfileQueue" class="uploadifyQueue"></div>
        <div id="uploadInfo">请选择您要上传的图片，支持批量上传！</div>
        <div class="btn-group">
         <a href="javascript:$('#file_upload').uploadify('upload','*')" class="btn">上传</a>
         <a href="javascript:$('#file_upload').uploadify('cancel','*')" class="btn">取消上传</a>
         <a href="javascript:$('#file_upload').uploadify('stop','*')" class="btn">暂停上传</a>
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 			
<?php }?>
   </div> 
  </div> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/core.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/card.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/dialog.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.plugins.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/common.js"></script>
  <script type="text/javascript">listenMsg.start();nav.init();nav.userMenu();</script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/album.js"></script>
<?php if($view==""){?>
  <script type="text/javascript">nav.helpNoticeInit();albumLib.imagesBatchDelInit(); albumLib.imageDelInit();</script>
<?php }elseif($view=="imageSpaceSort"){?>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/jquery/jquery.ui.custom.min.js"></script>
  <script type="text/javascript">nav.helpNoticeInit();albumLib.imageSpaceSortInit();</script>
<?php }elseif($view=="imageSort"){?>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/jquery/jquery.ui.custom.min.js"></script>
  <script type="text/javascript">nav.helpNoticeInit();albumLib.imageSortInit();</script>
<?php }elseif($view=="praise"){?>
<?php }elseif($view=="following"){?>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.masonry.min.js"></script>
  <script type="text/javascript">
nav.helpNoticeInit();
var imgDatas = [<?php echo $lpids; ?>];
imgLoaded.init('#imageList', imgDatas, 1);
libs.spaceInit();
  </script>
<?php }elseif($view=="add"){?>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/jquery/uploadify/jquery.uploadify.js"></script>
  <script type="text/javascript">nav.helpNoticeInit();albumLib.imageAddInit();</script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/jquery/uploadify/swfobject.js"></script>
<?php }?>
<?php include_once('source/space_footer.php');?>
  </body>
</html>