function get_comment_parent($commentid)
{
    global $DB, $db_prefix;
    $parent = $DB->result($DB->query("SELECT comment_parent FROM {$db_prefix}comments WHERE commentid='{$commentid}'"), 0);
    if ($parent != 0) {
        return get_comment_parent($parent);
    } else {
        return $commentid;
    }
}
Пример #2
0
 $cmid = $DB->insert_id();
 if ($sax_uid) {
     $DB->unbuffered_query("UPDATE {$db_prefix}users SET lastpost='{$timestamp}' WHERE userid='{$sax_uid}'");
     // 更新用户最后发表时间
 }
 if (!$spam) {
     // 如果不是垃圾则更新当前文章评论数
     $DB->unbuffered_query("UPDATE {$db_prefix}articles SET comments=comments+1 WHERE articleid='{$articleid}'");
     $DB->unbuffered_query("UPDATE {$db_prefix}statistics SET comment_count=comment_count+1");
     newcomments_recache();
     statistics_recache();
 }
 scookie('comment_post_time', $timestamp);
 // 跳转到最新发表的评论
 if ($comment_parent) {
     $gocommentid = get_comment_parent($comment_parent);
 } else {
     $gocommentid = $cmid;
 }
 $cmnum = '#cm' . $gocommentid;
 $article_comment_num = (int) $options['article_comment_num'];
 if ($article_comment_num) {
     $cpost = $DB->result($DB->query("SELECT COUNT(commentid) FROM {$db_prefix}comments WHERE articleid='{$articleid}' AND visible='1' AND commentid<='{$gocommentid}' AND comment_parent='0'"), 0);
     if ($cpost / $article_comment_num <= 1) {
         $page = 1;
     } else {
         $page = @ceil($cpost / $article_comment_num);
         $article['url'] = redirect_permalink($articleid, $article['alias'], $page);
     }
 } else {
     $page = 1;