<% userPageRights="{admin}" %>
<!--#include file="check.asp"-->
<!--#include file="../include/md5pass.asp"-->
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<%
If Request.QueryString("style")="del" Then
   conn.execute("delete * from tb_admin where w_id=" & Request.QueryString("id"))
   Response.Write("<script language=javascript>window.location.replace('adminmana.asp');</script>")
End If
If Request.QueryString("style")="adds" Then
    sql="select * from [tb_admin] where w_name='"&Request.Form("user")&"'"
    set rs=Server.CreateObject("Adodb.Recordset")
	rs.open sql,conn,1,1
	If not rs.Bof Then 
	   Response.Write("<script language=javascript>alert('已经有此用户。请返回！！！');history.back()</script>")
	   Response.End
	End If
	rights = trim(request.Form("rights"))
	rights = replace(rights," ","")
	rights = replace(rights,",","")
	if inStr(rights,"{admin}") > 0 then rights="{admin}"
   sqlp="insert into tb_admin (w_name,w_pass,w_fullname,w_email,w_qq,w_tel,w_off,rights) values ('"&Request.Form("user")&"','"&md5pass(Request.Form("pass"))&"','"&Request.Form("w_fullname")&"','"&Request.Form("w_email")&"','"&Request.Form("w_qq")&"','"&Request.Form("w_tel")&"','"&Request.Form("w_off")&"','"&rights&"')"
   conn.Execute(sqlp)
   Response.Write("<script language=javascript>window.location.replace('adminmana.asp');</script>")
   Response.end
End If

If Request.QueryString("style")="edits" Then
rights = trim(request.Form("rights"))
	rights = replace(rights," ","")
	rights = replace(rights,",","")
	if inStr(rights,"{admin}") > 0 then rights="{admin}"
if trim(Request.Form("pass"))<>"" then
 sqlss="update tb_admin set rights='"&rights&"',w_off='"&request("w_off")&"',w_pass='"&md5pass(Request.Form("pass"))&"',w_name='"&request("user")&"',w_fullname='"&request("w_fullname")&"',w_email='"&request("w_email")&"',w_qq='"&request("w_qq")&"',w_tel='"&request("w_tel")&"' where w_id="&int(Request("id"))&""
else
 sqlss="update tb_admin set rights='"&rights&"',w_off='"&request("w_off")&"',w_name='"&request("user")&"',w_fullname='"&request("w_fullname")&"',w_email='"&request("w_email")&"',w_qq='"&request("w_qq")&"',w_tel='"&request("w_tel")&"' where w_id="&int(Request("id"))&""
end if
conn.Execute(sqlss)
  Response.Write("<script language=javascript>alert('用户资料修改成功。请返回！');window.location.replace('adminmana.asp');</script>")
   Conn.Close()
   Response.end
End If
if request("userid")<>"" then
    sqls="select * from [tb_admin] where w_id="&request("userid")
    set rss=Server.CreateObject("Adodb.Recordset")
	rss.open sqls,conn,1,1
	If rss.Bof Then 
	   Response.Write("<script language=javascript>alert('该用户不存在。请返回！！！');history.back()</script>")
	else
	w_name=rss("w_name")
	w_fullname=rss("w_fullname")
	w_email=rss("w_email")
	w_qq=rss("w_qq")
	w_tel=rss("w_tel")
	w_type=rss("w_type")
	w_off=rss("w_off")
	thisRights = rss("rights")
	End If 
end if
%>
<html>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language=javascript>
function xxg()
{
  if (form2.user.value=="")
   {
     alert("帐号不能为空");
	 return false;
	 }
	if (form2.w_fullname.value=="")
   {
     alert("姓名不能为空");
	 return false;
	 }
	 return true
	 }
</script>
</head>
<body>
<table class=tableBorder width="95%" border=0 align="center" cellpadding=5 cellspacing=1>
  <tbody>
    <tr align="left">
      <th height=21 sytle="line-height:150%">【帐号管理】<a href="adminmana.asp">添加新帐号</a></th>
    </tr>
    <tr>
      <td  class=forumRow><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr align="center">
          <td width="35" height="25">ID</td>
          <td width="135" height="25">姓名/帐号</td>
          <td width="46">状态</td>
          <td width="480">注册时间｜上次登陆｜登陆次数</td>
          <td width="200" height="25">操作</td>
          </tr>
      </table>
        <%
sql="select * from [tb_admin] ORDER BY w_lasttime DESC"
set rs=Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
if rs.eof then
response.write ("目前还没有此方面的信息")
else
rs.PageSize = 20
page = CLng(Request("page"))
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
rs.AbsolutePage = Page
For iPage = 1 to rs.PageSize
w_types="管理员"
if rs("w_off")=1 then
w_offs="正常"
else
w_offs="锁定"
end if
%>
        <table width="100%" align="center" cellpadding="2" cellspacing="1">
            <tr>
              <td width="36" height="25" align="center"><%=rs("w_ID")%></td>
              <td width="123" height="25"><%=rs("w_fullname")%>|<%=rs("w_name")%></td>
              <td width="43" height="25" align="center"><%=w_offs%></td>
              <td width="477" align="center"><%=rs("w_addtime")%>｜<%=rs("w_utime")%>｜<span class="style1"><%=rs("w_number")%>次</span></td>
              <td width="193" height="25" align="center"><a href="adminmanas.asp?userid=<%=rs("w_id")%>">修改</a>      <a href="adminmana.asp?id=<%=rs("w_id")%>&style=del" class="black">删除</a></td>
            </tr>
        </table>
      <%
rs.MoveNext
   If rs.EOF Then Exit For
next
end if%></td>
    </tr>
    <tr>
      <td align="left" class=forumRow>目前共有 <%=rs.recordcount%> 位系统管理者      <font color="#FF0000">*严禁删除管理员帐号</font></td>
    </tr>
  </tbody>
</table>
<form name="form2" method="post" action="adminmana.asp<%if request("userid")<>"" then response.write "?style=edits&id="&request("userid") else response.write "?style=adds" end if%>" onSubmit="return xxg()">
  <table class=tableBorder width="95%" border=0 align="center" cellpadding=5 cellspacing=1>
    <tbody>
      <tr align="left">
        <th height=21 colspan="2" sytle="line-height:150%">【<%if request("userid")<>"" then%>修改帐号<%else%>添加帐号<%end if%>】<a name="1"></a></th>
      </tr>
      <tr>
        <td align="center"  class=forumRow>帐号</td>
        <td  class=forumRowHighlight><input name="user" type="text" id="user2" value="<%=w_name%>"></td>
      </tr>
      <tr>
        <td align="center"  class=forumRow>状态</td>
        <td  class=forumRowHighlight><select name="w_off" id="w_off">
          <option value="1"<%if w_off=1 then%> selected<%end if%>>正常</option>
          <option value="0"<%if w_off=0 then%> selected<%end if%>>锁定</option>
        </select><%if request("userid")=1 then%><font color="#FF0000">*注意：此帐号请误自行修改状态类型，否则后果自付</font><%end if%></td>
      </tr>
      <tr>
        <td width="9%" align="center"  class=forumRow>姓名</td>
        <td width="91%"  class=forumRowHighlight><input name="w_fullname" type="text" id="w_fullname2" value="<%=w_fullname%>"></td>
      </tr>
      <tr>
        <td align="center" class=forumRow>密码</td>
        <td class=forumRowHighlight><input name="pass" type="password" id="pass3"></td>
      </tr>
      <tr>
        <td align="center" class=forumRow>邮箱</td>
        <td class=forumRowHighlight><input name="w_email" type="text" id="w_email" value="<%=w_email%>"></td>
      </tr>
      <tr>
        <td align="center" class=forumRow>ＱＱ</td>
        <td class=forumRowHighlight><input name="w_qq" type="text" id="w_qq" value="<%=w_qq%>"></td>
      </tr>
      <tr>
        <td align="center" class=forumRow>电话</td>
        <td class=forumRowHighlight><input name="w_tel" type="text" id="w_tel" value="<%=w_tel%>"></td>
      </tr>
      <tr>
        <td align="center" class=forumRow>权限</td>
        <td class=forumRowHighlight><%
set rightsRs = server.CreateObject("adodb.recordset")
rightsRs.open "select * from tb_adminRights order by id ASC",conn,1,1
do while not rightsRs.Eof
	rights = Trim(rightsRs("rights"))
	if inStr(thisRights,rights) > 0 then
		response.Write("<input type=""checkbox"" checked value="""&rights&""" id=""rights"" name=""rights"">"&rightsRs("label")&"")
	else
		response.Write("<input type=""checkbox"" value="""&rights&""" id=""rights"" name=""rights"">"&rightsRs("label")&"")
	end if
	rightsRs.movenext
loop
%><%if request("userid")=1 then%><font color="#FF0000">*注意：此帐号禁止修改权限，否则后果自付</font><%end if%></td>
      </tr>
      <tr>
        <td class=forumRow>&nbsp;</td>
        <td class=forumRowHighlight><input type="submit" name="Submit" value="提交"></td>
      </tr>
    </tbody>
  </table>
</form>
  
</body>
</html>
<%
rs.close()
Conn.Close() %>