<?php
include("qs.php");
require( '../data/config.php');
$conn=mysql_connect($db_host,$db_user,$db_pass);
mysql_query("set names 'utf8'");
mysql_select_db($db_name);
if (PHP_VERSION >= '5.1' && !empty($timezone))
{
    date_default_timezone_set($timezone);
}
$qs=explode(",",$_SESSION["tm_qs"]);
if($qs[0]==0)
   {
   echo "<script>location.href='main.php';</script>";
   exit();
   }
?>
<!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" />
<META http-equiv="Pragma" content="no-cache" />
<LINK href="css/general.css" rel="stylesheet" type="text/css" />
<LINK href="css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script>
var xmlHttp = false;
try {
xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
xmlHttp = false;
}
}
}
if (!xmlHttp){
alert("无法创建 XMLHttpRequest 对象！");
} 

function getInfo(id) {
var url = "jin.php?id=" + id + "&ku=tm_admin";
xmlHttp.open("GET", url, true);//这里的true代表是异步请求
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
} 

function updatePage(){
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
var a=response.split(","); 
   document.getElementById("jin"+a[1]).src =a[2];
}
}
</script>
</HEAD><BODY>
<div class="h2">系统管理 >> 帐号管理</div>
<div class="list-div">

<table cellspacing='1' cellpadding='3'>
<tr>
  <th align='left'><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="left">&nbsp;&nbsp;帐号管理</div></td>
        <td width="150"><div align="center"><h1><span class="action-span"><a href="admin_w.php">添加</a></span></h1></div></td>
      </tr>
    </table></th>
</tr>
<tr><td align="left" valign="top" style="background:#F5F5F5;padding-bottom:8px;"><table width="80%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td height="30">
	<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 CALLPADDING="0">
			  <form id="form2" name="form2" method="post" action="admin_w.php">
			  <tr bgcolor="#D5D5D5">
                    <td height="20" bgcolor="#C2C2C2" style="PADDING-LEFT: 8px; PADDING-TOP: 8px"><input type="checkbox" name="selall" title="全选"  onClick="select_all('form2','chkkindid[]',this.name)">&nbsp;</td>
                    <td bgcolor="#C2C2C2" style="PADDING-LEFT: 8px; PADDING-TOP: 8px">登录名称</td>
					<td width="25%" bgcolor="#C2C2C2"><div align="center" class="STYLE1">姓名</div></td>
                    <td width="14%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">添加日期</div></td>
                    <td width="11%" bgcolor="#C2C2C2" class="STYLE1"><div align="center">最后登录</div></td>
                    <td width="10%" bgcolor="#C2C2C2"><div align="center">状态</div></td>
                    <td bgcolor="#C2C2C2"><div align="center">操作</div></td>
			  </tr>
				<?php 
$sql="select count(*) from tm_admin";
$resultc=mysql_query($sql) or die(mysql_error());
$rsc=mysql_fetch_array($resultc);
$num=$rsc[0];
$pagesize=12; 
if(_get('page')<>"")
   {
   $page=_get('page')-1;
   if($page<0)$page=0;
   if($page>(intval($num/$pagesize)))$page=intval($num/$pagesize);
   }
else
	$page=0;
		  $sql="select * from tm_admin order by id desc limit ".$pagesize*$page.",".$pagesize;
		  $rsql=mysql_query($sql);
		  while($rs=mysql_fetch_object($rsql))
		  {
		  ?>
              <TR BORDER="0" WIDTH="100%" bgcolor="#EEEEEE" onmousemove="this.style.color='#000000';this.style.backgroundColor='#D5D5D5'" onmouseout="this.style.backgroundColor='#EEEEEE';this.style.color='#000000'">
                <TD width="6%"  height=25 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;"><?php if($rs->id<>1){?><input name="chkkindid[]" type="checkbox" id="chkkindid[]" value="<?php echo $rs->id;?>" /><?php }?>&nbsp;</TD>
                <TD  height=25 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;">
                <?php  echo $rs->user; if($rs->id==1) echo "(最高管理员)";?></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center"><?php echo $rs->name;?>&nbsp;</div></TD>
				<TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">&nbsp;<?php echo $rs->date;?></div></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">&nbsp;<?php echo $rs->indate;?></div></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;">
				  <div align="center"><a href="javascript:void(0);" onclick="getInfo(<?php echo $rs->id;?>)"><img id="jin<?php echo $rs->id;?>" src="<?php if($rs->show1==0) echo "images/close.gif"; else echo "images/righton.gif";?>" border="0" /></a> </div></TD>
                <TD width="15%" 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center"><a href="admin_w.php?id=<?php echo $rs->id;?>">更改</a> <a href="qs_w.php?id=<?php echo $rs->id;?>">权限</a> </div></TD>
              </TR>
		  <?php }?>
			<TR BORDER="0" WIDTH="100%">
              <TD height="30"  colspan="7">&nbsp;&nbsp;
                <input type="image" src="images/del.gif" align="absmiddle" border="0" name="del" onclick="javascript:return chkform(form2.name,'确定刪除吗？','del');" />
                &nbsp;&nbsp;
                <input name="action" type="hidden" id="action" /></TD>
			</TR>
		  </form>
<TR BORDER="0" WIDTH="100%">
			  <TD height="30"  colspan="7" style="padding-left:8px;">
			  <div class="page">
		  总数：<?php echo $num;?>个,每页显示<?php echo $pagesize;?>个，共<?php echo ceil($num/$pagesize);?>页，<a href="admin.php?page=1">首页</a><?php if($page>0) echo " <a href='admin.php?page=".$page."'>上一页</a> ";
for($i=($page>4?($page-3):1);$i<=($page<(ceil($num/$pagesize)-4)?(($page>=5?($page-3):1)+8):ceil($num/$pagesize));$i++)
    {
	if(($page+1)==($i))
	echo "&nbsp;".$i."&nbsp;";
	else
	echo "<a href=admin.php?page=".$i.">[".($i)."]</a>";
	}
	?><?php if($page<ceil($num/$pagesize)-1) echo " <a href='admin.php?page=".($page+2)."'>下一页</a> ";?><a href="admin.php?page=<?php echo round(ceil($num/$pagesize));?>">末页</a>		  </div>			  </TD>
			  </TR>
      </TABLE>
	</td>
  </tr>
</table>	</td>
  </tr>
</table></td>
</tr></table></div>

<?php include "boot.php";?>
</body></html>
<script language="JavaScript" >

function chkform(theForm,msg,action){
	if (confirm(msg)){

		document.forms[theForm].action.value = action;
		document.forms[theForm].submit();
		return true;
	}else{
		return false;
	}
}

// -------- 全選或取消 checkbox 方塊
<!--
function select_all(formName, elementName, selectAllName) {
	if(document.forms[formName].elements[selectAllName].checked) {
		
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
		
			document.forms[formName].elements[elementName].checked = true;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
			document.forms[formName].elements[elementName][i].checked = true;
		}
	}
	else {
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
			document.forms[formName].elements[elementName].checked = false;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
				document.forms[formName].elements[elementName][i].checked = false;
		}
	}
}
//-->
</script>