SysAdmin_Add.asp
上传用户:jisenq
上传日期:2014-06-29
资源大小:7216k
文件大小:14k
源码类别:

数据库编程

开发平台:

ASP/ASPX

  1. <% Option Explicit %>
  2. <!--#include file="../FS_Inc/Const.asp" -->
  3. <!--#include file="../FS_InterFace/MF_Function.asp" -->
  4. <!--#include file="../FS_Inc/Function.asp" -->
  5. <!--#include file="../FS_Inc/Md5.asp" -->
  6. <!--#include file="../FS_Inc/Cls_Cache.asp" -->
  7. <%
  8. Dim Conn,strShowErr
  9. MF_Default_Conn
  10. MF_Session_TF
  11. if not MF_Check_Pop_TF("MF_Pop") then Err_Show
  12. Dim p_name_str,p_pwd_str,p_truename_str,p_email_str,p_homepage_str,p_qq_str,p_sex_num,p_lock_num,p_child_num,p_style_num,p_selfintro_str,p_Admin_OnlyLogin
  13. if Trim(Request.Form("act")) <>"" then
  14. p_name_str = NoSqlHack(Request.Form("name"))
  15. p_pwd_str = NoSqlHack(Request.Form("pwd"))
  16. p_truename_str = NoSqlHack(Request.Form("truename"))
  17. p_email_str = NoSqlHack(Request.Form("email"))
  18. p_homepage_str = NoSqlHack(Request.Form("homepage"))
  19. p_qq_str = NoSqlHack(Request.Form("qq"))
  20. p_sex_num = NoSqlHack(Request.Form("sex"))
  21. p_lock_num = NoSqlHack(Request.Form("lock"))
  22. p_child_num = NoSqlHack(Request.Form("createchild"))
  23. p_style_num = cint(Request.Form("style"))
  24. p_selfintro_str = NoSqlHack(Request.Form("selfintro"))
  25. p_Admin_OnlyLogin = NoSqlHack(Request.Form("Admin_OnlyLogin"))
  26. Dim p_RsAdmin_add
  27. Set p_RsAdmin_add = CreateObject(G_FS_RS)
  28. if Request.Form("act")="add" then
  29. p_RsAdmin_add.open "select * from FS_MF_Admin where Admin_Name ='"& p_name_str&"'",Conn,3,3
  30. if Not p_RsAdmin_add.eof then
  31. strShowErr = "<li>管理员重名,请重新输入</li>"
  32. Response.Redirect("Error.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
  33. Response.end
  34. Else
  35. p_RsAdmin_add.AddNew
  36. p_RsAdmin_add("Admin_Name") = p_name_str
  37. p_RsAdmin_add("Admin_Pass_Word") = md5(p_pwd_str,16)
  38. p_RsAdmin_add("Admin_Parent_Admin") = Session("Admin_Name")
  39. p_RsAdmin_add("Admin_Is_Super") = 0
  40. End if
  41. Else
  42. p_RsAdmin_add.open "select * from FS_MF_Admin where id ="&clng(Request.Form("id")),Conn,3,3
  43. if Trim(p_pwd_str)<>"" then
  44. p_RsAdmin_add("Admin_Pass_Word") = md5(p_pwd_str,16)
  45. End if
  46. End if
  47. p_RsAdmin_add("Admin_Real_Name") = p_truename_str
  48. p_RsAdmin_add("Admin_Email") = p_email_str
  49. p_RsAdmin_add("Admin_Home_Page") = p_homepage_str
  50. p_RsAdmin_add("Admin_Self_Intro") = p_selfintro_str
  51. p_RsAdmin_add("Admin_QQ") = p_qq_str
  52. p_RsAdmin_add("Admin_Sex") = p_sex_num
  53. p_RsAdmin_add("Admin_Is_Locked") = p_lock_num
  54. p_RsAdmin_add("Admin_Add_Admin") = p_child_num
  55. p_RsAdmin_add("Admin_Style_Num") = p_style_num
  56. if p_Admin_OnlyLogin <>"" then
  57. p_RsAdmin_add("Admin_OnlyLogin") = 1
  58. Else
  59. p_RsAdmin_add("Admin_OnlyLogin") = 0
  60. End if
  61. p_RsAdmin_add.Update
  62. '创建管理员图片目录
  63. if Request.Form("act")="add" then
  64. Dim p_FSO
  65. Set p_FSO = Server.CreateObject(G_FS_FSO)
  66. p_FSO.CreateFolder(Server.MapPath(".."& G_UP_FILES_DIR &"adminFiles") & "" & p_name_str)
  67. set p_FSO = nothing
  68.     End if
  69. p_RsAdmin_add.close : Set p_RsAdmin_add=Nothing
  70. strShowErr = "<li>操作成功!</li>"
  71. Response.Redirect("Success.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=SysAdmin_List.asp")
  72. Response.end
  73. End if
  74. Dim obj_admin_Rs,p_act
  75. Dim p_Admin_Name,p_Admin_Pass_Word,p_Admin_Parent_Admin,p_Admin_Is_Super,p_Admin_Real_Name,p_Admin_Is_Locked,p_Admin_Pop_List,p_Admin_Email
  76. Dim p_Admin_Home_Page,p_Admin_Self_Intro,p_Admin_QQ,p_Admin_Sex,p_Admin_Add_Admin,p_Admin_Login_Num,p_Admin_Reg_Time,p_Admin_Style_Num,p_id
  77. if Request.QueryString("Action") = "edit" then
  78. Set obj_admin_Rs = server.CreateObject(G_FS_RS)
  79. obj_admin_Rs.Open "Select ID,Admin_Name,Admin_Pass_Word,Admin_Parent_Admin,Admin_Is_Super,Admin_Real_Name,Admin_Is_Locked,Admin_Pop_List,Admin_Email,Admin_Home_Page,Admin_Self_Intro,Admin_QQ,Admin_Sex,Admin_Add_Admin,Admin_Login_Num,Admin_Reg_Time,Admin_Style_Num,Admin_OnlyLogin from FS_MF_Admin where id="&NoSqlHack(Request.QueryString("AdminID")),Conn,1,3
  80. if obj_admin_Rs("Admin_Name")<>session("Admin_Name") then
  81. if session("Admin_Is_Super")<>1 then
  82. if obj_admin_rs("Admin_Is_Super")=1 then
  83. strShowErr = "<li>您不能修改系统管理员!</li>"
  84. Response.Redirect("Error.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=SysAdmin_List.asp")
  85. Response.end
  86. end if
  87. if obj_admin_rs("Admin_Add_Admin")<>session("Admin_Name") then
  88. strShowErr = "<li>此管理员的上级管理员不是您,您不能修改此管理员!</li>"
  89. Response.Redirect("Error.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=SysAdmin_List.asp")
  90. Response.end
  91. end if
  92. end if
  93. end if
  94. p_act = "Edit"
  95. p_id = obj_admin_Rs("ID")
  96. p_Admin_Name = obj_admin_Rs("Admin_Name")
  97. p_Admin_Pass_Word = obj_admin_Rs("Admin_Pass_Word")
  98. p_Admin_Parent_Admin = obj_admin_Rs("Admin_Parent_Admin")
  99. p_Admin_Real_Name = obj_admin_Rs("Admin_Real_Name")
  100. p_Admin_Is_Locked = obj_admin_Rs("Admin_Is_Locked")
  101. p_Admin_Pop_List = obj_admin_Rs("Admin_Pop_List")
  102. p_Admin_Email = obj_admin_Rs("Admin_Email")
  103. p_Admin_Home_Page = obj_admin_Rs("Admin_Home_Page")
  104. p_Admin_Self_Intro = obj_admin_Rs("Admin_Self_Intro")
  105. p_Admin_QQ = obj_admin_Rs("Admin_QQ")
  106. p_Admin_Sex = obj_admin_Rs("Admin_Sex")
  107. p_Admin_Add_Admin = obj_admin_Rs("Admin_Add_Admin")
  108. p_Admin_Login_Num = obj_admin_Rs("Admin_Login_Num")
  109. p_Admin_Reg_Time = obj_admin_Rs("Admin_Reg_Time")
  110. p_Admin_Style_Num = obj_admin_Rs("Admin_Style_Num")
  111. p_Admin_OnlyLogin = obj_admin_Rs("Admin_OnlyLogin")
  112. obj_admin_Rs.close:set obj_admin_Rs = nothing
  113. Else
  114. p_act = "add"
  115. p_Admin_Parent_Admin = Session("Admin_Name")
  116. Dim obj_Add_Admin_Pop_rs
  117. Set obj_Add_Admin_Pop_rs = server.CreateObject(G_FS_RS)
  118. obj_Add_Admin_Pop_rs.open "select Admin_Add_Admin,Admin_Is_Super from FS_MF_Admin where Admin_Name ='"&  session("Admin_Name") &"'",Conn,1,3
  119. if obj_Add_Admin_Pop_rs("Admin_Is_Super")=0 then
  120. if obj_Add_Admin_Pop_rs("Admin_Add_Admin") = 0 then
  121. strShowErr = "<li>您没权限建立管理员</li>"
  122. Response.Redirect("Error.asp?ErrCodes="&Server.URLEncode(strShowErr)&"&ErrorUrl=")
  123. Response.end
  124. End if
  125. End if
  126. obj_Add_Admin_Pop_rs.close:set obj_Add_Admin_Pop_rs = nothing
  127. End if
  128. %>
  129. <html xmlns="http://www.w3.org/1999/xhtml">
  130. <HEAD>
  131. <TITLE>FoosunCMS</TITLE>
  132. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
  133. </HEAD>
  134. <script language="JavaScript" src="../FS_Inc/PublicJS.js" type="text/JavaScript"></script>
  135. <script language="JavaScript" src="../FS_Inc/Prototype.js" type="text/JavaScript"></script>
  136. <script language="JavaScript" src="../FS_Inc/CheckJs.js" type="text/JavaScript"></script>
  137. <link href="images/skin/Css_<%=Session("Admin_Style_Num")%>/<%=Session("Admin_Style_Num")%>.css" rel="stylesheet" type="text/css">
  138. <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=yes>
  139. <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
  140.   <tr class="xingmu">
  141.     <td class="xingmu">管理员管理</td>
  142.   </tr>
  143.   <tr class="hback">
  144.     <td><a href="SysAdmin_List.asp">管理员首页</a> | <a href="SysAdmin_List.asp?Is_Super=1">超级管理员</a> | <a href="SysAdmin_List.asp?islock=1">锁定的管理员</a> | <a href="SysAdmin_List.asp?islock=0">开放的管理员</a></td>
  145.   </tr>
  146. </table>
  147. <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
  148.   <form action="" method="post" name="newadmin" id="newadmin" onSubmit="return checkinput();">
  149.     <tr class="hback">
  150.       <td colspan="2" class="xingmu">添加修改管理员管理员</td>
  151.     </tr>
  152.     <tr class="hback">
  153.       <td align="right">父管理员</td>
  154.       <td><input name="Admin_Parent_Admin" type="text" id="Admin_Parent_Admin" value="<%=p_Admin_Parent_Admin%>" size="60" maxlength="16" readonly>
  155.         0表示顶级管理员,上级没管理员</td>
  156.     </tr>
  157.     <tr class="hback">
  158.       <td width="140" align="right">管理员帐号</td>
  159.       <td><input name="name" type="text" onFocus="Do.these('name',function(){return CheckContentLen('name','span_name','3-20')})" onKeyUp="Do.these('name',function(){return CheckContentLen('name','span_name','3-20')})" value="<% = p_Admin_Name%>" size="60" maxlength="16" <%if Request.QueryString("Action") = "edit" then response.Write("Readonly")%> />
  160.         <span id="span_name"></span>
  161.         <input name="ID" type="hidden" id="ID" value="<% = p_id %>">
  162.       </td>
  163.     </tr>
  164.     <% If Session("Admin_Is_Super")=1 Then %>
  165.     <tr class="hback">
  166.       <td width="140" align="right">密码</td>
  167.       <td><input name="pwd" type="password" onFocus="Do.these('pwd',function(){return CheckContentLen('pwd','span_pwd','6-16')})" onKeyUp="Do.these('pwd',function(){return CheckContentLen('pwd','span_pwd','6-16')})" value="" size="60" maxlength="16" />
  168.         <span id="span_pwd"></span> 不修改请保持为空 </td>
  169.     </tr>
  170. <tr class="hback">
  171.       <td width="140" align="right">重复密码</td>
  172.       <td><input name="Rpwd" type="password" onFocus="Do.these('Rpwd',function(){return CheckContentLen('Rpwd','span_Rpwd','6-16')})" onKeyUp="Do.these('Rpwd',function(){return CheckContentLen('Rpwd','span_Rpwd','6-16')})" value="" size="60" maxlength="16" />
  173.         <span id="span_Rpwd"></span> 不修改请保持为空 </td>
  174.     </tr>
  175.     <% End If %>
  176.     <tr class="hback">
  177.       <td width="140" align="right">真实姓名</td>
  178.       <td><input name="truename" type="text" onFocus="Do.these('truename',function(){return isEmpty('truename','span_truename')})" onKeyUp="Do.these('truename',function(){return isEmpty('truename','span_truename')})" value="<% = p_Admin_Real_Name%>" size="60" maxlength="10" />
  179.         &nbsp;<span id="span_truename"></span> </td>
  180.     </tr>
  181.     <tr class="hback">
  182.       <td width="140" align="right">邮箱地址</td>
  183.       <td><input name="email" type="text" onFocus="Do.these('email',function(){return checkMail('email','span_email')})" onKeyUp="Do.these('email',function(){return checkMail('email','span_email')})" value="<% = p_Admin_Email%>" size="60" maxlength="50" />&nbsp;<span id="span_email"></span>
  184.       </td>
  185.     </tr>
  186.     <tr class="hback">
  187.       <td width="140" align="right">主页</td>
  188.       <td><input name="homepage" type="text" value="<% = p_Admin_Home_Page%>" size="60" maxlength="100" />
  189.       </td>
  190.     </tr>
  191.     <tr class="hback">
  192.       <td width="140" align="right">管理员QQ</td>
  193.       <td><input name="qq" type="text" value="<% = p_Admin_QQ%>" size="60" maxlength="16" />
  194.       </td>
  195.     </tr>
  196.     <tr class="hback">
  197.       <td width="140" align="right">性别</td>
  198.       <td><select name="sex" style="width:100">
  199.           <option value="1" <%if p_Admin_Sex=1 then response.Write("selected")%>>男</option>
  200.           <option value="0" <%if p_Admin_Sex=0 then response.Write("selected")%>>女</option>
  201.         </select>
  202.       </td>
  203.     </tr>
  204.     <tr class="hback">
  205.       <td width="140" align="right">是否被锁定</td>
  206.       <td><select name="lock" style="width:100">
  207.           <option value="0" <%if p_Admin_Is_Locked=0 then response.Write("selected")%>>不锁定</option>
  208.           <option value="1"<%if p_Admin_Is_Locked=1 then response.Write("selected")%>>锁定</option>
  209.         </select>
  210.       </td>
  211.     </tr>
  212.     <tr class="hback">
  213.       <td width="140" align="right">新建下级管理员</td>
  214.       <td><select name="createchild" style="width:100">
  215.           <option value="1" <%if p_Admin_Add_Admin=1 then response.Write("selected")%>>可以</option>
  216.           <option value="0" <%if p_Admin_Add_Admin=0 then response.Write("selected")%>>不可以</option>
  217.         </select>
  218.       </td>
  219.     </tr>
  220.     <tr class="hback">
  221.       <td width="140" align="right">后台使用风格</td>
  222.       <td><select name="style" style="width:100">
  223.           <option value="3" <%if p_Admin_Style_Num=3 then response.Write("selected")%>>蓝色海洋</option>
  224.           <option value="1" <%if p_Admin_Style_Num=1 then response.Write("selected")%>>默认风格</option>
  225.           <option value="2" <%if p_Admin_Style_Num=2 then response.Write("selected")%>>银色风格</option>
  226.           <option value="4" <%if p_Admin_Style_Num=4 then response.Write("selected")%>>浪漫咖啡</option>
  227.           <option value="5" <%if p_Admin_Style_Num=5 then response.Write("selected")%>>青青河草</option>
  228.         </select>
  229.       </td>
  230.     </tr>
  231.     <tr class="hback">
  232.       <td align="right">只允许一个人登陆</td>
  233.       <td><input name="Admin_OnlyLogin" type="checkbox" id="Admin_OnlyLogin" value="1" <%if p_Admin_OnlyLogin=1 then response.Write("checked")%>>
  234.         是</td>
  235.     </tr>
  236.     <tr class="hback">
  237.       <td width="140" align="right">自我介绍</td>
  238.       <td><textarea name="selfintro" cols="60" rows="6"><% = p_Admin_Self_Intro%>
  239. </textarea>
  240.       </td>
  241.     </tr>
  242.     <tr class="hback">
  243.       <td align="right">&nbsp;</td>
  244.       <td><input type="submit" name="Submit3" value=" 保存 ">
  245.         <input type="reset" name="Submit4" value=" 重置 ">
  246.         <input name="act" type="hidden" id="act" value="<% = p_act %>"></td>
  247.     </tr>
  248.   </form>
  249. </table>
  250. </body>
  251. </html>
  252. <%
  253. Conn.Close
  254. Set Conn = Nothing
  255. %>
  256. <script language="JavaScript" type="text/JavaScript">
  257. function checkinput(){
  258. if($("name").value=='')
  259. {
  260. alert('请填写管理员帐号');
  261. newadmin.name.focus();
  262. return false;
  263. }
  264. if($("name").value.length>20||$("name").value.length<3)
  265. {
  266. alert('帐户长度为3-20');
  267. $("name").focus();
  268. return false;
  269. }
  270. <% If Session("Admin_Is_Super")=1 Then %>
  271. if ($("pwd").value!=""){
  272. if ($("pwd").value.length>16||$("pwd").value.length<6)
  273. {
  274. alert('密码长度为6-18');
  275. $("pwd").focus();
  276. return false;
  277. }else if ($("Rpwd").value.length>16||$("Rpwd").value.length<6){
  278. alert('密码长度为6-18');
  279. $("Rpwd").focus();
  280. return false;
  281. }else if ($("pwd").value!=$("Rpwd").value){
  282. alert('两次密码不一致');
  283. $("Rpwd").focus();
  284. return false;
  285. }
  286. }
  287. <% End If %>
  288. if($("email").value!=''){
  289. if (!checkMail('email','')){
  290. alert('请填写正确的Email地址');
  291. $("email").focus();
  292. return false;
  293. }
  294. }
  295. if($("truename").value=='')
  296. {
  297. alert('请填写真实姓名');
  298. $("truename").focus();
  299. return false;
  300. }
  301. }
  302. </script>