 <!--#include file="../head.asp"-->
 
 <%
   isyou=0
    sqlyou="select top 1 * from [Websen_worldec_config]"
	Set rsyou= Server.CreateObject("ADODB.Recordset") 
	rsyou.Open sqlyou,conn,1,1
    if not rsyou.eof then
	isyou=rsyou("iswrite")   '是否允许游客留言
	rsyou.close
	end if
	if isyou=0 then
 %>
   <!--#include file="../checkrole.asp"-->
 <%
      call checkuser("ly")
 	end if
	
	
    if issession=0 then
	gsid=Replace_Text(request.Cookies("Yxmemberid"))
	else
	gsid=session("id")
	end if
		
secuser=Replace_Text(request.form("selected_friend_id"))
secuser=replace(replace(replace(secuser,"-1+",""),"0+",""),"1+","")
  title=Replace_Text(request.form("messageTitle"))
content=Replace_Text(request.form("messageContent"))
sendemail=Replace_Text(request.form("sendemail"))
saveSendMessage=Replace_Text(request.form("saveSendMessage"))
sendContact=Replace_Text(request.form("sendContact"))
if issession=0 then 
safecode=Replace_Text(request.Cookies("safecode"))
else
safecode=Session("SafeCode")
end if

if   Replace_Text(request.form("messageTitle"))="" then 
  response.write"<SCRIPT language=JavaScript>alert('亲爱的会员，您还没有输入主题，请再试一下');history.back(-1);</script>"
  response.End()
end if
if   Replace_Text(request.form("messageContent"))="" then 
  response.write"<SCRIPT language=JavaScript>alert('亲爱的会员，您还没有输入内容，请再试一下');history.back(-1);</script>"
  response.End()
end if
if Replace_Text(request("Verifycode"))="" then 
  response.write"<SCRIPT language=JavaScript>alert('亲爱的会员，您的验证码输入错误，请再试一下');history.back(-1);</script>"
  response.End()
 end if
 if cstr(Replace_Text(request("Verifycode")))<>cstr(safecode) then 
   response.write"<SCRIPT language=JavaScript>alert('亲爱的会员，您的验证码输入错误，请再试一下');history.back(-1);</script>"
  response.End()
 end if
touser=Replace_Text(request.form("touser"))

   
if   gsid<>"" then   '已经登录的会员留言
  '------------------------------------------------------------
 set rs=server.CreateObject("adodb.recordset")
 sqlr="select id,[user] from Websen_corporation where flag=1 and  [user]='"&touser&"' and id<>"&gsid&"" 
 rs.open sqlr,conn,1,3
if rs.eof or rs.bof then
  response.write"<SCRIPT language=JavaScript>alert('您填写的对方会员登陆名不正确或会员登陆名是您自己！');"
  response.write"javascript:history.go(-1)</SCRIPT>"
  response.end
else
  mycid=rs("id")
end if
'-----------------------------------
set rs1=server.createobject("adodb.recordset")
sql1="select * from Websen_getprice1 where id<>0" 
rs1.open sql1,conn,1,3
rs1.addnew
rs1("title")=title
rs1("content")=content
 if sendemail<>"" then rs1("sendemail")=1
 if sendContact<>"" then rs1("sendcontact")=1
 rs1("mycid")=mycid
rs1("sendcid")=gsid
rs1("datetime")=now()
rs1.update
  
set rs=server.createobject("adodb.recordset")
sql="select * from Websen_getprice where id<>0" 
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
 if sendemail<>"" then rs("sendemail")=1
if sendContact<>"" then rs("sendcontact")=1
 rs("mycid")=mycid
rs("sendcid")=gsid
rs("datetime")=now()
 rs("getprice1id")=rs1("id")
rs1.close
set rs1=nothing
 rs.update
 rs.close
set rs=nothing

else   '游客留言
   '--------------------------------------
  set rs=server.CreateObject("adodb.recordset")
 sqlr="select id,[user] from Websen_corporation where flag=1 and  [user]='"&touser&"'" 
 rs.open sqlr,conn,1,3
if rs.eof or rs.bof then
  response.write"<SCRIPT language=JavaScript>alert('您填写的对方会员登陆名不正确！');"
  response.write"javascript:history.go(-1)</SCRIPT>"
  response.end
else
  mycid=rs("id")
end if
  '-----------------------------------
 
 if  isyou=1 then   '允许游客留言
 
 set rsyk=server.CreateObject("adodb.recordset")
 sqlyk="select  * from Yx_ykmessage"
 rsyk.open sqlyk,conn,1,3
 rsyk.addnew
 rsyk("gsid")=mycid
 rsyk("title")=title
 rsyk("content")=content
 rsyk("seeflag")=0
 rsyk("datemsg")=now()
 rsyk.update
 rsyk.close
end if
end if
  urlago=request.ServerVariables("HTTP_REFERER") 	
  response.write"<SCRIPT language=JavaScript>alert('留言成功！');"
  response.write"location.href='"&urlago&"'</SCRIPT>"
 

%>
                	
