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

//删除博文
if($_GET['web'] == "del"){
	$id = $_GET['id'];
	$sql = "delete from {$total_pr}article where id='".$id."'";
	$re = mysql_query($sql);
	//删除成功后页面跳转刷新
	if($re){
		header("location:article.php");
	}
}
?>
<!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 = 'art_show.php?web=del&id='+id;
	   }
   }
   
   //跳转至博文评论页面
   function com(id){
	   window.open("open/art_com.php?order=com&id="+id+"","com","left=400,top=200,width=500,height=300");
   }
</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="show">
           <?php
		   $id = $_GET['id'];
		   if($id){
			 //增加评论次数
			 $times = mysql_query("update {$total_pr}article set times=times+1 where id='".$id."'");
			 if($times){
			   //查询评论次数
			   $query = mysql_query("select id from {$total_pr}art_comment where art_id='".$id."'");
               $num = mysql_num_rows($query);
			   //查询数据库
			   $query = mysql_query("select * from {$total_pr}article where id='".$id."'");
			   while($row = mysql_fetch_assoc($query)){
		   ?>
            <h2><?=$row['title'] ?> <span class="date"><?=$row['atime'] ?></span></h2>
            <div class="show_article">
               <div class="show_article_con">
                <?=$row['content'];?>
               </div>
               <div class="show_article_show1">
                 <div class="read_num">阅读（<?=$row['times'] ?>）&nbsp;|</div>
                 <div class="com_num">&nbsp;评论（<?=$num ?>）</div>
               </div>
               <div class="show_article_show">
                 <?php
                  if($_SESSION['user_id'] != $_SESSION['con_id']){
                    echo '<div class="say_com"><a href="javascript:com('.$row[id].')">评论博文</a>&nbsp;|</div>';
                  }
                 ?>
                 <div class="see_com"><a href="see_art_com?order=see&id=<?=$row['id'] ?>">查看评论</a></div>
                 <?php
                  if($_SESSION['user_id'] == $_SESSION['con_id']){
                    echo "<div class='del'>&nbsp;|&nbsp;<a href='javascript:delart(".$row['id'].")'>删除博文</a></div>";
                  }
                  ?>
               </div>
            </div>
            <?php
		   }
		 }
	   }
		   ?>
         </div>
     </div>
<!-----左侧边栏结束----->
   </div>
<!-------------主体部分结束----------->
<!-------------尾部内容开始----------->
   <div id="footer">
	  <?php
       include "include/bottom.php";
      ?>
   </div>
<!-------------尾部内容结束----------->
</div>
</body>
</html>