<?php
session_start();
include "conn/config.php";
include "include/class/page.class.php";

//删除图片
if($_GET['order'] == "del"){
	$id = $_GET['id'];
	if($id){
		$query = mysql_query("select tname from {$total_pr}picture where id='".$id."'");
		while($row = mysql_fetch_assoc($query)){
			$name = $row['tname'];
		}
		//删除文件夹中图片
		if(is_file('images/uploads/'.$name)){
		   @unlink('images/uploads/'.$name);
		}
		
		//删除数据库表中资料
	    $query = mysql_query("delete from {$total_pr}picture where id='".$id."'");
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/picture.js"></script>
<title>我的相册</title>
</head>

<body>
<div id="wrap">
<!-------------头部开始-------------->
   <div id="header">
	 <?php
      include "include/top.php";
      ?>
   </div>
<!-------------头部结束-------------->
<!-------------主体部分开始----------->
   <div id="content">
<!-----左侧边栏开始----->
     <div id="left">
	 <?php
      include "include/left2.php";
     ?>
     </div>
<!-----左侧边栏结束----->
<!-----右部分内容开始----->
     <div id="right">
       <div class="picture">
          <div class="title">
              <h2>我的相册<?php if($_SESSION['user_id'] == $_SESSION['con_id']){echo '<span class="pic_upload"><a href="javascript:pic_upload()">上传相片</a></span>';} ?></h2>
          </div>
          <div id="picture_con" class="picture_con">
             <?php
			  $sql = mysql_query("select * from {$total_pr}picture where userid='".$_SESSION['con_id']."'");
			  $total = mysql_num_rows($sql);
			  $pagesize = 18;
			  $config = "张相片";
			  
			  $page = new page($total,$pagesize,$config);
			  
			  $sql = "select * from {$total_pr}picture where userid='".$_SESSION['con_id']."' order by id desc {$page->limit} ";
			  $result = mysql_query($sql);
			  $rows = mysql_fetch_array($result);
			  $i = 0;
					if($rows == false){
					  if($_SESSION['user_id'] == $_SESSION['con_id']){
						 echo '<div class="no_pic">您还没有<a href="javascript:pic_upload()">上传</a>任何相片</div>'; 
					  }
					  else{
						 echo '<div class="no_pic">他还没有上传任何相片</div>';  
					  }
					}
					else{
					  do{
			 ?>
             <div class="pic_mess"  onmousemove="xhid(<?=$i++ ?>)" onmouseout="hid()">
                 <img src="<?php echo $rows['file'] ?>" /><br />
                     <div class="name">
					 <?php 
					    echo substr($rows['tname'],0,8);
						if(strlen($rows['tname']) > 8 ){ 
						  echo "...";
						}
					 ?>
                     </div>
                     <span class="name_w_no" ><a href="picture_show.php?id=<?=$rows['id'] ?>">查看</a>&nbsp;&nbsp;&nbsp;
                     <?php
                     if($_SESSION['user_id'] == $_SESSION['con_id']){
                        echo "<a href='javascript:delconfirm(".$rows['id'].")'>删除</a>";
                     }
					 else{
						echo "<a href='javascript:comdump(".$rows['id'].")'>评论</a>";
					 }
                     ?>
                   </span>
             </div>
             <?php
					}
					while($rows = mysql_fetch_array($result));
			  }
			  ?>
          </div>
          <div class="page">
          <?php echo $page->fpage() ?>
          </div>
       </div>
     </div>
<!-----右部分内容结束----->
   </div>
<!-------------主体部分结束----------->
<!-------------尾部内容开始----------->
   <div id="footer">
	  <?php
       include "include/bottom.php";
      ?>
   </div>
<!-------------尾部内容结束----------->
</div>
</body>
</html>