<!-- #include file="common.asp"-->
<!--#include file="KeywordFilter.asp"-->
<%
'------------------- 解决留言不会换行的-----------------------
  function HTMLEncode(fString)
  if not isnull(fString) then
  fString = replace(fString, ">", "&gt;")
  fString = replace(fString, "<", "&lt;")

  fString = Replace(fString, CHR(32), "&nbsp;")
  fString = Replace(fString, CHR(9), "&nbsp;")
  fString = Replace(fString, CHR(34), "&quot;")
  fString = Replace(fString, CHR(39), "&#39;")
  fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
  fString = Replace(fString, CHR(10), "<BR> ")
  HTMLEncode = fString
  end if
  end function
%>
<%
  If Trim(Request.Form("Recontent"))="" Then

  Else
    SaveType = Trim(Request.Form("SaveType"))
'------------------- v 1.4 解决留言不会换行的Bug-----------------------
    recontent = HtmlEncode(Request.form("Recontent"))

'------------------- v 3.0 Security Encode -----------------------
  	recontent = SecEncode( recontent )
	
	On Error Resume Next
    Set Rs=Server.CreateObject("ADODB.Recordset")
	If SaveType="MOD" Then
	  sqlstrb="select * from reply Where ID="&Trim(Request("RID"))
	Else
      sqlstrb="select * from reply Where GuestID="&Trim(Request("ID"))
	End If
    Rs.Open sqlstrb,conn,1,3
	
	If Err.Number=0 Then
    If SaveType<>"MOD" Then
	Rs.AddNew
	End If
	Rs("GuestID")	=Trim(Request("ID"))
	
	Rs("Content")	=recontent
	Rs("RName")		=Trim(Request("nname"))
	Rs("Remail")	=Trim(Request("nmail"))
	Rs("Rhomepage")	=Trim(Request("npage"))
	Rs("Roicq")		=Trim(Request("noicq"))
	Rs("Raddress")	=Trim(Request("naddr"))
	If SaveType<>"MOD" Then
	  Rs("Date")	=Date()
	  Rs("Time")	=Time()
	  Rs("Rip")		=Request.Servervariables("REMOTE_addr")
	Else
	  Rs("ModRDT")	=Now()
	End If
	'秘密回复，只有管理员可以查看
	If Request.Form("SecReply")="1" Then
	  Rs("SecReply")=True
	Else
	  Rs("SecReply")=False
	End If
	'不显示回复
	If Request.Form("RNoview")="1" Then
	  Rs("RNoview")=True
	Else
	  Rs("RNoview")=False
	End If
	If IfRepNeedAud=False Then
	  Rs("AudStatus")="1"
	End If
  Rs.Update
	
	SQL = "Update Guest Set Reply=1 Where ID=" & Request("ID")
	Conn.Execute(SQL)
	End If
	
	If Request.Form("NoView")=1 Then
	  SQL2 = "Update Guest Set ReNoView=True Where ID=" & Request("ID")
	  Conn.Execute(SQL2)
	Else
	  SQL2 = "Update Guest Set ReNoView=False Where ID=" & Request("ID")
	  Conn.Execute(SQL2)
	End If	  

  End if
  conn.Close
  Set conn=Nothing
  
  If SaveType="MOD" Then
    Response.Write("<script language=javascript>alert('修改成功！');location.href='"&Trim(Request("RetUrl"))&"?pn="&Trim(Request("pn"))&"&GID="&Trim(Request("ID"))&"&RID="&Trim(Request("RID"))&"';</script>")
  Else
    Response.Write("<script language=javascript>alert('回复成功！');location.href='"&Trim(Request("RetUrl"))&"?pn="&Trim(Request("pn"))&"&GID="&Trim(Request("ID"))&"&ipn="&Trim(Request("ipn"))&"';</script>")
  End If
%>
