<!--#include file="../Include/Head.asp"-->

<%Call getValidform("adminform",1,1,1)%>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="../Main/Right.asp">首页</a></li>
    <li><a href="AdminSet.asp">后台管理设置</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
	<%
	target=Request_QueryString("target")
	Select Case target
	%>   
	<%
    '===========================================
    '默认显示管理列表
    Case ""
	%>
    <table class="tablelist">
    	<thead>
    	<tr>
        <th width="60">序号</th>
        <th>登录名</th>
        <th>昵称</th>
        <th width="80">登录次数</th>
        <th width="150">上次登陆时间</th>
        <th width="150">上次登陆IP</th>
        <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <%
        Set Rs=server.createobject("adodb.recordSet")
        Sql="select * from Jin_Admin where AdminID<>'oyjz' order by sysID asc"
        Rs.Open Sql,Conn,1,3
        For i=1 To Rs.RecordCount
        %>    
        <tr>
        <td><%=Rs("sysID")%></td>
        <td><%=Rs("AdminID")%></td>
        <td><%=Rs("AdminName")%></td>
        <td><%=Rs("LoginNum")%></td>
        <td><%=Rs("LastLoginTime")%></td>
        <td><%=Rs("LastLoginIP")%></td>
        <td>
        <%If Rs("IsLock")=true Then%>
        <a <%If Rs("AdminID")<>AdminID Then%>href="?action=Unlock&id=<%=Rs("sysID")%>"<%End If%> class="tablelink">解锁</a>
		<%else%>
        <a <%If Rs("AdminID")<>"admin" and Rs("AdminID")<>AdminID Then%>href="?action=Lock&id=<%=Rs("sysID")%>"<%End If%> class="tablelink">锁定</a>
		<%End If%>
        <a href="?action=reset&id=<%=Rs("sysID")%>" class="tablelink">重置</a> 
        <a <%If Rs("AdminID")<>"admin" and Rs("AdminID")<>AdminID Then%>href="?action=Del&id=<%=Rs("sysID")%>"<%End If%> class="tablelink">删除</a>
        </td>
        </tr> 
		<%
        Rs.MoveNext
        Next
        Rs.Close
        Set Rs=nothing
        %>    
        
        </tbody>
    </table>
    <a href="?target=add"><span style=" margin:10px 5px; line-height:25px; display:block; float:left; font-weight:bold; background:url(../Images/t01.png) no-repeat; padding-left:30px;">添加管理员</span></a>
    <a href="?target=edit&AdminID=<%=AdminID%>"><span style=" margin:10px 5px; line-height:25px; display:block; float:left; font-weight:bold; background:url(../Images/t02.png) no-repeat; padding-left:30px;">修改个人信息</span></a>
    <span style=" margin:10px 5px; margin-left:20px; line-height:25px; display:block; float:left; color:#999; background:url(../Images/t05.png) no-repeat; padding-left:30px;"><input name="Web_CookDate" class="Web_CookDate" type="text" value="<%=Web_CookDate%>" maxlength="3" style="width:30px; height:25px; padding:0 8px; font-size:14px; color:red; border:none; background:none;"/>设置记录账号密码时间(直接输入数字：1表示1天，31表示一个月365表示一年;请输入1-365之间的数字)</span>
	<%
    '===========================================
    '管理员添加
    Case "add"		'区分大小写！
	%>
    <div class="formtitle"><span>添加管理员</span></div>
    <form name="form1" class="adminform" action="?Action=add" method="post">
    <ul class="forminfo">
    <li><label>管理员账号</label>
    <input name="AdminID" type="text" class="newinput200" value=""  style="width:200px;" datatype="s3-18" nullmsg="管理员账号不能为空！" errormsg="管理员账号在3到18个字符之间！"   />
    <i class="Validform_checktip"></i>
    <li><label>管理员姓名</label>
    <input name="AdminName" type="text" class="newinput200" value="" style="width:200px;" datatype="*2-10" nullmsg="管理员姓名不能为空！" errormsg="管理员姓名在2到10个字符之间！" />
    <i class="Validform_checktip"></i>
    </li>
    <li><label>管理员密码</label>
    <input name="AdminPwd" type="text" class="newinput200" value="" style="width:200px;" datatype="s6-18" nullmsg="管理密码不能为空！" errormsg="密码长度请在6到18个字符之间！" />
    <i class="Validform_checktip"></i>
    </li>
    <li><label>&nbsp;</label><input name="submit" type="submit" class="btn" value="确认添加"/></li>
    </ul>
    </form>
    <%
    '===========================================
    '管理员信息修改
	Case "edit"
	%>
    <div class="formtitle"><span>修改<%=AdminID%>的信息</span></div>
    <form name="form1" class="adminform" action="?Action=edit" method="post">
    <ul class="forminfo">
    <li><label>管理员账号</label>
    <input name="AdminID" type="text" class="newinput200" value="<%=AdminID%>"  style="width:200px;" readonly="readonly" />
    <i>登陆账号不可修改！</i>
    <li><label>管理员姓名</label>
    <input name="AdminName" type="text" class="newinput200" value="<%=AdminName%>" style="width:200px;" datatype="*2-10" nullmsg="管理员姓名不能为空！" errormsg="管理员姓名在2到10个字符之间！" />
    <i class="Validform_checktip"></i>
    </li>
    <li><label>原密码</label>
    <input name="AdminPwdOld" type="password" class="newinput200" value="" style="width:200px;" datatype="*" nullmsg="原密码不能为空！" />
    <i class="Validform_checktip"></i>
    </li>
    <li><label>新密码</label>
    <input name="AdminPwd" type="password" class="newinput200" value="" style="width:200px;" datatype="s6-18" nullmsg="管理密码不能为空！" errormsg="密码长度请在6到18个字符之间！" />
    <i class="Validform_checktip"></i>
    </li>
    <li><label>&nbsp;</label><input name="submit" type="submit" class="btn" value="确认修改"/></li>
    </ul>
    </form>
	
	<%End Select %>
    
    </div>
    

<%
if Trim(Request_QueryString("Action"))="Unlock" then
	conn.execute "UPDATE [Jin_Admin] SET IsLock = false WHERE SysID = "&Trim(Request_QueryString("id"))
	Call goHistory()
end if
if Trim(Request_QueryString("Action"))="Lock" then
	conn.execute "UPDATE [Jin_Admin] SET IsLock = true WHERE SysID = "&Trim(Request_QueryString("id"))
	Call goHistory()
end if
if Trim(Request_QueryString("Action"))="reset" then
	conn.execute "UPDATE [Jin_Admin] SET AdminPwd = '"&MD5("123456")&"' WHERE SysID = "&Trim(Request_QueryString("id"))
	call alertrefer("密码已重置为:123456\n请下次登陆时使用新密码并修改密码！")
end if
if Trim(Request_QueryString("Action"))="Del" then
	conn.execute "delete from [Jin_Admin] where SysID = " & Trim(Request_QueryString("id"))
	call alertrefer("删除成功！")
end if
if Trim(Request_QueryString("Action"))="add" then
	conn.execute "insert into [Jin_Admin] (AdminID,AdminName,AdminPwd) values ('"&Request_Form("AdminID")&"','"&Request_Form("AdminName")&"','"&MD5(Request_Form("AdminPwd"))&"')"
	call alertgo1("添加成功！","AdminSet.asp")
end if
if Trim(Request_QueryString("Action"))="edit" then
	Admin_ID=Request_Form("AdminID")		'用户账号
	Admin_Name=Request_Form("AdminName")		'用户姓名
	Admin_PwdOld=Request_Form("AdminPwdOld")		'用户原密码
	Admin_Pwd=Request_Form("AdminPwd")		'用户新密码
	If Admin_Pwd<>"" Then Admin_PwdNew=Admin_Pwd else Admin_PwdNew=Admin_PwdOld
	
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Sql="select * from Jin_Admin where AdminID='"&Admin_ID&"' and AdminPwd='"&MD5(Admin_PwdOld)&"' "
	Rs.open Sql,conn,1,3
	If Rs.RecordCount>0 Then
	Rs("AdminName")=Admin_Name
	Rs("AdminPwd")=MD5(Admin_PwdNew)
	Rs.update
	call alertgo1("修改成功！\n请下次登陆时使用新密码登录！","AdminSet.asp")
	Else
	call alertgo("密码验证失败！")
	End If
	Rs.close
	Set Rs=nothing
end if
%>


<script>
autoSave("Web_CookDate");
</script>

<%Call BackFoot()%>