<%@ LANGUAGE=VBScript.Encode codepage ="936" %>
<%if session("adminname")="" then
response.Redirect "../login.asp"
end if%>
<%
Response.Buffer = True
Response.Expires = 0
Response.CacheControl = "Private"
Sub Msg (v)
 Response.Write "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><meta http-equiv='pragma' content='no-cache'><style type=text/css>body{color:black;font-family:宋体;font-size:9pt;background-color:buttonface;border-bottom:medium none;border-left:medium none;border-right:medium none;border-top:medium none;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px}</style></head><body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0>"
 Response.Write "<script Language=JavaScript>alert('" & v & "');history.go(-1);</script></body></html>"
 Response.End
End Sub
nickname=Session("hxf_u_nickname")
grade=Int(Session("hxf_u_grade"))
inthechat=Session("hxf_u_inthechat")
userip=Request.ServerVariables("REMOTE_ADDR")
If nickname = "" Then Msg "不在聊天室中，不能定义权限。"
if Session("hxf_u_inthechat")<>"1" and nickname<>"聊天室管理员" then Msg "不在聊天室中，不能定义权限。"
If grade <> 12 or Int(Session("ipbt"))<>1 Then Msg "你没有定义权限的权利！"
grade = Request.QueryString("grade")
If grade = "" Or Not IsNumeric(grade) Then Msg "指定的级别错误！"
grade = Int(grade)
If grade < 1 Or grade > 11 Then Msg "级别必须是 1 - 11 的正整数！"
Dim ng(30)
ng(0) = Request.Form("x1")
ng(1) = Request.Form("x2")
ng(2) = Request.Form("x3")
ng(3) = Request.Form("x4")
ng(4) = Request.Form("x5")
ng(5) = Request.Form("x6")
ng(6) = Request.Form("x7")
ng(7) = Request.Form("x8")
ng(8) = Request.Form("x9")
ng(9) = Request.Form("x10")
ng(10) = Request.Form("x11")
ng(11) = Request.Form("x12")
ng(12) = Request.Form("x13")
ng(13) = Request.Form("x14")
ng(14) = Request.Form("x15")
ng(15) = Request.Form("x16")
ng(16) = Request.Form("x17")
ng(17) = Request.Form("x18")
ng(18) = Request.Form("x19")
ng(19) = Request.Form("x20")
ng(20) = Request.Form("x21")
ng(21) = Request.Form("x22")
ng(22) = Request.Form("x23")
ng(23) = Request.Form("x24")
ng(24) = Request.Form("x25")
ng(25) = Request.Form("x26")
ng(26) = Request.Form("x27")
ng(27) = Request.Form("x28")
ng(28) = Request.Form("x29")
ng(29) = Request.Form("x30")
ng(30) = Request.Form("x31")
For i = 0 To 30
 If i = 4 Then
  If ng(i) < 0 Then ng(i) = 0
  If ng(i) > 4 Then ng(i) = 4
 Elseif i = 30 Then
   If ng(i) > 10 Then ng(i) = 10
 Else
  If ng(i) <> 1 Then ng(i) = 0
 End If
Next
grqx = Join(ng, "{]")
If CStr(Application("wsaxhxf_c_grade" & grade)) = CStr(grqx) Then Msg "权限定义没有变化，不需要改变。"
n = Year(Date)
y = Month(Date)
r = Day(Date)
s = Hour(Time())
f = Minute(Time())
m = Second(Time())
If Len(y) = 1 Then y = "0" & y
If Len(r) = 1 Then r = "0" & r
If Len(s) = 1 Then s = "0" & s
If Len(f) = 1 Then f = "0" & f
If Len(m) = 1 Then m = "0" & m
sjsfm = s & ":" & f & ":" & m
sj = n & "-" & y & "-" & r & " " & sjsfm
Set conn=Server.CreateObject("ADODB.CONNECTION")
Set rs=Server.CreateObject("ADODB.RecordSet")
connstr=Application("wsaxhg_connstr")
conn.open connstr
sql = "SELECT value FROM system WHERE name = 'grade" & grade & "'"
rs.Open sql, conn, 1, 3
If rs.Eof And rs.Bof Then
 rs.Close
 conn.Close
 Set rs = Nothing
 Set conn = Nothing
 Msg "参数名称有误！"
End If
rs("value") = grqx
rs.Update
rs.Close
sql = "INSERT INTO logs (type, logtime, name, ip, opertion) VALUES ('5', '" & sj & "', '" & nickname & "', '" & userip & "', '重定义 <font color=red>[" & grade & "]</font> 级的权限')"
conn.Execute sql
conn.Close
Set rs = Nothing
Set conn = Nothing
Application.Lock
Application("wsaxhxf_c_grade" & grade) = grqx
Application.UnLock
Response.Write "<html><head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><meta http-equiv='pragma' content='no-cache'><style type=text/css>body{color:black;font-family:宋体;font-size:9pt;background-color:buttonface;border-bottom:medium none;border-left:medium none;border-right:medium none;border-top:medium none;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px}</style></head><body leftMargin=0 topMargin=0 marginheight=0 marginwidth=0>"
Response.Write "<script Language=JavaScript>alert('■ 操作完成 ■\n\n已经重定义 [" & grade & "] 级的权限。');window.close();</script></body></html>"
Response.End
%>