<%On Error Resume Next%>
<!--#include file="conn.asp"-->
<!--#include file="chk_logs.asp"-->
<!--#include file="zjy_md6.asp"-->
<%if session("AdminName")="" then
response.Write "<script LANGUAGE='javascript'>alert('网络超时或者您还没有登录请登录');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>1then
response.Write "<script language=javascript>alert('您没有此项目管理权限！！');window.location.href='manageadmin.asp';</script>"
response.End
end if
end if

function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
dim action,bookid
'bookid=request.QueryString("id")
action=request.QueryString("action")

select case action

case "add1"
if request("username")=""then
response.Write "<script language=javascript>alert('请填写用户名!！');window.location.href='manageadmin.asp';</script>"
response.End
end if
if request("password")=""then
response.Write "<script language=javascript>alert('请正确填写密码!！');window.location.href='manageadmin.asp';</script>"
response.End
end if
if request("adduser")=""then
response.Write "<script language=javascript>alert('请选择管理权限!！');window.location.href='manageadmin.asp';</script>"
response.End
end if
dim flag,tri,username

username=replace(trim(request("username")) ,"'","")
tri=trim(request("adduser"))
if tri="admin" then
flag=1
end if 
if tri="qiantai" then
flag=2
end if
if tri="putong" then
flag=3
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_admin where admin='"&username&"'",conn,1,3
if not(rs.bof and rs.eof) then
response.Write "<script language=javascript>alert('您添加的用户已经成在!！');window.location.href='manageadmin.asp';</script>"
response.End
else
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_admin ",conn,1,3
rs.AddNew
rs("admin")=replace(trim(request("username")) ,"'","")
rs("password")=zjy_md6(replace(trim(request("password")),"'",""))
rs("flag")=flag
rs.Update
response.Write "<script language=javascript>alert('添加成功！');window.location.href='renpassword.asp';</script>"
response.End
end if
rs.Close
set rs=nothing

case "del"
dim id
id=request("selectadmin")
if id<>"" then
conn.execute "delete from shop_admin where adminid in ("&id&")"
response.Write "<script language=javascript>alert('删除成功！');window.location.href='renpassword.asp';</script>"
response.End
	'conn.close
	'set conn=nothing

end if

case "exit"
dim xname,xpwd,trii
trii=replace(trim(request("menu1")) ,"'","")
xpwd=replace(trim(request("textfield2")) ,"'","")
xname=replace(trim(request("textfield")) ,"'","")
adminid=replace(trim(request("adminid")) ,"'","")
if trii="admin" then
flag=1
end if 
if tri="qiantai" then
flag=2
end if
if trii="putong" then
flag=3
end if
if trii="" then
flag=3
end if
if xpwd<>""then
'response.Write "<br>加密前:"&xpwd
'response.End()
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_admin where adminid="&adminid,conn,1,3
rs("admin")=xname
rs("password")=zjy_md6(xpwd)
rs("flag")=flag
'response.Write "<br>adminid="&adminid
'response.Write "<br>加密后:"&xpwd  
'response.Write flag
'response.end
rs.Update
rs.Close
'response.write "<br>after:"
'response.write xx
'response.end 




set rs=nothing
response.Write "<script language=javascript>alert('修改成功！');window.location.href='renpassword.asp';</script>"
response.End
else
response.Write "<script language=javascript>alert('请填写您要修改的密码！nnnnnn');window.location.href='renpassword.asp';</script>"
response.End
end if

end select

%>

