<!--#include file="conn.asp"-->
<!--#include file="inc/cook1.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="top.asp"-->
<%
id=request("id")
username=ReplaceConstChar(trim(request("username")))
user=ReplaceConstChar(trim(request("user")))
admin2=ReplaceConstChar(trim(request("admin2")))
Pingname=split(Const_Pingname,"|")
for i=0 to UBound(Pingname)
if instr(user,Pingname(i)) then
response.write"<script>alert('此用户名可能被禁止使用，请重新选择！');history.go(-1);</script>"
response.end
end if
if instr(admin2,Pingname(i)) then
response.write"<script>alert('此用户名可能被禁止使用，请重新选择！');history.go(-1);</script>"
response.end
end if
if instr(com_xxx_admin,Pingname(i)) then
response.write"<script>alert('此用户名可能被禁止使用，请重新选择！');history.go(-1);</script>"
response.end
end if
next
select case action
'//修改数据*****************************************************************
case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from com_admin where adminid="&id,conn,1,3
Set rs_new=Server.CreateObject("Adodb.RecordSet")
rs_new.open "Select * from com_admin Where com_xxx_admin='" &user&"' and adminid <> "&id&"",conn,1,3
if not (rs_new.bof and rs_new.EOF) then
response.Write "<script LANGUAGE='javascript'>alert('修改失败，帐号" & user & "已经存在！');location.href=""db_admin.asp"";</script>"
rs_new.close
set rs_new=nothing
else
rs("com_xxx_admin")=user
if trim(request("pass"))<>"" then
randostr=rando(6)
password=md5(trim(request("pass")))
password=password&randostr
password=md5(password)
rs("com_xxx_pass")=password
rs("randchar")=randostr
end if
rs("admin")=int(request("flag"))
rs.Update
rs.Close
set rs=nothing

response.Write "<script language=javascript>alert('修改成功！');history.go(-1);</script>"
response.Redirect "db_admin.asp"
end if
'//添加新数据******************************************************************88
case "add"
Set rs_new=Server.CreateObject("Adodb.RecordSet")
rs_new.open "Select * from com_admin Where com_xxx_admin='" & admin2 & "'",conn,1,3
if not (rs_new.bof and rs_new.EOF) then
response.Write "<script LANGUAGE='javascript'>alert('添加失败，帐号" & admin2 & "已经存在！');location.href=""db_admin.asp"";</script>"
rs_new.close
set rs_new=nothing
else
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from com_admin",conn,1,3
rs.addnew
rs("com_xxx_admin")=admin2
randostr=rando(6)
password=md5(trim(request("password2")))
password=password&randostr
password=md5(password)
rs("com_xxx_pass")=password
rs("randchar")=randostr
rs("admin")=int(request("flag2"))
rs("vip")=0
rs("flag")="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
rs.update
rs.close
set rs=nothing
response.Write "<script language=javascript>alert('添加成功！');history.go(-1);</script>"
response.Redirect "db_admin.asp"
end if
'//删除数据**************************************************************************************
case "del"
if username=session("admin_xyz") then 
response.Write "<script LANGUAGE='javascript'>alert('删除失败，此帐号处于登陆状态，不能删除！');location.href=""db_admin.asp"";</script>"
else
conn.execute ("delete from com_admin where com_xxx_admin='"&username&"'")

response.Redirect "db_admin.asp"
end if
end select
%>