92 lines
2.2 KiB
PHP
92 lines
2.2 KiB
PHP
<?php
|
|
defined('IN_TS') or die('Access Denied.');
|
|
//用户是否登录
|
|
$userid = aac('user')->isLogin($js,$userkey);
|
|
switch($ts){
|
|
|
|
case "do":
|
|
|
|
$authcode = strtolower($_POST['authcode']);
|
|
|
|
if ($TS_SITE ['isauthcode']) {
|
|
if ($authcode != $_SESSION ['verify']) {
|
|
getJson ( "验证码输入有误,请重新输入!" ,$js,0);
|
|
}
|
|
}
|
|
|
|
$attachid = intval($_POST['attachid']);
|
|
$content = tsClean($_POST['content'],$js);
|
|
$content2 = emptyText($_POST['content']);//测试空内容
|
|
$ispublic = intval($_POST['ispublic']);
|
|
|
|
//过滤内容开始
|
|
if($TS_USER['isadmin']==0){
|
|
aac('system')->antiWord($content,$js);
|
|
}
|
|
//过滤内容结束
|
|
|
|
if($content2==''){
|
|
getJson('没有任何内容是不允许你通过滴^_^',$js);
|
|
}else{
|
|
$commentid = $new['attach']->create('attach_comment',array(
|
|
'attachid' => $attachid,
|
|
'userid' => $userid,
|
|
'content' => $content,
|
|
'addtime'=> time(),
|
|
));
|
|
|
|
|
|
|
|
//发送系统消息(通知楼主有人回复他的帖子啦)
|
|
$strattach = $new['attach']->find('attach',array(
|
|
'attachid'=>$attachid,
|
|
));
|
|
|
|
if($strattach['userid'] != $TS_USER['userid']){
|
|
|
|
$msg_userid = '0';
|
|
$msg_touserid = $strattach['userid'];
|
|
$msg_content = '你的附件:《'.$strattach['attachname'].'》新增一条评论,快去看看给个回复吧^_^ ';
|
|
$msg_tourl = tsUrl('attach','show',array('id'=>$attachid));
|
|
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
|
|
|
|
}
|
|
|
|
header("Location: ".tsUrl('attach','show',array('id'=>$attachid)));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
//删除评论
|
|
case "delete":
|
|
|
|
$commentid = intval($_GET['commentid']);
|
|
|
|
$strComment = $new['attach']->find('attach_comment',array(
|
|
'commentid'=>$commentid,
|
|
));
|
|
|
|
$strattach = $new['attach']->find('attach',array(
|
|
'attachid'=>$strComment['attachid'],
|
|
));
|
|
|
|
|
|
|
|
if($strattach['userid']==$userid || $TS_USER['isadmin']==1 || $strComment['userid']==$userid){
|
|
|
|
$new['attach']->delete('attach_comment',array(
|
|
'commentid'=>$commentid,
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//跳转回到帖子页
|
|
header("Location: ".tsUrl('attach','show',array('id'=>$strComment['attachid'])));
|
|
|
|
break;
|
|
} |