<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 580Web @2010-2014 f02
'URL:http://www.580Web.Cn/
'EMail:wsok85@qq.com
'QQ:253819801
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0",UType)

Dim Fk_Admin_LoginName,Fk_Admin_LoginPass1,Fk_Admin_LoginPass2,Fk_Admin_Name,Fk_Admin_State,Fk_Admin_Type,Fk_Admin_Limit
Dim Limit_View,Limit_Menu,Limit_ShowModule
Dim levelTemp,levelTempArr

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call AdminList() '管理员列表
	Case 2
		Call AdminAddForm() '添加管理员表单
	Case 3
		Call AdminAddDo() '执行添加管理员
	Case 4
		Call AdminEditForm() '修改管理员表单
	Case 5
		Call AdminEditDo() '执行修改管理员
	Case 6
		Call AdminDelDo() '执行删除管理员
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：AdminList()
'作    用：管理员列表
'==========================================
Sub AdminList()
%>
		<div id="rightNav">
			<ul>
				<li><a href="Admin.asp?Type=2" target="dialog" width="700">添加管理员</a></li>
			</ul>
		</div>
		<div id="searchLine" class="font_bold">
			管理员管理
		</div>
		<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th align="center">序号</th>
				<th align="center">用户名</th>
				<th align="center">姓名</th>
				<th align="center">权限</th>
				<th align="center">操作</th>
			</tr>
<%
	Sqlstr="Select Fk_Admin_Id,Fk_Admin_LoginName,Fk_Admin_Name,Fk_Admin_Type From [Fk_Admin] Order By Fk_Admin_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1
		While Not Rs.Eof
			Fk_Admin_Type=FKFun.GetAdminTypeName(Rs("Fk_Admin_Type"))
%>
			<tr>
				<td height="20" align="center"><%=i%></td>
				<td align="center"><%=Rs("Fk_Admin_LoginName")%></td>
				<td align="center"><%=Rs("Fk_Admin_Name")%></td>
				<td align="center"><%=Fk_Admin_Type%></td>
				<td align="center"><a href="Admin.asp?Type=4&Id=<%=Rs("Fk_Admin_Id")%>" target="dialog" width="700">修改</a><%If Rs("Fk_Admin_Id")>1 Then%> <a href="Admin.asp?Type=6&Id=<%=Rs("Fk_Admin_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_Admin_LoginName")%>”？此操作不可逆！" refreshUrl="Admin.asp?Type=1" showStr="管理员删除成功！">删除</a><%End If%></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">&nbsp;</td>
			</tr>
		</table>
		<div id="rightBottom">
		
		</div>
<%
End Sub

'==========================================
'函 数 名：AdminAddForm()
'作    用：添加管理员表单
'==========================================
Sub AdminAddForm()
%>
<form id="AdminAdd" name="AdminAdd" method="post" target="ajax" action="Admin.asp?Type=3" showStr="新管理员添加成功！" refreshUrl="Admin.asp?Type=1" boxClose="1">
<div id="title">添加新管理员</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">登录名：</td>
			<td width="76%">&nbsp;<input name="Fk_Admin_LoginName" type="text" class="input" id="Fk_Admin_LoginName" /><span class="help" title="<p>管理用户登录用，建议用英文、数字，登录名不可重复，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">密码：</td>
			<td>&nbsp;<input name="Fk_Admin_LoginPass1" type="password" class="input" id="Fk_Admin_LoginPass1" /><span class="help" title="<p>管理用户密码，请输入1-50个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">重复密码：</td>
			<td>&nbsp;<input name="Fk_Admin_LoginPass2" type="password" class="input" id="Fk_Admin_LoginPass2" /><span class="help" title="<p>重新输入用户密码，两次密码需要一致，请输入1-50个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">姓名：</td>
			<td>&nbsp;<input name="Fk_Admin_Name" type="text" class="input" id="Fk_Admin_Name" /><span class="help" title="<p>管理员姓名，便于管理，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">权限：</td>
			<td>&nbsp;<select name="Fk_Admin_Type" class="input" id="Fk_Admin_Type" onchange="AdminTypeChange($(this).val());">
					<option value="0">超级管理员</option>
					<option value="1">普通管理员</option>
				</select><span class="help" title="<p>管理员权限，普通管理员可配置权限（此选项对超级管理员admin无效）。</p>"></span>
			</td>
		</tr>
		<tr>
			<td height="30" align="right">状态：</td>
            <td>&nbsp;<input name="Fk_Admin_State" type="radio" class="input" id="Fk_Admin_State" value="0" /> 禁用
				<input name="Fk_Admin_State" type="radio" class="input" id="Fk_Admin_State" value="1" checked="checked" /> 可用<span class="help" title="<p>选择帐号状态。</p>"></span>
			</td>
		</tr>
		<tr class="a_limit dis">
			<td height="30" align="right">内容编辑权限：</td>
            <td>&nbsp;<input name="Limit_View" type="radio" class="input" id="Limit_View" value="0" onclick="AdminViewLimitChange($(this).val());" /> 根据勾选
				<input name="Limit_View" type="radio" class="input" id="Limit_View" value="1" checked="checked" onclick="AdminViewLimitChange($(this).val());" /> 所有内容<span class="help" title="<p>选择普通管理员编辑内容权限，如选择“根据勾选”，内容编辑权限根据勾选确定。</p>"></span>
			</td>
		</tr>
		<tr class="a_limit dis">
			<td height="30" align="right">系统操作权限：</td>
			<td>
                <ul class="triState">
                    <li><span class="title">系统功能</span>
                        <ul>
                            <li><span class="title">常规管理权限</span>
                                <ul>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_System" /><label href="#" class="label">系统设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Html" /><label href="#" class="label">静态文件生成</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Rewrite" /><label href="#" class="label">伪静态规则生成</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Template" /><label href="#" class="label">模板管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_AspJpeg" /><label href="#" class="label">图片水印缩略设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_JMail" /><label href="#" class="label">邮件发送设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_SiteMap" /><label href="#" class="label">生成网站地图</label></li>
                                </ul>
                            </li>
                            <li><span class="title">内容设置权限</span>
                                <ul>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="m_Menu" /><label href="#" class="label">菜单管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="m_Module" /><label href="#" class="label">菜单项管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Info" /><label href="#" class="label">独立信息管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Friends" /><label href="#" class="label">友情连接管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Vote" /><label href="#" class="label">投票管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Focus" /><label href="#" class="label">独立轮换管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Subject" /><label href="#" class="label">专题管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Recommend" /><label href="#" class="label">推荐管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Word" /><label href="#" class="label">站内关键字管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Model" /><label href="#" class="label">模型管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Field" /><label href="#" class="label">自定义字段管理</label></li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
                <div class="cal"></div>
			</td>
		</tr>
		<tr class="a_limit a_limitView dis">
			<td height="30" align="right">勾选内容权限：</td>
			<td><div style="height:200px;overflow:auto;">
                <ul class="triState">
                    <li><span class="title">内容编辑权限</span>
                        <ul>
<%
	Temp=""
	Sqlstr="Select Fk_Menu_Id,Fk_Menu_Name From [Fk_Menu] Order By Fk_Menu_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	While Not Rs.Eof 
		If Temp="" Then
			Temp=Rs("Fk_Menu_Id")&"||"&Rs("Fk_Menu_Name")
		Else
			Temp=Temp&","&Rs("Fk_Menu_Id")&"||"&Rs("Fk_Menu_Name")
		End If
		Rs.MoveNext
	Wend
	Rs.Close
	TempArr=Split(Temp,",")
	For Each Temp In TempArr
%>
                            <li><span class="title"><%=Split(Temp,"||")(1)%></span>
<%
	Call GetModuleList(Split(Temp,"||")(0),0,"")
%>
                            </li>
<%
	Next
%>            
                        </ul>
                    </li>
                </ul>
                <div class="cal"></div>
				</div>
			</td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="submit" class="button" name="Enter" id="Enter" value="添 加" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：AdminAddDo
'作    用：执行添加管理员
'==============================
Sub AdminAddDo()
	Fk_Admin_LoginName=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_LoginName")))
	Fk_Admin_LoginPass1=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_LoginPass1")))
	Fk_Admin_LoginPass2=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_LoginPass2")))
	Fk_Admin_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_Name")))
	Fk_Admin_Type=Trim(Request.Form("Fk_Admin_Type"))
	Fk_Admin_State=Trim(Request.Form("Fk_Admin_State"))
	Call FKFun.JsonString(Fk_Admin_LoginName,1,50,0,"请输入登录名！","登录名不能大于50个字符！")
	Call FKFun.JsonString(Fk_Admin_LoginPass1,1,50,0,"请输入登录密码！","登录密码不能大于50个字符！")
	Call FKFun.JsonString(Fk_Admin_Name,1,50,0,"请输入姓名！","姓名不能大于50个字符！")
	Call FKFun.JsonNum(Fk_Admin_Type,"请选择权限！")
	Call FKFun.JsonNum(Fk_Admin_State,"请选择帐号状态！")
	If Fk_Admin_LoginPass1<>Fk_Admin_LoginPass2 Then
		Call FKFun.JsonError("两次密码不一致！")
	End If
	If Fk_Admin_Type>0 Then
		Fk_Admin_Limit=FKFun.HTMLEncode(Trim(Replace(Request.Form("Fk_Admin_Limit")," ","")))
		Limit_View=Trim(Request.Form("Limit_View"))
		Call FKFun.JsonNum(Limit_View,"请选择内容编辑权限！")
		If Limit_View=1 Then
			Limit_Menu="all"
			Limit_ShowModule="all"
		Else
			Limit_Menu=","
			Limit_ShowModule=","
			TempArr=Split(","&Fk_Admin_Limit,",v_")
			For Each Temp In TempArr
				If IsNumeric(Temp) Then
					Sqlstr="Select Fk_Module_Menu,Fk_Module_LevelList From [Fk_Module] Where Fk_Module_Id=" & Temp
					Rs.Open Sqlstr,Conn,1,1
					If Not Rs.Eof Then
						If Instr(Limit_Menu,","&Rs("Fk_Module_Menu")&",")=0 Then
							Limit_Menu=Limit_Menu&Rs("Fk_Module_Menu")&","
						End If
						If Instr(Limit_ShowModule,","&Temp&",")=0 Then
							Limit_ShowModule=Limit_ShowModule&Temp&","
						End If
						levelTempArr=Split(Rs("Fk_Module_LevelList"),",")
						For Each levelTemp In levelTempArr
							If levelTemp<>"" And Instr(Limit_ShowModule,","&levelTemp&",")=0 Then
								Limit_ShowModule=Limit_ShowModule&levelTemp&","
							End If
						Next
					End If
					Rs.Close
				End If
			Next
		End If
		Fk_Admin_Limit=Limit_Menu&"|-|"&Limit_ShowModule&"|-|,"&Fk_Admin_Limit&","
	Else
		Fk_Admin_Limit=""
	End If
	Sqlstr="Select Fk_Admin_Id,Fk_Admin_LoginName,Fk_Admin_LoginPass,Fk_Admin_Name,Fk_Admin_Type,Fk_Admin_State,Fk_Admin_Limit From [Fk_Admin] Where Fk_Admin_LoginName='"&Fk_Admin_LoginName&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_Admin_LoginName")=Fk_Admin_LoginName
		Rs("Fk_Admin_LoginPass")=Md5(Md5(Fk_Admin_LoginPass1,32),16)
		Rs("Fk_Admin_Name")=Fk_Admin_Name
		Rs("Fk_Admin_Type")=Fk_Admin_Type
		Rs("Fk_Admin_State")=Fk_Admin_State
		Rs("Fk_Admin_Limit")=Fk_Admin_Limit
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该管理员登录名已被占用！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：AdminEditForm()
'作    用：修改管理员表单
'==========================================
Sub AdminEditForm()
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_Admin_LoginName,Fk_Admin_Name,Fk_Admin_Type,Fk_Admin_State,Fk_Admin_Limit From [Fk_Admin] Where Fk_Admin_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_Admin_LoginName=Rs("Fk_Admin_LoginName")
		Fk_Admin_Name=Rs("Fk_Admin_Name")
		Fk_Admin_Type=Rs("Fk_Admin_Type")
		Fk_Admin_State=Rs("Fk_Admin_State")
		Fk_Admin_Limit=Rs("Fk_Admin_Limit")
		Limit_View=0
		If Fk_Admin_Limit="" Then
			Limit_View=1
		ElseIf Split(Fk_Admin_Limit,"|-|")(0)="all" Then
			Limit_View=1
		End If
	Else
		Rs.Close
		Call FKFun.ShowErr("管理员不存在！",1)
	End If
	Rs.Close
%>
<form id="AdminEdit" name="AdminEdit" method="post" target="ajax" action="Admin.asp?Type=5" showStr="管理员帐号修改成功！" refreshUrl="Admin.asp?Type=1" boxClose="1">
<div id="title">修改管理员帐号</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">登录名：</td>
			<td width="76%">&nbsp;<%=Fk_Admin_LoginName%></td>
		</tr>
		<tr>
			<td height="30" align="right">密码：</td>
			<td>&nbsp;<input name="Fk_Admin_LoginPass1" type="password" class="input" id="Fk_Admin_LoginPass1" /> *不修改请留空<span class="help" title="<p>管理用户密码，请输入0-50个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">重复密码：</td>
			<td>&nbsp;<input name="Fk_Admin_LoginPass2" type="password" class="input" id="Fk_Admin_LoginPass2" /><span class="help" title="<p>重新输入用户密码，两次密码需要一致，请输入0-50个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">姓名：</td>
			<td>&nbsp;<input name="Fk_Admin_Name" type="text" class="input" id="Fk_Admin_Name" value="<%=Fk_Admin_Name%>" /><span class="help" title="<p>管理员姓名，便于管理，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">权限：</td>
			<td>&nbsp;<select name="Fk_Admin_Type" class="input" id="Fk_Admin_Type" onchange="AdminTypeChange($(this).val());">
					<option value="0"<%=FKFun.BeSelect(Fk_Admin_Type,0)%>>超级管理员</option>
					<option value="1"<%=FKFun.BeSelect(Fk_Admin_Type,1)%>>普通管理员</option>
				</select><span class="help" title="<p>管理员权限，普通管理员可配置权限（此选项对超级管理员admin无效）。</p>"></span>
			</td>
		</tr>
		<tr>
			<td height="30" align="right">状态：</td>
            <td>&nbsp;<input name="Fk_Admin_State" type="radio" class="input" id="Fk_Admin_State" value="0"<%=FKFun.BeCheck(Fk_Admin_State,0)%> /> 禁用
				<input name="Fk_Admin_State" type="radio" class="input" id="Fk_Admin_State" value="1"<%=FKFun.BeCheck(Fk_Admin_State,1)%> /> 可用<span class="help" title="<p>选择帐号状态。</p>"></span>
			</td>
		</tr>
		<tr class="a_limit dis">
			<td height="30" align="right">内容编辑权限：</td>
            <td>&nbsp;<input name="Limit_View" type="radio" class="input" id="Limit_View" value="0"<%=FKFun.BeCheck(Limit_View,0)%> onclick="AdminViewLimitChange($(this).val());" /> 根据勾选
				<input name="Limit_View" type="radio" class="input" id="Limit_View" value="1"<%=FKFun.BeCheck(Limit_View,1)%> onclick="AdminViewLimitChange($(this).val());" /> 所有内容<span class="help" title="<p>选择普通管理员编辑内容权限，如选择“根据勾选”，内容编辑权限根据勾选确定。</p>"></span>
			</td>
		</tr>
		<tr class="a_limit dis">
			<td height="30" align="right">系统操作权限：</td>
			<td>
                <ul class="triState">
                    <li><span class="title">系统功能</span>
                        <ul>
                            <li><span class="title">常规管理权限</span>
                                <ul>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_System"<%If Instr(Fk_Admin_Limit,",s_System,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">系统设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Html"<%If Instr(Fk_Admin_Limit,",s_Html,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">静态文件生成</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Rewrite"<%If Instr(Fk_Admin_Limit,",s_Rewrite,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">伪静态规则生成</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_Template"<%If Instr(Fk_Admin_Limit,",s_Template,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">模板管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_AspJpeg"<%If Instr(Fk_Admin_Limit,",s_AspJpeg,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">图片水印缩略设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_JMail"<%If Instr(Fk_Admin_Limit,",s_JMail,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">邮件发送设置</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="s_SiteMap"<%If Instr(Fk_Admin_Limit,",s_SiteMap,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">生成网站地图</label></li>
                                </ul>
                            </li>
                            <li><span class="title">内容设置权限</span>
                                <ul>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="m_Menu"<%If Instr(Fk_Admin_Limit,",m_Menu,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">菜单管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="m_Module"<%If Instr(Fk_Admin_Limit,",m_Module,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">菜单项管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Info"<%If Instr(Fk_Admin_Limit,",o_Info,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">独立信息管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Friends"<%If Instr(Fk_Admin_Limit,",o_Friends,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">友情连接管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Vote"<%If Instr(Fk_Admin_Limit,",o_Vote,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">投票管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Focus"<%If Instr(Fk_Admin_Limit,",o_Focus,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">独立轮换管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Subject"<%If Instr(Fk_Admin_Limit,",o_Subject,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">专题管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Recommend"<%If Instr(Fk_Admin_Limit,",o_Recommend,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">推荐管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Word"<%If Instr(Fk_Admin_Limit,",o_Word,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">站内关键字管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Model"<%If Instr(Fk_Admin_Limit,",o_Model,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">模型管理</label></li>
                                    <li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="o_Field"<%If Instr(Fk_Admin_Limit,",o_Field,")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label">自定义字段管理</label></li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
                <div class="cal"></div>
			</td>
		</tr>
		<tr class="a_limit a_limitView dis">
			<td height="30" align="right">勾选内容权限：</td>
			<td><div style="height:200px;overflow:auto;">
                <ul class="triState">
                    <li><span class="title">内容编辑权限</span>
                        <ul>
<%
	Temp=""
	Sqlstr="Select Fk_Menu_Id,Fk_Menu_Name From [Fk_Menu] Order By Fk_Menu_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	While Not Rs.Eof 
		If Temp="" Then
			Temp=Rs("Fk_Menu_Id")&"||"&Rs("Fk_Menu_Name")
		Else
			Temp=Temp&","&Rs("Fk_Menu_Id")&"||"&Rs("Fk_Menu_Name")
		End If
		Rs.MoveNext
	Wend
	Rs.Close
	TempArr=Split(Temp,",")
	For Each Temp In TempArr
%>
                            <li><span class="title"><%=Split(Temp,"||")(1)%></span>
<%
	Call GetModuleList(Split(Temp,"||")(0),0,Fk_Admin_Limit)
%>
                            </li>
<%
	Next
%>            
                        </ul>
                    </li>
                </ul>
                <div class="cal"></div>
				</div>
			</td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="hidden" name="Id" value="<%=Id%>" />
	<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
<%
	If Fk_Admin_Type=1 Then
%>
	$('.a_limit').show();
	$('.a_limitView').hide();
<%
	End If
%>
<%
	If Limit_View=0 Then
%>
	$('.a_limitView').show();
<%
	End If
%>
});
</script>
<%
End Sub

'==============================
'函 数 名：AdminEditDo
'作    用：执行修改管理员
'==============================
Sub AdminEditDo()
	Fk_Admin_LoginPass1=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_LoginPass1")))
	Fk_Admin_LoginPass2=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_LoginPass2")))
	Fk_Admin_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Admin_Name")))
	Fk_Admin_Type=Trim(Request.Form("Fk_Admin_Type"))
	Fk_Admin_State=Trim(Request.Form("Fk_Admin_State"))
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_Admin_LoginPass1,0,50,0,"请输入登录密码！","登录密码不能大于50个字符！")
	Call FKFun.JsonString(Fk_Admin_Name,1,50,0,"请输入姓名！","姓名不能大于50个字符！")
	Call FKFun.JsonNum(Fk_Admin_Type,"请选择权限！")
	Call FKFun.JsonNum(Fk_Admin_State,"请选择帐号状态！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	If Fk_Admin_LoginPass1<>Fk_Admin_LoginPass2 And Fk_Admin_LoginPass1<>"" Then
		Call FKFun.JsonError("两次密码不一致！")
	End If
	If Fk_Admin_Type>0 Then
		Fk_Admin_Limit=FKFun.HTMLEncode(Trim(Replace(Request.Form("Fk_Admin_Limit")," ","")))
		Limit_View=Trim(Request.Form("Limit_View"))
		Call FKFun.JsonNum(Limit_View,"请选择内容编辑权限！")
		If Limit_View=1 Then
			Limit_Menu="all"
			Limit_ShowModule="all"
		Else
			Dim levelTemp,levelTempArr
			Limit_Menu=","
			Limit_ShowModule=","
			TempArr=Split(","&Fk_Admin_Limit,",v_")
			For Each Temp In TempArr
				If IsNumeric(Temp) Then
					Sqlstr="Select Fk_Module_Menu,Fk_Module_LevelList From [Fk_Module] Where Fk_Module_Id=" & Temp
					Rs.Open Sqlstr,Conn,1,1
					If Not Rs.Eof Then
						If Instr(Limit_Menu,","&Rs("Fk_Module_Menu")&",")=0 Then
							Limit_Menu=Limit_Menu&Rs("Fk_Module_Menu")&","
						End If
						If Instr(Limit_ShowModule,","&Temp&",")=0 Then
							Limit_ShowModule=Limit_ShowModule&Temp&","
						End If
						levelTempArr=Split(Rs("Fk_Module_LevelList"),",")
						For Each levelTemp In levelTempArr
							If levelTemp<>"" And Instr(Limit_ShowModule,","&levelTemp&",")=0 Then
								Limit_ShowModule=Limit_ShowModule&levelTemp&","
							End If
						Next
					End If
					Rs.Close
				End If
			Next
		End If
		Fk_Admin_Limit=Limit_Menu&"|-|"&Limit_ShowModule&"|-|,"&Fk_Admin_Limit&","
	Else
		Fk_Admin_Limit=""
	End If
	Sqlstr="Select Fk_Admin_Id,Fk_Admin_LoginName,Fk_Admin_LoginPass,Fk_Admin_Name,Fk_Admin_Type,Fk_Admin_State,Fk_Admin_Limit From [Fk_Admin] Where Fk_Admin_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		If Fk_Admin_LoginPass1<>"" Then
			Rs("Fk_Admin_LoginPass")=Md5(Md5(Fk_Admin_LoginPass1,32),16)
		End If
		Rs("Fk_Admin_Name")=Fk_Admin_Name
		If Id>1 Then
			Rs("Fk_Admin_Type")=Fk_Admin_Type
			Rs("Fk_Admin_State")=Fk_Admin_State
			Rs("Fk_Admin_Limit")=Fk_Admin_Limit
		End If
		Rs.Update()
		If UId=Clng(Id) And Fk_Admin_LoginPass1<>"" Then
			Response.Cookies("p_f02")=Md5(Md5(Md5(Fk_Admin_LoginPass1,32),16)&"f02"&Request.ServerVariables("REMOTE_ADDR")&Date(),16)
		End If
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要修改的管理员帐号不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：AdminDelDo
'作    用：执行删除管理员
'==============================
Sub AdminDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	If Id=1 Then
		Call FKFun.ShowErr("默认管理员无法删除！",2)
	End If
	Sqlstr="Select Fk_Admin_Id From [Fk_Admin] Where Fk_Admin_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("管理员帐号不存在！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：GetModuleList()
'作    用：菜单项列表
'==========================================
Function GetModuleList(gMenu,gModule,gDefault)
	Dim Rst
	Set Rst=Server.Createobject("Adodb.RecordSet")
	Sqlstr="Select Fk_Module_Id,Fk_Module_Name,Fk_Module_Type,Fk_Module_Model,Fk_Module_Url,Fk_Module_Link,Fk_Module_MenuShow,Fk_Module_State,Fk_Module_Order From [Fk_Module] Where Fk_Module_Menu="&gMenu&" And Fk_Module_Level="&gModule&" Order By Fk_Module_Order Asc,Fk_Module_Id Asc"
	Rst.Open Sqlstr,Conn,1,1
	If Not Rst.Eof Then
		i=1
		Response.Write("<ul>")
		While Not Rst.Eof
%>
					<li><span class="fleft">├</span><input type="checkbox" name="Fk_Admin_Limit" value="v_<%=Rst("Fk_Module_Id")%>"<%If Instr(gDefault,",v_"&Rst("Fk_Module_Id")&",")>0 Then%> checked="checked"<%End If%> /><label href="#" class="label"><%=Rst("Fk_Module_Name")%></label>
<%
			Call GetModuleList(gMenu,Rst("Fk_Module_Id"),gDefault)
			Response.Write("</li>")
			Rst.MoveNext
			i=i+1
		Wend
		Response.Write("</ul>")
	End If
	Rst.Close
End Function

Call FKFun.PageEnd()
%>
