<jsp:useBean id="record" scope="page" class="chatweb.manager" />
<%@ page import="java.sql.*"%>
<%@ include file="../Common.jsp" %>
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理页面</title>
<link href="../chat.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript" type="text/JavaScript">
function confirmDelete(username,pageno){
	if(window.confirm("确定要删除该记录吗？"))
		parent.location.href="delete.jsp?username="+username+"&page="+pageno;
}
function forbidden(username,pageno){
	var blocktime=prompt("请输入禁止时间，以分钟计(输入0可以取消禁言状态)","20");
	if(blocktime)
		parent.location.href="forbid.jsp?username="+username+"&page="+pageno+"&blocktime="+blocktime;
}
</script>
<%
if(!session.getAttribute("grade").toString().equals("1")){
    response.sendError(404,"Forbidden");
}
int pagesize=5;
int currentpage=1;
if(request.getParameter("page")!=null){
	currentpage=Integer.parseInt(request.getParameter("page"));
}
int count[];
count=record.getCount("user",pagesize);
%>
<body bgcolor="#FFF7DD">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="20"><font color="#FF0000">共有<%=count[0]%>个成员</font>&nbsp;共有<%=count[1]%>页&nbsp;当前是第<%=currentpage%>页&nbsp; 【<a href="manage.jsp?page=1" alt="第一页">&lt;&lt;</a>&nbsp;
      <%if(currentpage-3>1){
	out.println("...");
}
for(int n=currentpage-3;n<=currentpage+3;n++){
	if(n>1&&n<count[1]){
		if(n!=currentpage){
			out.println("<a href=\"manage.jsp?page="+n+"\">"+n+"</a>&nbsp;");
		}
		else{
			out.println(n+"&nbsp;");
		}
        }
}
if(currentpage+3<count[1]){
	out.println("...");
}
%> <a href="manage.jsp?page=<%=count[1]%>" alt="末页">&gt;&gt;</a>】
      <div align="right"></div></td>
  </tr>
  <tr>
    <td> <table width="100%" border="0" cellpadding="0" cellspacing="1" class="mytable">
        <tr bgcolor="#D3D3D3">
          <td width="20%"> <div align="center"><strong>成员名</strong></div></td>
          <td colspan="2"> <div align="center"><strong>状态</strong></div>
            <div align="center"></div></td>
          <td width="40%" height="25"> <div align="center"><strong>上次登陆时间</strong></div></td>
          <td width="20%"> <div align="center"><strong>操作</strong></div></td>
        </tr>
        <%
ResultSet rs=record.getPage("user",currentpage,pagesize);
int style=0;
java.sql.Date dt;
Time tm;
String username=null;
while(rs.next()){
username=rs.getString("username");
if(style%2==0){
%>
        <tr bgcolor="#EFEFEF">
<%}else{%>
	 <tr bgcolor="#FFFFFF">
<%}%>
          <td> <div align="center"><%=username%></div></td>
          <td width="10%"><div align="center"><%=(isOnline(username)?"<font color=red>在线</font>":"不在线")%></div></td>
          <td width="10%"><div align="center"><%=(record.getBlocked(username)>0?"被禁言":"正常")%></div></td>
          <td height="30">
            <div align="center">
              <%
dt=rs.getDate("lasttime");
tm=rs.getTime("lasttime");
out.println(dt+" "+tm);
%>
            </div></td>
          <td> <div align="center">
              <%if(rs.getInt("grade")==1) {//不能对管理员进行操作
		  	out.println("管理员");
		  }else{%>
              <input type="button" name="Submit32" value="禁止发言" onClick="forbidden('<%=username%>','<%=currentpage%>')">
              <input type="button" name="Submit222" value="删除" onClick="confirmDelete('<%=username%>','<%=currentpage%>')">
              <%}%>
            </div></td>
        </tr>
<%
style++;
}%>
      </table></td>
  </tr>
</table>
</body>
</html>
