<?php
session_start();
include "conn/config.php";
include "include/class/page.class.php";
//单个删除
if($_GET['what'] == "del"){
  $get = $_GET['order'];
  //判断哪个表
  switch($get){
	  case "paper":
		   $name = "纸条信息";
		   $table = "paper";
		   $id = $_GET['id'];
	  break;
	  case "hello":
		   $name = "招呼信息";
		   $table = "hello";
		   $id = $_GET['id'];
	  break;
	  case "mess";
		   $name = "留言信息";
		   $table = "le_mess";
		   $id = $_GET['id'];
	  break;
	  case "img";
		   $name = "图片评论信息";
		   $table = "img_comment";
		   $id = $_GET['id'];
	  break;
	  case "art";
		   $name = "文章评论信息";
		   $table = "art_comment";
		   $id = $_GET['id'];
	  break;
  }
  
  $query = mysql_query("delete from {$total_pr}{$table} where id='".$id."'");
  if($query){
	  echo '<script type="text/javascript">alert("删除此'.$name.'成功！");history.back();</script>';
  }
}
if($_GET['order']){
 $type = $_GET['type'];
 $idAll = explode("*",$_GET['con']);
 $idAll_len = count($idAll);

  //全部删除
  if($_GET['order'] == "delAll"){   
	 switch($type){
		 case "mess":
			 $type = "le_mess";
		 break;
		 case "img":
			 $type = "img_comment";
		 break;
		 case "art":
			 $type = "art_comment";
		 break;
	 }
	 
	 $count = 0;
	 for($i=0;$i<$idAll_len;$i++){
		 mysql_query("delete from {$total_pr}{$type} where id='".$idAll[$i]."'");
		 $count++;
	 }
	 
	 if($count == $idAll_len){
		 echo '<script type="text/javascript">alert("删除选定的'.$idAll_len.'条信息成功！");history.back();</script>';
	 }
  }
  //锁住用户
  elseif($_GET['order'] == "lockAll"){
	  $count = 0;
	  for($i=0;$i<$idAll_len;$i++){
		  mysql_query("update {$total_pr}user set rank='000' where id='".$idAll[$i]."'");
		  $count++;
	  }
	  
	  if($count == $idAll_len){
		 echo '<script type="text/javascript">alert("锁住选定的'.$idAll_len.'个用户成功！");history.back();</script>';
	 }
  }
  //恢复用户权限
  elseif($_GET['order'] == "normalAll"){
	  $count = 0;
	  for($i=0;$i<$idAll_len;$i++){
		  mysql_query("update {$total_pr}user set rank='111' where id='".$idAll[$i]."'");
	      $count++;
	  }
	  
	  if($count == $idAll_len){
		 echo '<script type="text/javascript">alert("恢复选定的'.$idAll_len.'个用户权限成功！");history.back();</script>';
	 }
  }
  //将用户设为管理员
  elseif($_GET['order'] == "manageAll"){
	  $count = 0;
	  for($i=0;$i<$idAll_len;$i++){
		  mysql_query("update {$total_pr}user set rank='333' where id='".$idAll[$i]."'");
	      $count++;
	  }
	  
	  if($count == $idAll_len){
		 echo '<script type="text/javascript">alert("将选定的'.$idAll_len.'个用户设为管理员成功！");history.back();</script>';
	 }
  }
}
?>
<!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>
<script type="text/javascript" language="javascript" src="js/with.js"></script>
<title>与我相关</title>
</head>

<body>
<div id="wrap">
<!-------------头部开始-------------->
   <div id="header">
	 <?php
      include "include/top.php";
      ?>
   </div>
<!-------------头部结束-------------->
<!-------------主体部分开始----------->
   <div id="content">
<!-----左侧边栏in开始----->
     <div id="left">
	 <?php
      include "include/left_me.php";
     ?>
     </div>
<!-----左侧边栏in结束----->
<!-----有部分内容开始----->
    <div id="right">
     <div id="news">
        <div class="dis_m" onclick="set(0);">扔纸条</div>
        <div class="normal_m" onclick="set(1);">打招呼</div>
        <div class="normal_m" onclick="set(2);">留言</div>
        <div class="normal_m" onclick="set(3);">图片评论</div>
        <div class="normal_m" onclick="set(4);">文章评论</div>
        <div class="normal_m" onclick="set(5);">个人资料</div>
        <?php 
		 $q = mysql_query("select * from {$total_pr}user where id='".$_SESSION['user_id']."'");
		 while($rows = mysql_fetch_assoc($q)){
			 $rank = $rows['rank'];
		 }
		 if($rank == '333'){
          echo '<div class="normal_m" onclick="set(6);">用户管理</div>';
		 }
		?>
     </div>
     <div id="con">
        <div class="dis_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}paper where receiveid='".$_SESSION['user_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"条消息","tab0");
		  
		  $query = mysql_query("select * from {$total_pr}paper where receiveid='".$_SESSION['user_id']."' order by id desc {$page->limit}");
		  $row = mysql_fetch_assoc($query);
		  if($row == false){
			  echo '<span class="no">还没有人向您扔纸条呢( ˇ_ˇ )！</span>';
		  }
		  else{
		   do{
			   if($row['status'] == 0){
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="paper" onclick="checkbox(0,'paper')" /><img src="images/see_not.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>给您扔纸条了，快去<a class="see_con" href="javascript:opinfo('paper',<?=$row['id'] ?>,500,300,300,200)">查看</a>吧^_^<span class="date">日期:<?php echo $row['date']."safsdf".$ot_get; ?></span><span class="del"><a href="javascript:del('paper',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
			   else{
		  ?>
		    <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="paper" onclick="checkbox(0,'paper')" /><img src="images/see_yes.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>给您扔纸条了，快去<a class="see_con" href="javascript:opinfo('paper',<?=$row['id'] ?>,500,300,300,200)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('paper',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
		  <?php
			   }
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		  ?>
          </ul>
          <span class="but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(0,'paper')" />&nbsp;全选/取消全选</span>
            <a class="set_del" href="javascript:setDe('del','paper')">删除所选</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
        <div class="normal_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}hello where receiveid='".$_SESSION['user_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"条消息","tab1");
		  
		  $query = mysql_query("select * from {$total_pr}hello where receiveid='".$_SESSION['user_id']."' order by id desc {$page->limit}");
		  $row = mysql_fetch_assoc($query);
		  if($row == false){
			  echo '<span class="no">还没有人向您打招呼呢( ˇ_ˇ )！</span>';
		  }
		  else{
		   do{
			   if($row['status'] == 0){
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="hello" onclick="checkbox(1,'hello')" /><img src="images/see_not.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>向您打招呼了，快去<a class="see_con" href="javascript:opinfo('hello',<?=$row['id'] ?>,550,320,260,120)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('hello',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
			   else{
		  ?>
           <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="hello" onclick="checkbox(1,'hello')" /><img src="images/see_yes.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>向您打招呼了，快去<a class="see_con" href="javascript:opinfo('hello',<?=$row['id'] ?>,550,320,260,120)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('hello',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		  ?>
          </ul>
          <span class="but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(1,'hello')" />&nbsp;全选/取消全选</span>
            <a class="set_del" href="javascript:setDe('del','hello')">删除所选</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
        <div class="normal_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}le_mess where receiveid='".$_SESSION['user_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"条消息","tab2");
		  
		  $query = mysql_query("select * from {$total_pr}le_mess where receiveid='".$_SESSION['user_id']."' order by id desc {$page->limit}");
		  $row = mysql_fetch_assoc($query);
		  if($row == false){
			  echo '<span class="no">还没有人给您留言呢( ˇ_ˇ )！</span>';
		  }
		  else{
		   do{
			   if($row['status'] == 0){
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="mess" onclick="checkbox(2,'mess')" /><img src="images/see_not.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>给您留言了，快去<a class="see_con" href="javascript:opinfo('mess',<?=$row['id'] ?>,470,300,450,250)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('mess',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
			   else{
		  ?>
           <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="mess" onclick="checkbox(2,'mess')" /><img src="images/see_yes.gif" /><a class="name" href="index.php?id=<?=$row['sendid'] ?>"><?=$row['sendname'] ?></a>给您留言了，快去<a class="see_con" href="javascript:opinfo('mess',<?=$row['id'] ?>,470,300,450,250)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('mess',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
		  <?php
			   }
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		  ?>
          </ul>
          <span class="but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(2,'mess')" />&nbsp;全选/取消全选</span>
            <a class="set_del" href="javascript:setDe('del','mess')">删除所选</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
        <div class="normal_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}img_comment where receiveid='".$_SESSION['user_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"条消息","tab3");
		  
		  $query = mysql_query("select * from {$total_pr}img_comment where receiveid='".$_SESSION['user_id']."' order by id desc {$page->limit}");
		  $row = mysql_fetch_assoc($query);
		  if($row == false){
			  echo '<span class="no">还没有人评论您的图片呢( ˇ_ˇ )！</span>';
		  }
		  else{
		   do{
			   if($row['status'] == 0){
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="img" onclick="checkbox(3'img')" /><img src="images/see_not.gif" /><a class="name" href="index.php?id=<?=$row['comid'] ?>"><?=$row['comname'] ?></a>评论您的图片了，快去<a class="see_con" href="javascript:opas('img',<?=$row['id'] ?>)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('img',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
			   else{
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="img" onclick="checkbox(3,'img')" /><img src="images/see_yes.gif" /><a class="name" href="index.php?id=<?=$row['comid'] ?>"><?=$row['comname'] ?></a>评论您的图片了，快去<a class="see_con" href="javascript:opas('img',<?=$row['id'] ?>)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('img',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
		  <?php
			   }
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		  ?>
          </ul>
          <span class="but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(3,'img')" />&nbsp;全选/取消全选</span>
            <a class="set_del" href="javascript:setDe('del','img')">删除所选</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
        <div class="normal_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}art_comment where receiveid='".$_SESSION['user_id']."'");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"条消息","tab4");
		  
		  $query = mysql_query("select * from {$total_pr}art_comment where receiveid='".$_SESSION['user_id']."' order by id desc {$page->limit}");
		  $row = mysql_fetch_assoc($query);
		  if($row == false){
			  echo '<span class="no">还没有人评论您的文章呢( ˇ_ˇ )！</span>';
		  }
		  else{
		   do{
			   if($row['status'] == 0){
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="art" onclick="checkbox(4,'art')" /><img src="images/see_not.gif" /><a class="name" href="index.php?id=<?=$row['comid'] ?>"><?=$row['comname'] ?></a>评论您的文章了，快去<a class="see_con" href="javascript:opas('art',<?=$row['id'] ?>)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('art',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
          <?php
			   }
			   else{
		  ?>
            <li><input class="checkbox" type="checkbox" value="<?=$row['id'] ?>" name="art" onclick="checkbox(4,'art')" /><img src="images/see_yes.gif" /><a class="name" href="index.php?id=<?=$row['comid'] ?>"><?=$row['comname'] ?></a>评论您的文章了，快去<a class="see_con" href="javascript:opas('art',<?=$row['id'] ?>)">查看</a>吧^_^<span class="date">日期:<?=$row['date'] ?></span><span class="del"><a href="javascript:del('art',<?=$row['id'] ?>)"><img src="images/del.gif" /></a></span></li>
		  <?php
			   }
		   }
		   while($row = mysql_fetch_assoc($query));
		  }
		  ?>
          </ul>
          <span class="but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(4,'art')" />&nbsp;全选/取消全选</span>
            <a class="set_del" href="javascript:setDe('del','art')">删除所选</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
        <div class="normal_c">
           <?php
		     $query = mysql_query("select * from {$total_pr}user where id='".$_SESSION['user_id']."'");
			 while($rows = mysql_fetch_assoc($query)){
		   ?>
           <table border="0">
             <caption><h2>个人资料</h2></caption>
             <tr>
              <td class="one">用户昵称：</td>
              <td class="two"><?=$rows['username'] ?></td>
             </tr>
             <tr>
              <td class="one">邮箱地址：</td>
              <td class="two"><a href="http://<?=$rows['email'] ?>"><?=$rows['email'] ?></a></td>
             </tr>
             <tr>
              <td class="one">博客等级：</td>
              <td class="two"><?=$rows['grade'] ?></td>
             </tr>
             <tr>
              <td class="one">博客积分：</td>
              <td class="two"><?=$rows['point'] ?></td>
             </tr>
             <tr>
              <td class="one">访问次数：</td>
              <td class="two"><?=$rows['visitnum'] ?></td>
             </tr>
             <tr>
              <td class="one">关注人气：</td>
              <td class="two"><?=$rows['popularity'] ?></td>
             </tr>
             <tr>
              <td class="one">注册时间：</td>
              <td class="two"><?=$rows['time'] ?></td>
             </tr>
             <tr>
              <td class="one">用户头像：</td>
              <td class="two"><img src="<?=$rows['userpic'] ?>" /></td>
             </tr>
           </table>
           <?php
			 }
		   ?>
        </div>
        <div class="normal_c">
          <ul>
          <?php
		  $sql = mysql_query("select * from {$total_pr}user order by id desc");
          $total = mysql_num_rows($sql);
          $pagesize = 10;
          $page = new page($total,$pagesize,"个用户","tab6");
		  
		  $query = mysql_query("select * from {$total_pr}user order by id {$page->limit}");
		   while($row = mysql_fetch_assoc($query)){
		  ?>
            <li class="user_li">
              <input class="u_checkbox" type="checkbox" value="<?=$row['id'] ?>" <?php if($_SESSION['user_id'] != $row['id']){echo 'name="manage"';} ?> onclick="checkbox(5,'manage')" />
              <img class="user_img" src="<?=$row['userpic'] ?>" />
              <span class="username"><a href="index.php?id=<?=$row['id'] ?>"><?=$row['username'] ?></a></span>
              <span class="user_small">
                博客等级：<font color="#0033FF"><?=$row['grade'] ?></font>&nbsp;
                博客积分：<font color="#0033FF"><?=$row['point'] ?></font>&nbsp;
                访问次数：<font color="#0033FF"><?=$row['visitnum'] ?></font>&nbsp;
                关注人气：<font color="#0033FF"><?=$row['popularity'] ?></font>&nbsp;
                博客状态:<?php 
				          if($row['rank'] == '111'){
					         echo '<font color="#009900">正常</font>';
				          }
						  elseif($row['rank'] == '000'){ 
						     echo '<font color="#333333">锁住</font>';
						  }
						  else {
							 echo '<font color="#0000FF">管理</font>';  
						  }
						  ?>
              </span>
            </li>
            <?php
		   }
		   ?>
          </ul>
          <span class="u_but">
            <span class="set_all"><input type="checkbox" name="check_all" onclick="setAll(5,'manage')" />&nbsp;全选/取消全选</span>
            <a class="set_throw" href="javascript:setDe('throw','manage')">发送纸条</a>
            <a class="set_lock" href="javascript:setDe('lock','manage')">将其锁住</a>
            <a class="set_normal" href="javascript:setDe('normal','manage')">恢复正常</a>
            <a class="set_manage" href="javascript:setDe('manage','manage')">设为管理员</a>
          </span>
          <span class="with_page">
          <?php echo $page->fpage() ?>
          </span>
        </div>
     </div>
    </div>
<!-----右部分内容结束----->
   </div>
<!-------------主体部分结束----------->
<!-------------尾部内容开始----------->
   <div id="footer">
	  <?php
       include "include/bottom.php";
      ?>
   </div>
<!-------------尾部内容结束----------->
</div>
</body>
</html>