<?php

	session_start();
	include '../user.php';
	include '../conn.php';
	include '../Admin/config.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['uin']) and !empty ($_GET['user'])){
	/*初始化变量*/
	$uin = $_GET['uin'];
	$user = $_GET['user'];
	$xg = $_POST['xg'];
	$email = $_GET['email'];
	/*获取管理员修改数据*/
	$jf = $_POST['jf'];
	$yuanyin = $_POST['yuanyin'];
	if ($yuanyin == ''){
	$yuanyin = '管理员未填写原因！';
	}
	if ($xg != ''){
	mysql_query("UPDATE `user` SET `jf`='$jf' WHERE `id`='$uin' and `user`='$user'");
	include '../../Source/function/global.php';
	Send_out_Mail ($email,'['.$configure['webname'].'] 积分变动通知','尊敬的：'.$user.'！<br><br><br><br>您的账户积分被管理员设置为<b>'.$jf.'</b><br><br><br><br>设置原因：<b>'.$yuanyin.'</b><br><hr><br>感谢您的我们的大力支持！我们的服务依然会不求更好，只求最好！');
	}
	}

	$page=isset($_GET['page'])?intval($_GET['page']):1;
	$num=50; //每页显示数
	$res1=mysql_query('select count(*) from `user`',$conn);
	$myrow = mysql_fetch_array($res1);
	$numrows=$myrow[0];
	$pagenum=ceil($numrows/$num);
	$offset=($page-1)*$num;
	$res2=mysql_query("select id,user,jf,email from user 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="5%" height="30" class="bky">UID</td>
		   <td width="5%" height="30" class="bky">用户名</td>
		   <td width="5%" height="30" class="bky">积分数量</td>
		   <td width="20%" 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="jf.php?uin=<?=$myrow[0]?>&user=<?=$myrow[1]?>&email=<?=$myrow[3]?>" 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="5%" class="bky"><div style="width:90%;color:#000;text-align:center;"><?=$myrow[0]?></div></td>
           <td width="5%" class="bky"><input name="user" style="width:90%;color:#000;text-align:center;" value="<?=$myrow[1]?>"></td>
           <td width="5%" class="bky"><input name="jf" style="width:90%;color:#000;text-align:center;" value="<?=$myrow[2]?>"></td>
           <td width="20%">
		   <div style="width:100%;color:#000;text-align:center;"><input name="yuanyin" style="width:85%;" placeholder="此处填写操作原因，操作原因将以邮件形式发送至用户，请认真填写！" value="">
		   <input style="width:10%;color:#000;text-align:center;" type="submit" name="xg" value="修改">
		   </div>
		   </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">共有用户:<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
}
?>