<?php
session_start();
include "conn/config.php";
include "include/class/page.class.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" />
<title>我的博文</title>
<script type="text/javascript">
   //全选/全不选
   function all_che(al){
	   var li = document.getElementsByName("art_che");
	   if(al.checked){
		   for(var i=0;i<li.length;i++){
			   li[i].checked = true;
		   }
	   }
	   else{
		   for(var i=0;i<li.length;i++){
			   li[i].checked = false;
		   }
	   }	   
   }
   
   //判断是否全选
   function art_che(){
	   var a = document.getElementsByName("all_che").item(0);
	   var l = document.getElementsByName("art_che");
	   var lcount = 0;
	   for(var i=0;i<l.length;i++){
		   if(l[i].checked){
			   lcount++;
		   }
	   } 
	   
	   if(lcount == l.length){
		   a.checked = true;
	   }  
	   else{
		   a.checked = false;   
	   }
   }
</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="message">
         <div class="title">
           <h2>文章列表<span class="art_upload"><?php if($_SESSION['user_id']==$_SESSION['con_id']){echo "<a href='ar_upload.php'>发表文章</a>";}?></span></h2>
         </div>
         <div class="art_con_b">
         <ul>
         <?php
          $sql = mysql_query("select * from {$total_pr}article where userid='".$_SESSION['con_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          
          $page = new page($total,$pagesize);
          
          $sql = "select * from {$total_pr}article where userid='".$_SESSION['con_id']."' order by id desc {$page->limit} ";
          $result = mysql_query($sql);
          $rows = mysql_fetch_array($result);
		  if($rows == false){
			  if($_SESSION['user_id'] == $_SESSION['con_id']){
			       echo '<div class="art_no_art">您还没有<a href="art_upload.php">发表</a>任何文章</div>'; 
			  }
			  else{
				   echo '<div class="art_no_art">他还没有发表任何文章</div>'; 
			  }
		  }
		  else{
			do{
         ?>
           <li><input class="che_art" type="checkbox" name="art_che" onclick="art_che()" /><a href="art_show.php?id=<?php echo $rows[id] ?>"><?=$rows[title] ?></a>&nbsp;&nbsp;<span class="date">[<?=date("Y-m-d H:i:s",$rows['time']) ?>]</span></li>
           <?php
		  }
		  while($rows = mysql_fetch_array($result));
		  }
		  ?>
         </ul>
         </div>
         <div class="che_all">
          <span class="a_all"><input type="checkbox" name="all_che" onclick="all_che(this)" />全选/全不选</span>
          <span class="a_del"><a href="">删除所选</a></span>
       </div>
       </div>
       <div class="page">
        <?php echo $page->fpage() ?>
       </div>
     </div>
<!-----左侧边栏结束----->
   </div>
<!-------------主体部分结束----------->
<!-------------尾部内容开始----------->
   <div id="footer">
	  <?php
       include "include/bottom.php";
      ?>
   </div>
<!-------------尾部内容结束----------->
</div>
</body>
</html>