<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<!--#include file=inc/ubbcode.asp-->
<!--#include file=inc/Email_Cls.asp-->
<%
 '=========================================================
' File: diaryresave.asp
' Version:3.0
' Date: 2005-10-22
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================
dim Did,Title,Content,TID,Topic,IP,usercookies,action
response.buffer=true
if not founduser then
  	errmsg=errmsg+"<br>"+"<li>您没有<a href=login.asp target=_blank>登录</a>。"
	founderr=true
end if
if chkpost=false then
	ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从外部提交发言。"
	FoundErr=True
end if
if Cint(Codeshow(3))=1 then
	if Not CodeIsTrue() then
		errmsg=errmsg+"<br>"+"<li>验证码校验失败，请返回刷新页面后再输入验证码。"
		founderr=true
	end if
end if
if Cint(GroupSetting(85))<>0 and dateadd("n",Cint(GroupSetting(85)),myjoinDate)>=Now() then
  	errmsg=errmsg+"<br>"+"<li>新注册用户"&GroupSetting(85)&"分钟后才能评论日记，请稍后<a href=login.asp target=_blank>登录</a>。"
	founderr=true
end if
if Cint(GroupSetting(99))=0 then
  	errmsg=errmsg+"<br>"+"<li>您没有发表评论的权限，请<a href=login.asp>登陆</a>或者同管理员联系。"
	founderr=true
end if
Did=Checkstr(Request.Form("Did"))
TID=Checkstr(Request.Form("TID"))
Title=Checkstr(trim(request.Form("Title")))
Content=Checkstr(trim(request("Content")))
action=Checkstr(trim(request.Form("action")))
Topic=Checkstr(trim(request.Form("Topic")))
IP=replace(Request.ServerVariables("REMOTE_ADDR"),"'","")
if TID="" or not isInteger(TID) or TID=0 then
	Errmsg=Errmsg+"<br>"+"<li>错误的日记参数！请确认您是从有效的连接进入。"
	founderr=true
else
	TID=clng(TID)
end if
if Title="" or strLength(Title)>200 then
	Errmsg=Errmsg+"<br>"+"<li>评论标题不能为空长度不大于200个字符。"
	founderr=true
end if
if Cint(GroupSetting(100))<>0 and strLength(Content)>Cint(GroupSetting(100)) then
	Errmsg=Errmsg+"<br>"+"<li>评论内容不能为空长度不大于"&GroupSetting(100)&"个字符。"
	founderr=true
end if
session("lastpost")=Now()
if cint(split(Reflash,"|")(0))=1 then
	if not (isnull(session("lastpost")) or Standmaster or master or supermaster or vipuser) then
		if DateDiff("s",session("lastpost"),Now())<cint(GroupSetting(101)) then
   		ErrMsg=ErrMsg+"<Br>"+"<li>本交友限制评论距离时间为"&GroupSetting(101)&"秒，请稍后再发。"
   		FoundErr=True
		end if
	end if
end if
call nav()
if founderr then
	call head_var("","")
	call Mslove_error()
else
stats="评论发表成功"
	call head_var("","")
	call main()
	if founderr then call Mslove_error()
end if
call activeonline()
call footer()

sub main()''操作数据库
dim rsLayer,userEmail
dim postname,Disid,Emailflag''检查评论用户是否是自己的日记
dim mailbody,sendmsg
set rsLayer=conn.execute("select d.EmailFlag,d.username,u.UserEmail from Ms_diary d inner join [Ms_user] u on d.username=u.username where d.Did="&Did)
if not(rsLayer.eof and rsLayer.bof) then
postname=rsLayer("Username")
Emailflag=rsLayer("Emailflag")
userEmail=rsLayer("UserEmail")
else
	Errmsg=Errmsg+"<br>"+"<li>对不起，没有找到记录。"
	founderr=true
end if
rsLayer.close
if postname=trim(membername) then
	Errmsg=Errmsg+"<br>"+"<li>对不起，您不能自己给自己的日记评论。"
	founderr=true
end if
if postname="" then
	Errmsg=Errmsg+"<br>"+"<li>参数错误。"
	founderr=true
end if
if Chkvalue(1,GroupSetting(102),Cint(GroupSetting(103)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的金币不够请确认。"
	founderr=true
end if
if Chkvalue(2,GroupSetting(104),Cint(GroupSetting(105)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的魅力值不够请确认。"
	founderr=true
end if
if Chkvalue(3,GroupSetting(106),Cint(GroupSetting(107)))=false then
	errmsg=errmsg+"<br>"+"<li>对不起，您的经验值不够请确认。"
	founderr=true
end if
if founderr=true then exit sub
set rs=server.createobject("adodb.recordset")
sql="select * from Ms_diaryb where TID="&TID&" and Title='"&Title&"'"
rs.Open sql,conn,1,3
if not (rs.eof and rs.bof) then
	Errmsg=Errmsg+"<br>"+"<li>请不要重复发布评论内容。"
	founderr=true
exit sub
else
rs.addnew
rs("TID")=TID
rs("Title")=Title
rs("Topic")=Topic
rs("Content")=UBBCode(Content)
rs("LastPost")=trim(membername)
rs("LastTime")=now()
rs.update
Disid=rs("Did")
rs.close
conn.execute("update Ms_diary set LastPost='"&trim(membername)&"',Lasttime=now(),Disdiary=Disdiary+1 where Did="&Did&"")
conn.execute("update Ms_user set UserWealth=UserWealth "&GroupSetting(102)&Cint(GroupSetting(103))&",UserEP=UserEP "&GroupSetting(104)&Cint(GroupSetting(105))&",UserCP=UserCP "&GroupSetting(106)&Cint(GroupSetting(107))&" where Username='"&trim(membername)&"'")
if Emailflag=1 or Emailflag=3 then
		topic="您在"&webname&"发表的日记有人回复了"
		email=userEmail
		mailbody=mailbody & ""&postname&"，您好：<br>"
		mailbody=mailbody & "您在"&webname&"发表的日记有人回复了<br>"
		mailbody=mailbody & "请到以下地址浏览该回复内容。<br>"
		mailbody=mailbody & "<a href=http://"&request.servervariables("server_name")&replace(lcase(request.servervariables("script_name")),"diaryresave.asp","")&"diaryview.asp?Did="&Did&" target=_blank>查看回复内容</a>"
	Dim DvEmail
	Set DvEmail = New Dv_SendMail
		DvEmail.SendObject = Cint(Mailtype)	'设置选取组件 1=Jmail,2=Cdonts,3=Aspemail,0不支持
		DvEmail.ServerLoginName = Mailuser	'您的邮件服务器登录名
	    DvEmail.ServerLoginPass = Mailpass	'登录密码
		DvEmail.SendSMTP = Mailsmtp			'SMTP地址
		DvEmail.SendFromEmail = Mailsend		'发送来源地址
		DvEmail.SendFromName = Webname		'发送人信息
		If DvEmail.ErrCode = 0 Then
			DvEmail.SendMail useremail,topic,mailbody	'执行发送邮件
			If MsEmail.Count>0 Then
			sendmsg="<li>邮件已经发送成功</li>"
			Else
				sendmsg="<li>由于系统错误，邮件发送不成功</li>"
			End If
		Else
			sendmsg="<li>由于系统错误，邮件不能发送！</li>"
		End If
		Set DvEmail = Nothing
end if
if Emailflag=2 or Emailflag=3 then
dim mtitle,messages
mtitle="您在"&webname&"发表的日记有人回复了"
messages="<a href=http://"&request.servervariables("server_name")&replace(lcase(request.servervariables("script_name")),"diaryresave.asp","")&"diaryview.asp?Did="&Did&" target=_blank>查看回复内容</a>"
sql="insert into Ms_message (incept,sender,title,content,sendtime,flag,issend) values ('"&postname&"','"&trim(membername)&"','"&mtitle&"','"&messages&"',Now(),0,1)"
sendmsg="<li>短信发送成功！</li>"
conn.execute(sql)
end if
	sucmsg=sucmsg+"<br>"+sendmsg 
	sucmsg=sucmsg+"<br>"+"<li>您已成功发表评论。"
	call Mslove_suc()
end if
end sub
%>