<?php
	session_start();
	include '../user.php';
	include '../conn.php';
	include '../../header.php';

	$user = $_COOKIE['AnYue_Admin_User'];
	$pass = $_COOKIE['AnYue_Admin_Pass'];

	if ($user != $username or $pass != $password){
	header('refresh:0;url=../login.php');
}else{
	if (!empty ($_GET['timpano']) and !empty ($_GET['qid'])){
	/*初始化变量*/
	$yqq = $_GET['timpano'];
	$qid = $_GET['qid'];
	$xg = $_POST['xg'];
	$sc = $_POST['sc'];
	/*获取管理员修改数据*/
	$xqq = $_POST['qq'];
	$myqq = $_POST['myqq'];
	$sid = $_POST['sid'];
	$qy = $_POST['qy'];
	$dj = $_POST['dj'];
	$nos = $_POST['nos'];
	$newsid = $_POST['newsid'];
	$Agreement = $_POST['Agreement'];

	if ($xg != ''){
	mysql_query("UPDATE `qqlist` SET `qq`='$xqq',`myqq`='$myqq',`sid`='$sid',`qy`='$qy',`dj`='$dj',`nos`='$nos',`newsid`='$newsid',`Agreement`='$Agreement' WHERE `qq`='$yqq' and `qid`='$qid'");
	mysql_query("UPDATE `fw1` SET `qq`='$xqq',`sid`='$sid',`Agreement`='$Agreement' WHERE `qq`='$yqq' and `qid`='$qid'");
	}else if ($sc != ''){
	mysql_query ("DELETE FROM `qqlist` WHERE qq='$yqq' and qid='$qid'");
	mysql_query ("DELETE FROM `fw1` WHERE qq='$yqq' and qid='$qid'");
	}
	}

	$page=isset($_GET['page'])?intval($_GET['page']):1;
	$num=50; //每页显示数
	$res1=mysql_query('select count(*) from `fw1`' ,$conn);
	$myrow = mysql_fetch_array($res1);
	$numrows=$myrow[0];
	$pagenum=ceil($numrows/$num);
	$offset=($page-1)*$num;
	$res2=mysql_query("select qq,myqq,sid,qy,dj,nos,newsid,Agreement,qid from `qqlist` where fwq='fw1' order by id desc limit $offset,$num");
	if ($myrow = mysql_fetch_array($res2)){
?>
<style type="text/css">
<!--
body {margin-left: 0px;	margin-top: 0px;	margin-right: 0px;	margin-bottom: 0px;	background-color: #F8F9FA;}
#list a{color: #0072E3;font-size:13px;text-decoration: none;}
#list a:hover {color: #FF5809;font-size:13px;padding:0px 8px;}
input{border-left:0px;border-top:0px;border-right:0px;border-bottom:1px;}
-->
</style>
<link href="../js/skin.css" rel="stylesheet" type="text/css" />
<link href="../js/css.css" rel="stylesheet" type="text/css" />
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
  <td width="17" height="29" valign="top" background="../images/mail_leftbg.gif"><img src="../images/left-top-right.gif" width="17" height="29" /></td>
  <td width="935" height="29" valign="top" background="../images/content-bg.gif">
   <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
    <tr><td height="31"><div class="titlebt">服务器①</div></td></tr>
   </table>
  </td>
  <td width="16" valign="top" background="../images/mail_rightbg.gif"><img src="../images/nav-right-bg.gif" width="16" height="29" /></td>
 </tr>
 <tr>
  <td height="71" valign="middle" background="../images/mail_leftbg.gif">&nbsp;</td>
  <td valign="top" bgcolor="#F7F8F9">
  <table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
   <tr><td height="13" valign="top">&nbsp;</td></tr>
   <tr>
    <td valign="top">
     <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
       <td class="left_txt">
        <div class="wbk"><div class="zbk"><div class="kg">
         <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr class="left_txt" style="text-align:center">
           <td width="10%" height="30" class="bky">QQ号</td>
		   <td width="9%" height="30" class="bky">所属用户</td>
           <td width="18%" height="30" class="bky">SID</td>
		   <td width="7%" height="30" class="bky">挂Q状态</td>
		   <td width="7%" height="30" class="bky">QQ等级</td>
		   <td width="7%" height="30" class="bky">挂Q失败次数</td>
		   <td width="7%" height="30" class="bky">自动更新SID</td>
		   <td width="7%" height="30" class="bky">挂Q协议</td>
		   <td width="7%" height="30">快捷操作</td>
          </tr>
         </table>
        </div></div></div>
       </td>
      </tr>
      <tr>
       <td height="20">
        <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
         <tr><td></td></tr>
        </table>
       </td>
      </tr>
      <tr>
       <td>
        <div class="wbk"><div class="zbk"><div class="kg"><div id="list">
         <?php do {$i++; ?>
		 <form action="fw1.php?timpano=<?=$myrow[0]?>&qid=<?=$myrow[8]?>" method="post" name="cz" target="_self" id="xg">
		 <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
		  <tr style="text-align:center" onMouseOver="this.style.background='#A8A8A8'; " onmouseout ="this.style.background=''; this.style.borderColor=''" >
           <td width="10%" class="bky"><input name="qq" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[0]?>"></td>
           <td width="9%" class="bky"><input name="myqq" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[1]?>"></td>
           <td width="18%" class="bky"><input name="sid" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[2]?>"></td>
           <td width="7%" class="bky"><input name="qy" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[3]?>"></td>
		   <td width="7%" class="bky"><input name="dj" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[4]?>"></td>
		   <td width="7%" class="bky"><input name="nos" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[5]?>"></td>
		   <td width="7%" class="bky"><input name="newsid" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[6]?>"></td>
		   <td width="7%" class="bky"><input name="Agreement" style="width:90%;color:#000;text-align:center;"value="<?=$myrow[7]?>"></td>
           <td width="7%">
		   <input style="width:55%;color:#000;text-align:center;" type="submit" name="xg" value="修改">
		   <input style="width:55%;color:#000;text-align:center;" type="submit" name="sc" value="删除">
		   </td>
		  </tr>
		 </table>
		 </form>
		 <?php }
		  while ($myrow = mysql_fetch_array($res2));
		  }
		  echo '</div></div></div></div>';
		  $Previous_page=$page-1;   //上页
		  $next_page=$page+1;   //下页
		  echo "<p style='padding-top:10px;padding-bottom:10px;text-align:center;'>";
		  echo '<span class="left_txt">当前服务器挂Q数:<font color=red>'.$numrows.'</font>个，共有<font color=red>'.$pagenum.'</font>页，当前页(<font color=red>'.$page.'</font>/'.$pagenum.')&nbsp;&nbsp;</span>';
		  echo '<a href=?page=1>首页</a>&nbsp;&nbsp;';
		  if ($pagenum<$page){
		  echo '暂无用户';
		  }else if ($pagenum<2){
		  echo '';
		  }else if ($Previous_page<1){
		  echo '<span class="left_txt">上一页</span>&nbsp;&nbsp;';
		  echo "<a href=?page=$next_page>下一页</a>";
		  }else if ($page<=$pagenum-2){
		  echo "<a href=?page=$Previous_page>上一页</a>&nbsp;&nbsp;";
		  echo "<a href=?page=$next_page>下一页</a>";
		  }else{
		  echo "<a href=?page=$Previous_page>上一页</a>&nbsp;&nbsp;";
		  echo '<span class="left_txt">下一页</span>';
		  }
		  echo "&nbsp;&nbsp;<a href=?page=$pagenum>末页</a>&nbsp;&nbsp;";
		  echo '</p>';
	 	 ?>
       </td>
      </tr>
     </table>
    </td>
   </tr>
  </table>
  </td>
   <td background="../images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
   <td valign="middle" background="../images/mail_leftbg.gif"><img src="../images/buttom_left2.gif" width="17" height="17" /></td>
   <td height="17" valign="top" background="../images/buttom_bgs.gif"><img src="../images/buttom_bgs.gif" width="17" height="17" /></td>
   <td background="../images/mail_rightbg.gif"><img src="../images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
 </table>
</body>
<?php
}
?>