<% 
AdminID= skweboa.ChkNumeric(skweboa.S("AdminID"))
action = Request.QueryString("A") 
Select Case action
			Case "edit"
				Call edit()
			Case "editsave"
				Call save()	
					Case "Add"
				Call Add()	
						Case "Addsave"
				Call save()
			 Case Else
				Call Main()						
	End Select
	

   IF Request.QueryString("action") = "Del" Then
   If Not skweboa.SK_CHKadministrator() Then  Call skweboa.SK_window("您没有权限操作",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","2","3")	  End If
		Dim AdminID ,Sqllog
		AdminID = skweboa.Return_to_numerical(Request.QueryString("AdminID"))
		IF AdminID  <> 1 Then
			Sqllog = "Delete From admin_skweb Where ID=" & AdminID
			Conn.Execute (Sqllog)		
			set conn=nothing
		Else
		End If
 		   response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
 		Response.end
	End IF
	
	IF Request.QueryString("action") = "Lock" Then
   If Not skweboa.SK_CHKadministrator() Then  Call skweboa.SK_window("您没有权限操作",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","2","3")	  End If
		AdminID = skweboa.Return_to_numerical(Request.QueryString("AdminID"))
		Conn.execute("Update Admin_skweb set Locked=1 where ID ="&AdminID&"")
		set conn=nothing
 	    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
		Response.end
	End IF
	
	
	IF Request.QueryString("action") = "Unlock" Then
   If Not skweboa.SK_CHKadministrator() Then  Call skweboa.SK_window("您没有权限操作",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","2","3")	  End If	
		AdminID = skweboa.Return_to_numerical(Request.QueryString("AdminID"))
		Conn.execute("Update Admin_skweb set Locked=0 where ID ="&AdminID&"")
		set conn=nothing
 	    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
		Response.end
	End IF
	
	
 	Sub save()
			Dim Admin_Name ,PassWord,RPassWord,Locked,Tel,Email,qq,msn,aliww,skype,Description,Sex,RealName,TempRs,AdminRS,AdminSql,AdminID
			Admin_Name = skweboa.C_SKCMSSQL(Request.Form("Admin_Name"))
			PassWord = Request.Form("PassWord")
			RPassWord = Request.Form("RPassWord")	
			Description = skweboa.C_SKCMSSQL(Request.Form("Description"))	
			IF Trim(PassWord) <> Trim(RPassWord) Then
				ShowErr = "2次输入的密码不一致! "
				 Call skweboa.SK_window(ShowErr,"","")
				Response.end
			End IF


IF Request.QueryString("A") = "Addsave" Then
			 If Not skweboa.SK_CHKadministrator() Then '超级管理员检测
				Call skweboa.SK_window("您没有权限操作","","3","3")
			 End If 
			IF Admin_Name <> "" Then
				IF Len(Admin_Name) >= 100 Then
					Call skweboa.SK_window("管理员名称不能超过50个字符","","3","3")
					Response.end
				End IF
			Else
					 Call skweboa.SK_window("请输入管理员名称","","3","3")
					Response.end
          	End if	

   If Not skweboa.SK_CHKadministrator() Then  Call skweboa.SK_window("您没有权限操作",""&MyDbPath&"SKCMS/dialog.asp?action=clos","2","3")	  End If
			Set TempRs = Conn.Execute("Select Admin_Name from Admin_skweb where Admin_Name='" & Admin_Name & "'")
			IF Not TempRs.Eof Then
                    Call skweboa.SK_window("数据库中已存在该管理员名称","","2","3")
					Response.end
	               End IF			
			      Set AdminRS = Server.CreateObject("adodb.recordset")
				  AdminSql = "select * from Admin_skweb"
				  AdminRS.Open AdminSql, Conn, 1, 3
				  AdminRS.AddNew
				  AdminRS("AddDate") = Now
				  AdminRS("Admin_Name") = Admin_Name
				  AdminRS("PassWord")=MD5(RPassWord,1)
				  AdminRS("Locked") = Locked
				  AdminRS("RealName") = RealName			  
				  AdminRS("Description") = Description
				  AdminRS("SuperTF") = 0
				  AdminRS("LoginTime") = Now
				  AdminRS("LoginIP") = skweboa.SK_GetIP()
				  AdminRS.Update
				  AdminRS.Close:Set AdminRS = Nothing		
 
 				 ShowErr = "添加管理员成功"
				 
				  Call skweboa.SK_window(ShowErr,""&MyDbPath&"SKCMS/dialog.asp?action=closmain","2","3")
			    Response.end
ELSE		  
			AdminID = skweboa.Return_to_numerical(Request("AdminID"))
 
				  Set AdminRS = Server.CreateObject("adodb.recordset")
				  AdminSql = "select * from Admin_skweb Where ID="&AdminID
				  AdminRS.Open AdminSql, Conn, 1, 3
				  IF RPassWord <> "" Then  AdminRS("PassWord")=MD5(RPassWord,1)
				  AdminRS.Update
				  
	if 	Request.Cookies(SkcmsCookies)("AdminName")=AdminRS("Admin_Name")  then  
				Response.Cookies(SkcmsCookies)("AdminName") = AdminRS("Admin_Name")'更新
				Response.Cookies(SkcmsCookies)("AdminPassword") = AdminRS("PassWord")
				Response.Cookies(SkcmsCookies)("AdminID") = AdminRS("ID")
				If AdminRS("SuperTF")=1 Then Response.Cookies(SkcmsCookies)("SuperTF")=1
				Response.Cookies(SkcmsCookies)("Purview") = AdminRS("Purview")
				Response.Cookies(SkcmsCookies)("skweb_Other") = AdminRS("skweb_Other")
				Response.Cookies(SkcmsCookies)("HQQXLX") = AdminRS("skweboa_QXLX")
	end if
				Call  skweboa.SK_log(server.MapPath(""&MyDbPath&"SKCMS/log/adminlog.cs"),""  & now() &"  - ["&Request.Cookies(SkcmsCookies)("AdminName")&"]   IP: "&skweboa.SK_GetIP()&"  修改管理员信息 "&AdminRS("Admin_Name")&"  <br><br>",true) 	
			    AdminRS.Close:Set AdminRS = Nothing			
			    ShowErr = "恭喜您修改成功!"
 
END IF
 
 
			    Call skweboa.SK_window(ShowErr,""&MyDbPath&"SKCMS/dialog.asp?action=clos","2","3")
			    Response.end
		
	 
    end sub 
	 %>