<%@language=vbscript codepage=936%>
<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim dns
dns="../"
%>
<!--#Include file="../Common/Inc_DatConn.asp"-->
<!--#Include file="Common/Inc_Config.asp"-->
<!--#Include file="Common/Inc_Function.asp"-->
<!--#Include file="fy_admin_check.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/Admin_Style.Css" rel="stylesheet" type="text/css">
<script src="../common/Admin.js" type="text/javascript"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<%
if fla24<>1 and Session("intUserLevel")<2 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误：操作权限出错，您没有权限操作些功能！</li>"
Call Admin_ShowErr(ErrMsg)
end if
bbaction=changechr(request("bbaction"))
Select case bbaction
  	Case "editsysuser"
		call editsysuser
  	Case "saveeditsysuser"
		call saveeditsysuser
  	Case "editsysuserqx"
		call editsysuserqx
  	Case "saveeditsysuserqx"
		call saveeditsysuserqx
  	Case "locksysuser"
		call locksysuser
  	Case "editsysuser"
		call editsysuser
  	Case "delsysuser"
		call delsysuser
  	Case "adduser"
		call adduser
  	Case "saveuser"
		call saveuser
	Case else
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="title"> 
    <td height="22" colspan="3" align="center"><strong>管理员管理</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="100" height="30"><strong>管理导航：</strong></td>
    <td height="30" width="60%">
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?bbaction=adduser">添加管理员</a>
    <td height="30" width="30%"><table border="0" width="96%" cellspacing="0" cellpadding="0" align="center">
	    <tr>
		  <form method="post" action="?" name="Form1">
		  <td width="50%" align="right">帐号：<input type="text" name="KeyWord" size="15" value="<%= Request("KeyWord")%>" class="face"> <input type="submit" name="submit" value="搜" class="button"></td>
		  </form>
		</tr>
	  </table></td>
  </tr>
</table>
<br>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" Class="border">
    <tr class="title"> 
      <td width="60" align="center">编 号</td>
      <td width="120" align="center">用户名</td>
      <td width="100" align="center">状态</td>
      <td width="100" align="center">用户身份</td>
            <td width="120" align="center">添加时间</td>
      <td width="140" align="center">操 作</td>
    </tr>
<%Dim rdsSysUser    '/通告的数据库对象及SQL语句/
Dim sqlSysUser
Dim rdsTotalRec   
Dim strKeyWord    '/关键字/
Dim intPage       '/当前页/
Dim intTotalRec	  '/所有记录/
Dim intUserCot	  '/通告条数/
Dim intUserCount  '/通告条数/
Dim n,p,ii	      '/定义一些临时变量/
Dim strState

strKeyWord = Request("KeyWord")

intPage = Trim(Request("Page"))
if intPage = "" then
	intPage = 1
else
	intPage = Clng(intPage)
end if

intUserCot = 10

set rdsSysUser = Server.CreateObject("ADODB.Recordset")
if strKeyWord <> "" then
	set rdsTotalRec = Conn.Execute("Select Count(UserKey) From Sys_Account Where Account like '%"& strKeyWord &"%'")
	intTotalRec = rdsTotalRec(0)
	sqlSysUser = "Select * From Sys_Account Where Account like '%"& strKeyWord &"%' Order By UserKey Desc"
else
	set rdsTotalRec = Conn.Execute("Select Count(UserKey) From Sys_Account")
	intTotalRec = rdsTotalRec(0)
	sqlSysUser = "Select * From Sys_Account Order By UserKey Desc"
end if
rdsSysUser.Open sqlSysUser,Conn,1,1
if not rdsSysUser.EOF then
	if intTotalRec mod intUserCot = 0 then
		n = intTotalRec \ intUserCot
	else
		n = intTotalRec \ intUserCot + 1
	end if
	rdsSysUser.MoveFirst
	if intPage > n then intPage = n
	if intPage < 1 then intPage = 1
	rdsSysUser.Move (intPage - 1) * intUserCot
	do while not rdsSysUser.EOF and intUserCount < Clng(intUserCot)
struserkey=rdsSysUser("UserKey")
		intUserCount = intUserCount + 1
		if rdsSysUser("State") = 0 then
			strState = "活动"
			strOperState = "<a href=""?bbaction=locksysuser&id="&struserkey&"&lx=1"">锁定</a>"
		else
			strState = "<font color=""red"">关闭</font>"
			strOperState = "<a href=""?bbaction=locksysuser&id="&struserkey&"&lx=0"">开启</a>"
		end if%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
      <td width="60" align="center"><%=struserkey%></td>
      <td width="120" align="center"><%= rdsSysUser("Account")%></td>
      <td width="100" align="center"><%= strState%></td>
      <td align="center"><%if rdsSysUser("UserLevel") = 1 then Response.Write "普通用户" else Response.Write "管 理 员" end if%></td>
		      <td width="120" align="center"><%= FormatTime(rdsSysUser("CreateTime"),5)%></td>
      <td width="140" align="center"><%if rdsSysUser("UserLevel") = 1 then%><a href="?bbaction=editsysuserqx&id=<%=struserkey%>">权限</a><%else%><font color="#808080" title="管理员拥有所有权限，不需要设置！">权限</font><%end if%>
      &nbsp;<%= strOperState%>&nbsp;<a href="?bbaction=editsysuser&id=<%=struserkey%>">编辑</a>&nbsp;<%if Session("strAccount") = rdsSysUser("Account") then%><font color="#808080" title="当前登录用户，不能删除！">删除</font><%else%><a href="?bbaction=delsysuser&id=<%=struserkey%>">删除</a><%end if%></td>
    </tr>
<%
		rdsSysUser.MoveNext
	loop
else
	Response.Write "<tr><td width=""100%"" height=""25"" colspan=""10"" class=""banma1"">&nbsp;<font color=""#FF0000"">没有管理用户信息...</font></td></tr>"
end if
rdsSysUser.Close
set rdsSysUser = nothing

if intPage - 1 mod 10 = 0 then
	p = (intPage - 1) \ 10
else
	p = (intPage - 1) \ 10
end if	
%>
  </table>
  	  <table border="0" width="96%" cellspacing="0" cellpadding="0" align="center">
	    <form method="post" action="?" id="form2" name="form2">
	    <input type="hidden" name="KeyWord" value="<%= strKeyWord%>">
	    <tr>
		  <td width="30%" height="30" valign="middle">页次：<b><%= intPage %></b>/<b><%= n %></b>页 每页<b><%= intUserCot %></b>条 共<b><%= intTotalRec %></b>条</td>
		  <td width="70%" height="30" valign="middle"><div align="right">分页：
			<%
				if intPage = 1 then
					Response.Write "<font face=webdings>9</font>   "
				else
					Response.Write "<a href='?Page=1&KeyWord="& strKeyWord &"' title=首页><font face=webdings>9</font></a>   "
				end if
				if p * 10 > 0 then Response.Write "<a href='?Page="&Cstr(p*10)&"&KeyWord="& strKeyWord &"' title=上十页><font face=webdings>7</font></a>   "
				Response.Write "<b>"
				for ii = p * 10 + 1 to P * 10 + 10
					   if ii = intPage then
				          Response.Write "<font color=""#FF0000"">"+Cstr(ii)+"</font> "
					   else
					      Response.Write "<a href='?Page="&Cstr(ii)&"&KeyWord="& strKeyWord &"'>"+Cstr(ii)+"</a>   "
					   end if
					if ii = n then exit for
				next
				Response.Write "</b>"
				if ii < n then Response.Write "<a href='?Page="&Cstr(ii)&"&KeyWord="& strKeyWord &"' title=下十页><font face=webdings>8</font></a>   "
				if intPage=n then
					Response.Write "<font face=webdings>:</font>   "
				else
					Response.Write "<a href='?Page="&Cstr(n)&"&KeyWord="& strKeyWord &"' title=尾页><font face=webdings>:</font></a>   "
				end if
			%>
			转到：<input type="text" name="Page" size="2" maxlength="10" value="<%= intPage %>" class="face"> <input type="submit" value="Go" name="submit" class="button">
			</div></td>
		</tr>
		</form>
	  </table>
<%
end Select
sub editsysuserqx
id=RtnReplaceInt(Request("Id"),0)
set rdsInfo = Server.CreateObject("ADODB.Recordset")
sqlInfo = "Select * From Sys_Account Where UserKey = "&id
rdsInfo.Open sqlInfo,Conn,1,1
if not rdsInfo.EOF then
flag=rdsInfo("flag")
testfla="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
if InStr(flag,",")>0 then
fla=split(flag,",")
else
fla=split(testfla,",")
end if
fla0=fla(0)
fla1=fla(1)
fla2=fla(2)
fla3=fla(3)
fla4=fla(4)
fla5=fla(5)
fla6=fla(6)
fla7=fla(7)
fla8=fla(8)
fla9=fla(9)
fla10=fla(10)
fla11=fla(11)
fla12=fla(12)
fla13=fla(13)
fla14=fla(14)
fla15=fla(15)
fla16=fla(16)
fla17=fla(17)
fla18=fla(18)
fla19=fla(19)
fla20=fla(20)
fla21=fla(21)
fla22=fla(22)
fla23=fla(23)
fla24=fla(24)
fla25=fla(25)
fla26=fla(26)
fla27=fla(27)
%>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <form name="form1" method="post" action="?bbaction=saveeditsysuserqx">
<input name="id" type="hidden" value="<%=id%>">
			  <tr class=title>
			    <td height="29">
				◆预留功能</td>
			  </tr> 
  	  
			  <tr class="tdbg">
			    <td height="29"><input type="checkbox" name="0" value="1"<%if fla0=1 then%> checked<%end if%> class=radio>备用</td>
			  </tr> 
  	  
			  <tr class=title>
			    <td height="29">
				◆会员管理</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class="tdbg">
				<input type="checkbox" name="1" value="1"<%if fla1=1 then%> checked<%end if%> class=radio>查看资料　<input type="checkbox" name="2" value="1"<%if fla2=1 then%> checked<%end if%> class=radio>点数管理　　<input type="checkbox" name="3" value="1"<%if fla3=1 then%> checked<%end if%> class=radio>级别设置　<input type="checkbox" name="4" value="1"<%if fla4=1 then%> checked<%end if%> class=radio>会员状态（开启/锁定）　<input type="checkbox" name="5" value="1"<%if fla5=1 then%> checked<%end if%> class=radio>会员删除</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class=title>
				◆新闻公告</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class="tdbg">
				<input type="checkbox" name="6" value="1"<%if fla6=1 then%> checked<%end if%> class=radio>信息添加　<input type="checkbox" name="7" value="1"<%if fla7=1 then%> checked<%end if%> class=radio>信息编辑　<input type="checkbox" name="8" value="1"<%if fla8=1 then%> checked<%end if%> class=radio>信息审核　<input type="checkbox" name="9" value="1"<%if fla9=1 then%> checked<%end if%> class=radio>信息删除</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class=title>
				◆供求信息管理</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class="tdbg">
				<input type="checkbox" name="10" value="1"<%if fla10=1 then%> checked<%end if%> class=radio>按信息分类管理(<font color="#FF0000">注：需要在分类中指定管理
				员</font>)　<input type="checkbox" name="11" value="1"<%if fla11=1 then%> checked<%end if%> class=radio>按地区分类管理(<font color="#FF0000">注：需要在分类中指定管理
				员</font>)<br>
				<input type="checkbox" name="12" value="1"<%if fla12=1 then%> checked<%end if%> class=radio>信息查看　<input type="checkbox" name="13" value="1"<%if fla13=1 then%> checked<%end if%> class=radio>信息推荐　<input type="checkbox" name="14" value="1"<%if fla14=1 then%> checked<%end if%> class=radio>信息置顶　<input type="checkbox" name="15" value="1"<%if fla15=1 then%> checked<%end if%> class=radio>信息编辑　<input type="checkbox" name="16" value="1"<%if fla16=1 then%> checked<%end if%> class=radio>信息审核　<input type="checkbox" name="17" value="1"<%if fla17=1 then%> checked<%end if%> class=radio>信息删除</td>
			  </tr> 
  	  
			  <tr>
			    <td height="29" class=title>
				◆分类管理</td>
			  </tr> 
  	  
			  <tr class="tdbg">
			    <td height="30">
				<input type="checkbox" name="18" value="1"<%if fla18=1 then%> checked<%end if%> class=radio>信息分类　<input type="checkbox" name="19" value="1"<%if fla19=1 then%> checked<%end if%> class=radio>黄页分类　<input type="checkbox" name="20" value="1"<%if fla20=1 then%> checked<%end if%> class=radio>地区分类</td>
			  </tr> 
  	  
			  <tr>
			    <td height="30" class=title>
				◆常规管理</td>
			  </tr> 
  	  
			  <tr>
			    <td height="30" class="tdbg">
				<input type="checkbox" name="21" value="1"<%if fla21=1 then%> checked<%end if%> class=radio>反馈管理　<input type="checkbox" name="22" value="1"<%if fla22=1 then%> checked<%end if%> class=radio>链接管理　<!--<input type="checkbox" name="23" value="1"<%if fla23=1 then%> checked<%end if%> class=radio>反馈管理　--><input type="checkbox" name="24" value="1"<%if fla24=1 then%> checked<%end if%> class=radio>公司简介　<input type="checkbox" name="25" value="1"<%if fla25=1 then%> checked<%end if%> class=radio>联系方式　<input type="checkbox" name="26" value="1"<%if fla26=1 then%> checked<%end if%> class=radio>IP管理　<input type="checkbox" name="27" value="1"<%if fla27=1 then%> checked<%end if%> class=radio>广告管理</td>
			  </tr>        <tr class="tdbg">
          <td height="12" align="right">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end if
rdsInfo.Close
set rdsInfo = nothing
end sub
sub editsysuser
	Dim intUserID
	Dim rdsUser
	Dim sqlUser
	
	intUserID = Request("ID")
	
	set rdsUser = Server.CreateObject("ADODB.Recordset")
	sqlUser = "Select * From Sys_Account Where UserKey = "& intUserID
	rdsUser.Open sqlUser,Conn
	if not rdsUser.EOF then
%>
	<script language="javascript">
	<!-- Begin validation form script
	//检验表单的合法性
	function EditUser() {
		if (document.EditUserForm.Account.value == "") {
			alert("\请填写用户名!");
			document.EditUserForm.Account.focus();
		}
		else if (document.EditUserForm.PassWord.value == "") {
			alert("\请填写用户管理密码!");
			document.EditUserForm.PassWord.focus();
		}
		else if (document.EditUserForm.UserLevel.value == "#") {
			alert("\请选择用户身份!");
			document.EditUserForm.UserLevel.focus();
		}
		else {
	        return true;
	    }
	    return false;
	}
	// End of validation form script -->
	</script>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>编辑用户</strong></td>
  </tr><form method="post" action="?bbaction=saveeditsysuser" name="AddForm" OnSubmit="return EditUser()">
  <tr class="tdbg"><input type="hidden" name="ID" value="<% = intUserID%>">
    <td width="12%" height="23" align="right">用户名：</td>
    <td height="23" width="87%"><input type="text" name="Account" size="15" class="face" value="<% = rdsUser("Account")%>"></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">密&nbsp; 码：</td>
    <td height="23" width="87%"><input type="password" name="PassWord" size="15" class="face">不改请留空</td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">身&nbsp; 份：</td>
    <td height="23" width="87%"><select name="UserLevel" size="1" class="face">
			<option value="#">选择身份</option>
			<option value="1">普通用户</option>
			<option value="3" selected>管 理 员</option>
	      </select></td>
  </tr>  
        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end if
end sub
sub adduser
%>
<script language="javascript">
	<!-- Begin validation form script
	//检验表单的合法性
	function AddUser() {
		if (document.AddUserForm.Account.value == "") {
			alert("\请填写用户名!");
			document.AddUserForm.Account.focus();
		}
		else if (document.AddUserForm.PassWord.value == "") {
			alert("\请填写用户管理密码!");
			document.AddUserForm.PassWord.focus();
		}
		else if (document.AddUserForm.UserLevel.value == "#") {
			alert("\请选择用户身份!");
			document.AddUserForm.UserLevel.focus();
		}
		else {
	        return true;
	    }
	    return false;
	}
	// End of validation form script -->
	</script><br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>添加管理员</strong></td>
  </tr><form method="post" action="?bbaction=saveuser" OnSubmit="return AddUser()" name="AddUserForm">
  <tr class="tdbg"><input type="hidden" name="ID" value="<% = intUserID%>">
    <td width="12%" height="23" align="right">用户名：</td>
    <td height="23" width="87%"><input type="text" name="Account" size="15" class="face"></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="25" align="right">密&nbsp; 码：</td>
    <td height="25" width="87%"><input type="password" name="PassWord" size="15" class="face"></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="22" align="right">身&nbsp; 份：</td>
    <td height="22" width="87%"><select name="UserLevel" size="1" class="face">
			<option value="#">选择身份</option>
			<option value="1">普通用户</option>
			<option value="3" selected>管 理 员</option>
	      </select></td>
  </tr>  
        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub
sub saveuser
	if Session("intUserLevel") > 2 then
		if not SearchFieldValue("Sys_Account","Account",Request.Form("Account")) then
			Dim rdsAddSysUser
	
			set rdsAddSysUser = Server.CreateObject("ADODB.Recordset")
			rdsAddSysUser.Open "Sys_Account",Conn,3,3
	
			rdsAddSysUser.AddNew
			rdsAddSysUser("Account") = Trim(Request.Form("Account"))
			rdsAddSysUser("PassWord") = md5(Trim(Request.Form("PassWord")),16)
			rdsAddSysUser("State") = 0
			rdsAddSysUser("UserLevel") = Trim(Request.Form("UserLevel"))
			rdsAddSysUser("CreateTime") =now()
			
			rdsAddSysUser.Update
			rdsAddSysUser.Close
			set rdsAddSysUser = nothing
	
response.redirect "SysUser.asp"
		else
			Response.Write "该用户已经存在!"
		end if	
	else
		Response.Write "没有操作权限!"
	end if	
end sub

%>