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

//删除评论
if($_GET['order'] == "del"){
	$id = $_GET['id'];
	$query = mysql_query("delete from {$total_pr}img_comment where id='".$id."'");
	if($query){
		echo '<script type="text/javascript">alert("评论删除成功！");</script>';
    }
}

if($_GET['order'] == "see"){
	$id = $_GET['id'];
}

if($_GET['order'] == "usersee"){
	$id = $_GET['id'];
	mysql_query("update {$total_pr}img_comment set status='1' 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" />
<link type="text/css" rel="stylesheet" href="css/jquery.ui.datepicker.css" />
<link type="text/css" rel="stylesheet" href="css/jquery.ui.theme.css" />
<script type="text/javascript" language="javascript" src="js/jquery-1.5.1.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.ui.datepicker-zh-CN.js"></script>
<title>查看图片评论</title>
<script type="text/javascript">
   //删除文章
   function delart(id){
	   if(confirm("您真的要删除这篇文章吗？") == true){
		   window.location.href = 'show_art.php?web=del&id='+id;
	   }
   }
   
   //跳转至博文评论页面
   function com(id){
	   window.open("art_com.php?order=com&id="+id+"","com","left=400,top=200,width=500,height=300");
   }
   
   //删除评论
   function del(id){
	   if(confirm("您真的要删除此评论吗？") == true){
		   window.location.href = "see_pic_com.php?order=del&id="+id+"";
	   }
   }
</script>
</head>

<body>
<div id="wrap">
<!-------------头部开始-------------->
   <div id="header">
	 <?php
      include "include/top.php";
      ?>
   </div>
<!-------------头部结束-------------->
<!-------------主体部分开始----------->
   <div id="content">
<!-----左侧边栏开始----->
     <div id="left">
	 <?php
      include "include/left.php";
     ?>
     </div>
<!-----左侧边栏结束----->
<!-----右部分内容开始----->
     <div id="right">
       <div class="see_comment">
         <div class="title">
           <?php
		     $sql = mysql_query("select tname from {$total_pr}picture where id='".$id."'");
			 while($row3 = mysql_fetch_assoc($sql)){
				 $title = $row3['tname'];
			 }
		   ?>
           <h2>对图片<span class="ti"><?=$title; ?></span>的评论</h2>
         </div>
         <div class="con">
		   <?php
            $sql = mysql_query("select * from {$total_pr}img_comment where img_id='".$id."'");
            $total = mysql_num_rows($sql);
            $pagesize = 4;
            
			$url = parse_url($_SERVER['REQUEST_URI']);
			$get = substr($url['query'],0,13).$id;
            $page = new page($total,$pagesize,"篇评论",$get);
           
            $query = mysql_query("select * from {$total_pr}img_comment where img_id='".$id."' order by id desc {$page->limit}");
            $row = mysql_fetch_assoc($query);
            if($row == false){
                echo '<div class="no">该图片还没有被评论过( ˇ_ˇ )....</div>';
            }
            else{
             do{
           ?>
           <div class="seecom">
              <div class="user">
              <?php
			   //查询user表信息
				$querys = mysql_query("select * from {$total_pr}user where id='".$row['comid']."'");
				while($rows = mysql_fetch_assoc($querys)){
			   ?>
                <div class="img"><img src="<?=$rows['userpic']; ?>" /></div>
                <span class="u">昵称：<?=$rows['username']; ?></span><br />
                <span class="u">等级：<?=$rows['grade']; ?></span>
                <?php
				}
				?>
              </div>
              <div class="big">
                <?=$row['content']; ?>
              </div>
              <div class="small">
                <span class="seedate">评论日期：<?=$row['date']; ?></span>
                <?php
				if($_SESSION['user_id'] == $_SESSION['con_id']){
                  echo '<span class="del"><a href="javascript:del('.$row['id'].');">删除</a></span>';
				}
				?>
              </div>
           </div>
           <?php
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		   ?>
         </div>
       </div>
       <div class="page">
              <?php echo $page->fpage() ?>
       </div>
     </div>
<!-----右部分内容结束----->
   </div>
<!-------------主体部分结束----------->
<!-------------尾部内容开始----------->
   <div id="footer">
	  <?php
       include "include/bottom.php";
      ?>
   </div>
<!-------------尾部内容结束----------->
</div>
</body>
</html>