验证码错误,请点击验证码图片更新验证码!';
exit();
}
}
$arcRow = GetOneArchive($aid);
if(empty($arcRow['aid']))
{
echo '无法查看未知文档的评论!';
exit();
}
if(isset($arcRow['notpost']) && $arcRow['notpost']==1)
{
echo '这篇文档禁止评论!';
exit();
}
if( $cfg_soft_lang != 'utf8' )
{
$msg = UnicodeUrl2Gbk($msg);
if(!empty($username)) $username = UnicodeUrl2Gbk($username);
}
//词汇过滤检查
if( $cfg_notallowstr != '' )
{
if(preg_match("#".$cfg_notallowstr."#i", $msg))
{
echo "评论内容含有禁用词汇!";
exit();
}
}
if( $cfg_replacestr != '' )
{
$msg = preg_replace("#".$cfg_replacestr."#i", '***', $msg);
}
if( empty($msg) )
{
echo "评论内容可能不合法或为空!";
exit();
}
if($cfg_feedback_guest == 'N' && $cfg_ml->M_ID < 1)
{
echo "管理员禁用了游客评论!点击登录";
exit();
}
//检查用户
$username = empty($username) ? '游客' : $username;
if(empty($notuser)) $notuser = 0;
if($notuser==1)
{
$username = $cfg_ml->M_ID > 0 ? '匿名' : '游客';
}
else if($cfg_ml->M_ID > 0)
{
$username = $cfg_ml->M_UserName;
}
else if($username!='' && $pwd!='')
{
$rs = $cfg_ml->CheckUser($username, $pwd);
if($rs==1)
{
$dsql->ExecuteNoneQuery("Update `#@__member` set logintime='".time()."',loginip='".GetIP()."' where mid='{$cfg_ml->M_ID}'; ");
}
$cfg_ml = new MemberLogin();
}
//检查评论间隔时间
$ip = GetIP();
$dtime = time();
if(!empty($cfg_feedback_time))
{
//检查最后发表评论时间,如果未登陆判断当前IP最后评论时间
$where = ($cfg_ml->M_ID > 0 ? "WHERE `mid` = '$cfg_ml->M_ID' " : "WHERE `ip` = '$ip' ");
$row = $dsql->GetOne("SELECT dtime FROM `#@__feedback` $where ORDER BY `id` DESC ");
if(is_array($row) && $dtime - $row['dtime'] < $cfg_feedback_time)
{
ResetVdValue();
echo '管理员设置了评论间隔时间,请稍等休息一下!';
exit();
}
}
$face = 1;
extract($arcRow, EXTR_SKIP);
$msg = cn_substrR(TrimMsg($msg), 500);
$username = cn_substrR(HtmlReplace($username,2), 20);
if(empty($feedbacktype) || ($feedbacktype!='good' && $feedbacktype!='bad'))
{
$feedbacktype = 'feedback';
}
//保存评论内容
if(!empty($fid))
{
$row = $dsql->GetOne("SELECT username,msg from `#@__feedback` WHERE id ='$fid' ");
$qmsg = '{quote}{content}'.$row['msg'].'{/content}{title}'.$row['username'].' 的原帖:{/title}{/quote}';
$msg = addslashes($qmsg).$msg;
}
$ischeck = ($cfg_feedbackcheck=='Y' ? 0 : 1);
$arctitle = addslashes(RemoveXSS($title));
$typeid = intval($typeid);
$feedbacktype = preg_replace("#[^0-9a-z]#i", "", $feedbacktype);
$inquery = "INSERT INTO `#@__feedback`(`aid`,`typeid`,`username`,`arctitle`,`ip`,`ischeck`,`dtime`, `mid`,`bad`,`good`,`ftype`,`face`,`msg`)
VALUES ('$aid','$typeid','$username','$arctitle','$ip','$ischeck','$dtime', '{$cfg_ml->M_ID}','0','0','$feedbacktype','$face','$msg'); ";
$rs = $dsql->ExecuteNoneQuery($inquery);
if( !$rs )
{
echo "发表评论出错了!";
//echo $dslq->GetError();
exit();
}
$newid = $dsql->GetLastID();
//给文章评分
if($feedbacktype=='bad')
{
$dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET scores=scores-{cfg_feedback_sub},badpost=badpost+1,lastpost='$dtime' WHERE id='$aid' ");
}
else if($feedbacktype=='good')
{
$dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET scores=scores+{$cfg_feedback_add},goodpost=goodpost+1,lastpost='$dtime' WHERE id='$aid' ");
}
else
{
$dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET scores=scores+1,lastpost='$dtime' WHERE id='$aid' ");
}
//给用户增加积分
if($cfg_ml->M_ID > 0)
{
#api{{
if(defined('UC_API') && @include_once DEDEROOT.'/api/uc.func.php')
{
//同步积分
uc_credit_note($cfg_ml->M_LoginID, $cfg_sendfb_scores);
//推送事件
$arcRow = GetOneArchive($aid);
$feed['icon'] = 'thread';
$feed['title_template'] = '{username} 在网站发表了评论';
$feed['title_data'] = array('username' => $cfg_ml->M_UserName);
$feed['body_template'] = '{subject}
{message}';
$url = !strstr($arcRow['arcurl'],'http://') ? ($cfg_basehost.$arcRow['arcurl']) : $arcRow['arcurl'];
$feed['body_data'] = array('subject' => "$arcRow[arctitle]", 'message' => cn_substr(strip_tags(preg_replace("/\[.+?\]/is", '', $msg)), 150));
$feed['images'][] = array('url' => $cfg_basehost.'/images/scores.gif', 'link'=> $cfg_basehost);
uc_feed_note($cfg_ml->M_LoginID,$feed); unset($arcRow);
}
#/aip}}
$dsql->ExecuteNoneQuery("UPDATE `#@__member` set scores=scores+{$cfg_sendfb_scores} WHERE mid='{$cfg_ml->M_ID}' ");
$row = $dsql->GetOne("SELECT COUNT(*) AS nums FROM `#@__feedback` WHERE `mid`='".$cfg_ml->M_ID."'");
$dsql->ExecuteNoneQuery("UPDATE `#@__member_tj` SET `feedback`='$row[nums]' WHERE `mid`='".$cfg_ml->M_ID."'");
}
$_SESSION['sedtime'] = time();
if($ischeck==0)
{
echo '成功发表评论,但需审核后才会显示你的评论!';
exit();
}
else
{
$spaceurl = '#';
if($cfg_ml->M_ID > 0) $spaceurl = "{$cfg_memberurl}/index.php?uid=".urlencode($cfg_ml->M_LoginID);
$id = $newid;
$msg = stripslashes($msg);
$msg = str_replace('<', '<', $msg);
$msg = str_replace('>', '>', $msg);
helper('smiley');
$msg = RemoveXSS(Quote_replace(parseSmileys($msg, $cfg_cmspath.'/images/smiley')));
//$msg = RemoveXSS(Quote_replace($msg));
if($feedbacktype=='bad') $bgimg = 'cmt-bad.gif';
else if($feedbacktype=='good') $bgimg = 'cmt-good.gif';
else $bgimg = 'cmt-neu.gif';
global $dsql, $aid, $pagesize, $cfg_templeturl;
if($cfg_ml->M_ID==""){
$mface=$cfg_cmspath."/member/templets/images/dfboy.png";
} else {
$row = $dsql->GetOne("SELECT face,sex FROM `#@__member` WHERE mid={$cfg_ml->M_ID} ");
if(empty($row['face']))
{
if($row['sex']=="女") $mface=$cfg_cmspath."/member/templets/images/dfgirl.png";
else $mface=$cfg_cmspath."/member/templets/images/dfboy.png";
}
}
?>