<!--#include file="config.asp"-->
<!--#include file="../inc/ubbcode.asp"-->
<%
Dim Rs, SQL,i,replyid
Dim Facestr,FaceOption,FormatInput
Newasp.LoadTemplates 9999, 3, 0
HtmlContent = Newasp.HtmlContent
HtmlContent = Replace(HtmlContent,"{$GuestFormContent}", Newasp.HtmlSetting(11))
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", ChannelID)
'--频道目录
HtmlContent = Replace(HtmlContent,"{$ChannelRootDir}", ChannelRootDir, 1, -1, 1)
HtmlContent = Replace(HtmlContent,"{$CurrentStation}",Newasp.ChannelName)
HtmlContent = Replace(HtmlContent,"{$PageTitle}","编辑回复")
HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)
HtmlContent = HTML.ReadAnnounceList(HtmlContent)
HtmlContent = Replace(HtmlContent, "{$MemberName}", Newasp.membername)
HtmlContent = Replace(HtmlContent,"{$LeastString}", Newasp.LeastString)
HtmlContent = Replace(HtmlContent, "{$MaxString}", Newasp.MaxString)
replyid = Newasp.ChkNumeric(Request("replyid"))
If replyid = 0 Then
	Response.Write"错误的系统参数!"
	Response.End
End If
If Trim(Newasp.membergrade) = "999" Or Trim(Session("AdminName")) <> "" Then
	If Newasp.CheckStr(LCase(Request.Form("action"))) = "save" And Request.Form("action") <> "" Then
		Call SaveGuestReply
	Else
		Call EditGuestReply
	End If
Else
	Call OutAlertScript(Newasp.HtmlSetting(3))
End If
Sub EditGuestReply()
	Set Rs = Newasp.Execute("SELECT * FROM xp90com_GuestReply WHERE id ="& replyid)
	If Rs.BOF And Rs.EOF Then
		Set Rs = Nothing
		Call OutAlertScript("错误的系统参数!")
	End If
	HtmlContent = Replace(HtmlContent,"{$Action}","save")
	HtmlContent = Replace(HtmlContent,"{$ReplyContent}","<b>留言内容：</b><br>" & UBBCode(Rs("rContent")))
	HtmlContent = Replace(HtmlContent,"{$SubmitValue}","保存编辑")
	HtmlContent = Replace(HtmlContent, "{$GuestID}", Rs("guestid"))
	HtmlContent = Replace(HtmlContent, "{$ReplyID}", replyid)
	HtmlContent = Replace(HtmlContent,"{$GuestTopic}",Newasp.CheckTopic(Rs("rtitle")))
	HtmlContent = Replace(HtmlContent,"{$UserName}",Newasp.CheckTopic(Rs("rUserName")))
	HtmlContent = Replace(HtmlContent,"{$GuestEmail}","mymail@163.com")
	HtmlContent = Replace(HtmlContent,"{$GuestQQ}","123456789")
	HtmlContent = Replace(HtmlContent,"{$RefererUrl}",Request.ServerVariables("HTTP_REFERER"))
	FaceOption = ""
	For i=1 to 20 
		FaceOption = FaceOption & "<option "
		Facestr="images/" & i & ".gif"
		If LCase(Facestr) = LCase(Rs("rface")) Then FaceOption = FaceOption & "selected "
		FaceOption = FaceOption & "value='" & Facestr &"'>头像" &i &"</option>"
	Next
	HtmlContent = Replace(HtmlContent, "{$FaceOption}", FaceOption)
	FormatInput = "<span style=""background-color: #fFfFff"" id=""myt"" " & Newasp.CheckTopic(Rs("Topicformat")) & " onclick=""javascript:formatbt(this);""  style=""cursor:hand; font-size:11pt"">设置标题样式 ABCdef</span>"
	FormatInput = FormatInput & "<input type=""checkbox"" name=""cancel"" value="""" onclick=""Cancelform()""> 取消格式"
	HtmlContent = Replace(HtmlContent,"{$FormatInput}",FormatInput)
	HtmlContent = Replace(HtmlContent,"{$Topicformat}",Newasp.CheckTopic(Rs("Topicformat")))
	HtmlContent = Replace(HtmlContent,"{$GuestContent}",Server.HTMLEncode(Rs("rContent")))
	Response.Write HtmlContent
	Rs.Close:Set Rs = Nothing
End Sub
Sub SaveGuestReply()
	On Error Resume Next
	If Newasp.CheckPost = False Then
		ErrMsg = ErrMsg + "<li>您提交的数据不合法，请不要从外部提交。</li>"
		FoundErr = True
	End If
	If Trim(Request.Form("username")) = "" Then
		ErrMsg = ErrMsg + "用户名不能为空\n"
		Founderr = True
	End If
	If Newasp.IsValidStr(Request.Form("username")) = False Then
		ErrMsg = ErrMsg + "用户名中含有非法字符\n"
		Founderr = True
	End If
	If Trim(Request.Form("topic")) = "" Then
		ErrMsg = ErrMsg + "回复主题不能为空\n"
		Founderr = True
	End If
	If Trim(Request.Form("content")) = "" Then
		ErrMsg = ErrMsg + "回复内容不能为空\n"
		Founderr = True
	End If
	If Len(Request.Form("content")) < Newasp.LeastString Then
		ErrMsg = ErrMsg + ("回复内容不能小于" & Newasp.LeastString & "字符！")
		Founderr = True
	End If
	If Len(Request.Form("content")) > Newasp.MaxString Then
		ErrMsg = ErrMsg + ("回复内容不能大于" & Newasp.MaxString & "字符！")
		Founderr = True
	End If
	If Founderr = True Then
		Call OutAlertScript(ErrMsg)
		Exit Sub
	End If
	Call PreventRefresh  '防刷新
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "SELECT * FROM xp90com_GuestReply WHERE id="& replyid
	Rs.Open SQL,Conn,1,3
		Rs("rusername") = Left(Request.Form("username"),50)
		Rs("Topicformat") = Trim(Request.Form("Topicformat"))
		Rs("rTitle") = Newasp.ChkFormStr(Left(Request.Form("topic"),100))
		Rs("rContent") = Html2Ubb(Request.Form("content"))
		Rs("rFace") = Trim(Request.Form("face"))
	Rs.update
	Rs.Close:Set Rs = Nothing
	Call OutputScript(Newasp.HtmlSetting(9),Request.ServerVariables("HTTP_REFERER"))
End Sub
Set HTML = Nothing
CloseConn
%>
