<!--#include file="../inc/Bll.asp"-->
<!--#include file="../inc/Constant.asp"-->
<!--#include file="../inc/Md5.asp"-->
<!--#include file="../inc/App.asp"-->

<%
Auto_Login2()
'uroomid,uface,unick,upaylevelcalss,upaynum
if Request.Form("ac")="y" then 
	RS_End
	dim UID,RoomID,RoomPass,NonePass,RoomRecord,NoneRecord,RoomPay,RoomPayJsStr
	if Session(Session_UserID_Arg)="" then RWS "alert('请登录！');';":REND
	UID = Session(Session_UserID_Arg)
	RoomID = Session(Session_RoomID_Arg)
	RS.Open "select top 1 * from [i_Sys_Room] where [i_Sys_Room_ID]="&RoomID,DB_CONN , 1 , 3
	RS("i_Sys_Room_BackGround")=Get_SafeStr(ClearHtml(Request.form("RoomBg")))
	RS("i_Sys_Room_BackGroundFix")=Get_SafeStr(ClearHtml(Request.form("BackgroundFix")))
	RS("i_Sys_Room_StyleTop")=Get_SafeStr(ClearHtml(Request.form("StyleTop")))
	RS("i_Sys_Room_PubNotice")=EscapeCode(Get_SafeStr(ClearHtml(Request.form("tPubNotice"))))
	RS("i_Sys_Room_PubNoticeHref")=Get_SafeStr(ClearHtml(Request.form("tPubNoticeHref")))
	RS("i_Sys_Room_PriNotice")=EscapeCode(Get_SafeStr(ClearHtml(Request.form("tPriNotice"))))
	RS("i_Sys_Room_PriNoticeHref")=Get_SafeStr(ClearHtml(Request.form("tPriNoticeHref")))
	RS("i_Sys_Room_IDCType")=Get_SafeStr(ClearHtml(Request.form("IDCType")))
	RoomPass = Get_SafeStr(ClearHtml(Request.form("i_Sys_Room_Pass")))
	if Request.form("i_Sys_Room_Pay")<>"" then 
		if not IsNumeric(Request.form("i_Sys_Room_Pay")) then
			RS("i_Sys_Room_Pay") =0
		else
			RS("i_Sys_Room_Pay") = Request.form("i_Sys_Room_Pay")
		end if
	end  if
	if RoomPass<>"" then
		RS("i_Sys_Room_Pass")=RoomPass
	end if
	NonePass = Get_SafeStr(ClearHtml(Request.form("NonePass")))
	
	if NonePass<>"" then
		RS("i_Sys_Room_Pass")=" "
	end if
	
	RoomRecord = Get_SafeStr(ClearHtml(Request.form("i_Sys_Room_Record")))
	if RoomRecord<>"" then
		RS("i_Sys_Room_Record")=RoomRecord
	end if
	NoneRecord = Get_SafeStr(ClearHtml(Request.form("NoneRecord")))
	
	if NoneRecord<>"" then
		RS("i_Sys_Room_Record")=" "
	end if
	RS.update()
	RS_End
	CreatRoomInfoJSFiel
	RWS "alert('设置成功');location.href='/handle/setSkinUI.asp?rid="&RoomID&"&pay="&Request.form("i_Sys_Room_Pay")&"';"
	Rend
end if


Sub CreatRoomInfoJSFiel()
	RS_End
	dim SumPay,SumIncome,CurrentPage,k,Re,RID,isManager,rpass
	Re="var DRoomJS=""{data:["
	Set RS=DB_CONN.EXECUTE("select a.*,b.* from [i_User_Info] a join [i_Sys_Room] b on a.[i_User_ID]=b.[i_Sys_Room_AdminUserID] where a.[i_User_ID]="&Session(Session_UserID_Arg))
	while (not RS.eof)
		if Trim(RS("i_Sys_Room_Pass"))<>"" then rpass=md5(RS("i_Sys_Room_Pass")) else rpass=""
		Re=Re&"{face:'"&RS("i_User_Face")&"',unick:'"&RS("i_User_NickName")&"',uid:'"&RS("i_User_ID")&"',rname:'"&RS("i_Sys_Room_Name")&"',pubnotice:'"&RS("i_Sys_Room_PubNotice")&"',pubnoticehref:'"&RS("i_Sys_Room_PubNoticeHref")&"',prinotice:'"&RS("i_Sys_Room_PriNotice")&"',prinoticehref:'"&RS("i_Sys_Room_PriNoticeHref")&"',background:'"&RS("i_Sys_Room_BackGround")&"',backgroundfix:'"&RS("i_Sys_Room_BackGroundFix")&"',styletop:'"&RS("i_Sys_Room_StyleTop")&"',pass:'"&rpass&"',stylecss:'"&RS("i_Sys_Room_StyleCss")&"',maxnum:"&RS("i_Sys_Room_MaxNum")&"}"
		RS.MoveNext
	Wend
	Re=Re&"]}"";"
	RS_End
	
	dim objStream,strFile
	strFile=server.mappath("/d/room/"&RoomID&".js")
	Set objStream = Server.CreateObject("ADODB.Stream")
	With objStream
        .Type = 2
        .Open
        .Charset = "utf-8"
        .Position = objStream.Size
        .WriteText = Re
        .SaveToFile strFile,2
        .Close
    End With
    Set objStream = Nothing
End Sub

Function EscapeCode(p_Message)
Dim m_char,m_asc,m_hex '字符，ASC码，16进制ASCII码
Dim m_temp '临时字符
Dim a_arc() 'ASC码数组
Dim i
ReDim a_arc(Len(p_Message))
For i = 0 To Len(p_Message) -1
    m_char = Mid(p_Message,i+1,1)
    m_asc = AscW(m_char)
    If m_asc < 255 Then
      If (m_char = "*") Or(m_char = "+") _
        Or(m_char >= "-" And m_char <= "9" ) _
        Or(m_char >= "@" And m_char <= "Z" ) _
        Or(m_char = "_") _
        Or(m_char >= "a" And m_char <= "z" ) Then
   a_arc(i) = m_char
   Else
   m_temp = Hex(m_asc)
   If Len(m_temp) = 1 Then
     a_arc(i) = "%0" & m_temp
   ElseIf Len(m_temp) = 2 Then
     a_arc(i) = "%" & m_temp
   Else
     a_arc(i) = "%u" & m_temp
   End If
   End If
    Else
        m_temp = Hex(m_asc)
     If Len(m_temp) = 1 Then
       a_arc(i) = "%u000" & m_temp
     ElseIf Len(m_temp) = 2 Then
       a_arc(i) = "%u00" & m_temp
     ElseIf Len(m_temp) = 3 Then
       a_arc(i) = "%u0" & m_temp
     Else
          a_arc(i) = "%u" & m_temp
        End If
    End If
Next
EscapeCode = Join(a_arc,"")
End Function
%>