$heatbefore = $thread['heats'];
     DB::query("UPDATE " . DB::table('forum_thread') . " SET heats='{$thread['heats']}' WHERE tid='{$_G['tid']}'", 'UNBUFFERED');
 }
 $bbcodeoff = checkbbcodes($message, !empty($_G['gp_bbcodeoff']));
 $smileyoff = checksmilies($message, !empty($_G['gp_smileyoff']));
 $parseurloff = !empty($_G['gp_parseurloff']);
 $htmlon = $_G['group']['allowhtml'] && !empty($_G['gp_htmlon']) ? 1 : 0;
 $usesig = !empty($_G['gp_usesig']) ? 1 : 0;
 $isanonymous = $_G['group']['allowanonymous'] && !empty($_G['gp_isanonymous']) ? 1 : 0;
 $author = empty($isanonymous) ? $_G['username'] : '';
 $pinvisible = $modnewreplies ? -2 : 0;
 $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
 $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $_G['tid'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0'));
 $cacheposition = getstatus($thread['status'], 1);
 if ($pid && $cacheposition) {
     savepostposition($_G['tid'], $pid);
 }
 $nauthorid = 0;
 if (!empty($_G['gp_noticeauthor']) && !$isanonymous && !$modnewreplies) {
     list($ac, $nauthorid, $nauthor) = explode('|', $_G['gp_noticeauthor']);
     if ($nauthorid != $_G['uid']) {
         $noticeauthormsg = strip_tags($_G['gp_noticeauthormsg']);
         $postmsg = messagecutstr(stripslashes(str_replace($_G['gp_noticetrimstr'], '', $message)), 100);
         if ($ac == 'q') {
             notification_add($nauthorid, 'post', 'repquote_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'noticeauthormsg' => $noticeauthormsg, 'postmsg' => $postmsg, 'fid' => $_G['fid'], 'pid' => $pid));
         } elseif ($ac == 'r') {
             notification_add($nauthorid, 'post', 'reppost_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'noticeauthormsg' => $noticeauthormsg, 'postmsg' => $postmsg, 'fid' => $_G['fid'], 'pid' => $pid));
         }
     }
 }
 if ($special == 5) {
Exemple #2
0
     $db->query("UPDATE {$tablepre}threads SET heats='{$thread['heats']}' WHERE tid='{$tid}'", 'UNBUFFERED');
 }
 $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
 $smileyoff = checksmilies($message, !empty($smileyoff));
 $parseurloff = !empty($parseurloff);
 $htmlon = $allowhtml && !empty($htmlon) ? 1 : 0;
 $usesig = !empty($usesig) ? 1 : 0;
 $isanonymous = $allowanonymous && !empty($isanonymous) ? 1 : 0;
 $author = empty($isanonymous) ? $discuz_user : '';
 $pinvisible = $modnewreplies ? -2 : 0;
 $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
 $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)\r\n\t\t\tVALUES ('{$fid}', '{$tid}', '0', '{$discuz_user}', '{$discuz_uid}', '{$subject}', '{$timestamp}', '{$message}', '{$onlineip}', '{$pinvisible}', '{$isanonymous}', '{$usesig}', '{$htmlon}', '{$bbcodeoff}', '{$smileyoff}', '{$parseurloff}', '0')");
 $pid = $db->insert_id();
 $cacheposition = getstatus($thread['status'], 1);
 if ($pid && $cacheposition) {
     savepostposition($tid, $pid);
 }
 $nauthorid = 0;
 if (!empty($noticeauthor) && !$isanonymous) {
     list($ac, $nauthorid, $nauthor) = explode('|', $noticeauthor);
     if ($nauthorid != $discuz_uid) {
         $postmsg = messagecutstr(str_replace($noticetrimstr, '', $message), 100);
         if ($ac == 'q') {
             sendnotice($nauthorid, 'repquote_noticeauthor', 'threads');
         } elseif ($ac == 'r') {
             sendnotice($nauthorid, 'reppost_noticeauthor', 'threads');
         }
     }
 }
 $uidarray = array();
 $query = $db->query("SELECT uid FROM {$tablepre}favoritethreads WHERE tid='{$tid}'");
function create_position(&$select, $lastpid = 0)
{
    if (empty($select) || !is_array($select)) {
        return 0;
    }
    $tid = $select[0];
    if (empty($lastpid)) {
        $check = DB::result_first("SELECT tid FROM " . DB::table('forum_postposition') . " WHERE tid='{$tid}' LIMIT 1");
        if ($check) {
            unset($select[0]);
            return 0;
        }
    }
    $round = 500;
    $posttable = getposttablebytid($tid);
    $query = DB::query("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$tid}' AND pid>'{$lastpid}' ORDER BY pid ASC LIMIT 0, {$round}");
    while ($post = DB::fetch($query)) {
        if (empty($post) || empty($post['pid'])) {
            continue;
        }
        savepostposition($tid, $post['pid']);
        $lastid = $post['pid'];
    }
    if (DB::num_rows($query) < $round) {
        DB::query("UPDATE " . DB::table('forum_thread') . " SET status=status | '1' WHERE tid='{$tid}'");
        unset($select[0]);
        return 0;
    } else {
        return $lastid;
    }
}
     $posttable = getposttablebytid($post['tid']);
     $curpostnum = DB::result_first("SELECT count(*) FROM " . DB::table($posttable) . " WHERE tid='{$post['tid']}' AND dateline<='{$post['dateline']}' {$sqladd}");
     if (empty($post['first'])) {
         $sticktopiclist[$pid] = $curpostnum;
     }
 }
 if (!submitcheck('modsubmit')) {
     $stickpid = '';
     foreach ($sticktopiclist as $id => $postnum) {
         $stickpid .= '<input type="hidden" name="topiclist[]" value="' . $id . '" />';
     }
     include template('forum/topicadmin_action');
 } else {
     if ($_G['gp_stickreply']) {
         foreach ($sticktopiclist as $pid => $postnum) {
             savepostposition($_G['tid'], $pid, $postnum, 1);
         }
     } else {
         foreach ($sticktopiclist as $pid => $postnum) {
             deletepostposition($_G['tid'], $pid, 1);
         }
     }
     $sticknum = DB::result_first("SELECT count(*) FROM " . DB::table('forum_postposition') . " WHERE tid='{$_G['tid']}' AND stick='1'");
     $stickreply = intval($_G['gp_stickreply']);
     if ($sticknum == 0 || $stickreply == 1) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET moderated='1', stickreply='{$stickreply}' WHERE tid='{$_G['tid']}'");
     }
     $modaction = $_G['gp_stickreply'] ? 'SRE' : 'USR';
     $reason = checkreasonpm();
     $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => $_G['gp_stickreply'] ? 'reason_stickreply' : 'reason_stickdeletereply') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason)), 'modlog' => $thread);
 }
Exemple #5
0
 $smileyoff = checksmilies($message, !empty($_G['gp_smileyoff']));
 $parseurloff = !empty($_G['gp_parseurloff']);
 $htmlon = $_G['group']['allowhtml'] && !empty($_G['gp_htmlon']) ? 1 : 0;
 $usesig = !empty($_G['gp_usesig']) ? 1 : ($_G['uid'] && $_G['group']['maxsigsize'] ? 1 : 0);
 $isanonymous = $_G['group']['allowanonymous'] && !empty($_G['gp_isanonymous']) ? 1 : 0;
 $author = empty($isanonymous) ? $_G['username'] : '';
 $pinvisible = $modnewreplies ? -2 : ($thread['displayorder'] == -4 ? -3 : 0);
 $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
 $postcomment = in_array(2, $_G['setting']['allowpostcomment']) && $_G['group']['allowcommentreply'] && !$pinvisible && !empty($_G['gp_reppid']) && ($nauthorid != $_G['uid'] || $_G['setting']['commentpostself']) ? messagecutstr($message, 200, ' ') : '';
 if (!empty($_G['gp_noticetrimstr'])) {
     $message = $_G['gp_noticetrimstr'] . "\n\n" . $message;
     $bbcodeoff = false;
 }
 $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $_G['tid'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'status' => defined('IN_MOBILE') ? 8 : 0));
 if ($pid && getstatus($thread['status'], 1)) {
     $postionid = savepostposition($_G['tid'], $pid, true);
 }
 if (getstatus($thread['status'], 3) && $postionid) {
     $rushstopfloor = DB::result_first("SELECT stopfloor FROM " . DB::table('forum_threadrush') . " WHERE tid = '{$_G['tid']}'");
     if ($rushstopfloor > 0 && $thread['closed'] == 0 && $postionid >= $rushstopfloor) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET closed='1' WHERE tid='{$_G['tid']}'");
     }
 }
 useractionlog($_G['uid'], 'pid');
 $nauthorid = 0;
 if (!empty($_G['gp_noticeauthor']) && !$isanonymous && !$modnewreplies) {
     list($ac, $nauthorid) = explode('|', authcode($_G['gp_noticeauthor'], 'DECODE'));
     if ($nauthorid != $_G['uid']) {
         if ($ac == 'q') {
             notification_add($nauthorid, 'post', 'reppost_noticeauthor', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'fid' => $_G['fid'], 'pid' => $pid));
         } elseif ($ac == 'r') {
function create_position(&$select, $lastpid = 0)
{
    global $db, $tablepre;
    if (empty($select) || !is_array($select)) {
        return 0;
    }
    $round = 500;
    $tid = $select[0];
    $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='{$tid}' AND pid>'{$lastpid}' ORDER BY pid ASC LIMIT 0, {$round}");
    while ($post = $db->fetch_array($query)) {
        if (empty($post) || empty($post['pid'])) {
            continue;
        }
        savepostposition($tid, $post['pid']);
    }
    if ($db->num_rows($query) < $round) {
        $db->query("UPDATE {$tablepre}threads SET status=status | '1' WHERE tid='{$tid}'");
        unset($select[0]);
        return 0;
    } else {
        return $post['pid'];
    }
}
Exemple #7
0
function article_move_forums($arr, $old_arr)
{
    global $_G;
    $arr['content'] = preg_replace(array('/<center>([\\s\\S]*?)<\\/center>/', '/\\s(?=\\s)/'), array("[align=center]\\1[/align]", ''), $arr['content']);
    $subject = addslashes(trim($arr['title']));
    if ($arr['check']) {
        if (!strlen($subject)) {
            return FALSE;
        }
        $num = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('forum_thread') . " WHERE subject='{$subject}' AND displayorder > '-1'");
        if ($num) {
            return FALSE;
        }
    }
    if ($arr['contents'] > 1 && $arr['is_content_reply'] != 1) {
        $arr['reply'] = array();
    }
    $time_arr = create_public_time($arr, count($arr['reply']) + 1, 1);
    if ($arr['contents'] == 1) {
        $uid_arr = get_rand_uid($arr, 'reply');
    } else {
        if ($arr['is_content_reply'] != 1) {
            if ($arr['content_arr']) {
                $arr['content'] = content_merge($arr['content_arr']);
            }
            $uid_arr = get_rand_uid($arr);
        }
    }
    $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : array_shift($time_arr);
    require_once libfile('function/editor');
    require_once libfile('function/forum');
    $subject = htmlspecialchars_decode(format_html($subject));
    $subject = htmlspecialchars_decode(format_html($subject));
    $arr['content'] = dstripslashes($arr['content']);
    $arr['content'] = img_htmlbbcode($arr['content'], $arr['page_url']);
    $arr['content'] = media_htmlbbcode($arr['content'], $arr['page_url']);
    $arr['content'] = audio_htmlbbcode($arr['content'], $arr['page_url']);
    $message = htmlspecialchars_decode(html2bbcode($arr['content']));
    $message = dstripslashes(format_html($message));
    $arr['fid'] = $_G['fid'] = $_GET['forums'] ? $_GET['forums'] : $arr['forum_fid'];
    $_G['uid'] = $arr['uid'] ? $arr['uid'] : $_G['uid'];
    $view_num = $arr['view_num'];
    require_once libfile('function/post');
    $special = 0;
    if (trim($subject) == '' || trim($message) == '') {
        return -1;
    }
    if (!$sortid && !$special && trim($message) == '') {
        return -1;
    }
    $_GET['save'] = $arr['uid'] ? $arr['uid'] : $_G['uid'];
    $uid = $_GET['save'];
    $typeid = intval($_GET['threadtypeid']) ? intval($_GET['threadtypeid']) : $arr['forum_typeid'];
    $displayorder = 0;
    $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0;
    $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0;
    $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0;
    $price = intval($price);
    $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0;
    if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) {
        return -2;
    }
    if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
        return -3;
    }
    if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
        return -4;
    }
    $_G['forum'] = DB::fetch_first("SELECT * FROM " . DB::table('forum_forum') . " WHERE fid = '{$arr['fid']}'");
    //查询版块信息
    if (!$_G['forum']) {
        return -5;
    }
    $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
    $typeexpiration = intval($_GET['typeexpiration']);
    if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
        return -5;
    }
    $_G['forum_optiondata'] = array();
    if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
        $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $pid);
    }
    $author = !$arr['username'] ? $_G['username'] : $arr['username'];
    $moderated = $digest || $displayorder > 0 ? 1 : 0;
    $thread['status'] = 0;
    $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status']));
    $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status']));
    $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
    $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
    //检查各项设置
    $bbcodeoff = checkbbcodes($message, FALSE);
    $smileyoff = checksmilies($message, FALSE);
    $parseurloff = FALSE;
    $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
    if ($_G['group']['allowreplycredit']) {
        $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
        $_GET['replycredit_times'] = intval($_GET['replycredit_times']);
        $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']);
        $_GET['replycredit_random'] = intval($_GET['replycredit_random']);
        $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'];
        $replycredit = $replycredit_real = 0;
    }
    if ($old_arr['forum_id']) {
        $info = DB::fetch_first("SELECT p.pid,p.tid,t.tid,p.first FROM " . DB::table('forum_post') . " p Inner Join " . DB::table('forum_thread') . " t  ON p.tid = t.tid WHERE p.first = '1' AND t.tid='" . $old_arr['forum_id'] . "' AND t.displayorder > '-1'");
    }
    $reply_count = count($arr['reply']);
    $view_num = $view_num < $reply_count - 1 ? rand($reply_count * 2, $reply_count * 10) : $view_num;
    if ($info['tid']) {
        //更新
        DB::query("UPDATE " . DB::table('forum_thread') . " SET typeid='{$typeid}', author='{$author}', authorid='{$uid}', subject='{$subject}', dateline='{$arr['public_time']}', lastpost='{$arr['public_time']}', fid='{$arr['fid']}', lastposter='{$author}', views='{$view_num}', attachment='0' WHERE tid='{$info['tid']}'", 'UNBUFFERED');
        $tid = $info['tid'];
    } else {
        //添加
        DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, views, displayorder, digest, special, attachment, moderated, status, isgroup, replycredit, closed)\r\n\t\t\tVALUES ('{$_G['fid']}', '0', '{$readperm}', '{$price}', '{$typeid}', '{$sortid}', '{$author}', '{$_G['uid']}', '{$subject}', '{$arr['public_time']}', '{$arr['public_time']}', '{$author}', '{$view_num}', '{$displayorder}', '{$digest}', '{$special}', '0', '{$moderated}', '32', '{$isgroup}', '{$replycredit}', '" . ($closed ? "1" : '0') . "')");
        $tid = DB::insert_id();
        useractionlog($uid, 'tid');
    }
    DB::update('common_member_field_home', array('recentnote' => $subject), array('uid' => $uid));
    if ($moderated) {
        updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
        updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
    }
    if (DISCUZ_VERSION == 'X2') {
        //2.0版本
        $tagstr = addthreadtag($arr['article_tag'], $tid);
    } else {
        $class_tag = new tag();
        $tagstr = $class_tag->add_tag($arr['article_tag'], $tid, 'tid');
    }
    if ($_G['group']['allowreplycredit']) {
        if ($replycredit > 0 && $replycredit_real > 0) {
            updatemembercount($_G['uid'], array('extcredits' . $_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid);
            DB::query("INSERT INTO " . DB::table('forum_replycredit') . " (tid, extcredits, extcreditstype, times, membertimes, random)VALUES('{$tid}', '{$_G['gp_replycredit_extcredits']}', '{$_G[setting][creditstransextra][10]}', '{$_G['gp_replycredit_times']}', '{$_G['gp_replycredit_membertimes']}', '{$_G['gp_replycredit_random']}')");
        }
    }
    if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
        DB::query("INSERT INTO " . DB::table('forum_threadrush') . " (tid, stopfloor, starttimefrom, starttimeto, rewardfloor) VALUES ('{$tid}', '{$_G['gp_stopfloor']}', '{$_G['gp_rushreplyfrom']}', '{$_G['gp_rushreplyto']}', '{$_G['gp_rewardfloor']}')");
    }
    $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
    $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '1', 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $isanonymous, 'usesig' => 1, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0);
    if (DISCUZ_VERSION != 'X2') {
        //2.5版本 2.5版本多了一个position字段
        $post_setarr['position'] = 1;
        $post_setarr = dstripslashes($post_setarr);
    } else {
        $post_setarr = daddslashes($post_setarr);
    }
    $post_setarr['tags'] = $tagstr;
    $replys = 0;
    if ($info['tid']) {
        //更新
        //发布时间要做更改
        $new_post_arr = DB::fetch_first("SELECT dateline FROM " . DB::table('forum_post') . " WHERE tid='{$tid}' ORDER BY dateline ASC limit 1");
        $post_setarr['dateline'] = $new_post_arr['dateline'] - 3600;
        DB::update('forum_post', $post_setarr, array('pid' => $info['pid']));
        $pid = $info['pid'];
    } else {
        $pid = insertpost($post_setarr);
        $post_setarr = array();
        //发布回复
        if ($arr['is_public_reply'] == 1 && $arr['reply'] || $arr['is_content_reply'] == 1) {
            //是否开启发布回复
            if ($arr['is_content_reply'] == 1) {
                $uid_arr = $time_arr = array();
            }
            $reply_arr = $arr['reply'];
            $replys = count($reply_arr);
            if ($arr['public_reply_seq'] == 1) {
                shuffle($reply_arr);
            }
            foreach ((array) $reply_arr as $k => $v) {
                $message = dstripslashes($v['content']);
                $message = media_htmlbbcode($message, $arr['page_url']);
                $message = img_htmlbbcode($message, $arr['page_url']);
                $message = htmlspecialchars_decode(html2bbcode($message));
                //print_r($v['content']);exit();
                if (!$message || strlen($message) < 2) {
                    continue;
                }
                $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '0', 'author' => $uid_arr[$k]['username'] ? $uid_arr[$k]['username'] : $arr['username'], 'authorid' => $uid_arr[$k]['uid'] ? $uid_arr[$k]['uid'] : $arr['uid'], 'subject' => '', 'dateline' => $time_arr[$k] ? $time_arr[$k] : $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $_G['group']['allowanonymous'] && !empty($_GET['isanonymous']) ? 1 : 0, 'usesig' => 1, 'htmlon' => $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0, 'bbcodeoff' => checkbbcodes($message, !empty($_GET['bbcodeoff'])), 'smileyoff' => checksmilies($message, !empty($_GET['smileyoff'])), 'parseurloff' => !empty($_GET['parseurloff']), 'attachment' => '0', 'tags' => 0, 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0);
                $lastpost = $post_setarr['dateline'];
                $lastposter = $post_setarr['author'];
                if (DISCUZ_VERSION != 'X2') {
                    //2.5版本 2.5版本多了一个position字段
                    $post_setarr['position'] = $k + 2;
                    $post_setarr = dstripslashes($post_setarr);
                } else {
                    $post_setarr = daddslashes($post_setarr);
                }
                $reply_pid = insertpost($post_setarr);
                $v['tid'] = $tid;
                $v['pid'] = $reply_pid;
                $v['is_post'] = 1;
                //标识是回复
                $v['cookie'] = $arr['cookie'];
                $v['is_water_img'] = $arr['is_water_img'];
                $v['is_download_img'] = $arr['is_download_img'];
                $v['is_download_file'] = $arr['is_download_file'];
                $forum_arr['tid'] = $tid;
                $forum_arr['pid'] = $reply_pid;
                $forum_arr['is_post'] = 1;
                //标识是回复
                $forum_arr['cookie'] = $arr['cookie'];
                $forum_arr['is_water_img'] = $arr['is_water_img'];
                $forum_arr['is_download_img'] = $arr['is_download_img'];
                $forum_arr['content'] = $v['content'];
                //$re_arr = forum_downremotefile($forum_arr);
                if ($arr['is_download_img'] == 1) {
                    $re_arr = forum_downremotefile($v);
                }
                DB::query("UPDATE " . DB::table('common_member_count') . " SET posts=posts+1 WHERE uid='{$post_setarr['authorid']}'");
                //更新数
                $new[$k] = $post_setarr;
            }
            unset($post_setarr);
            DB::update('forum_thread', array('replies' => count($reply_arr), 'lastpost' => $lastpost, 'lastposter' => $lastposter), array('tid' => $tid));
        }
    }
    //exit();
    $re = $arr;
    $re['fid'] = $fid;
    $re['tid'] = $tid;
    $re['fid'] = $fid;
    $re['uid'] = $arr['uid'];
    $re['username'] = $author;
    $re['pid'] = $pid;
    $re['message'] = $message;
    if ($pid && getstatus($thread['status'], 1)) {
        savepostposition($tid, $pid);
    }
    $threadimageaid = 0;
    $threadimage = array();
    //print_r($message);exit();
    if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) {
        foreach ($sortaids as $sortaid) {
            convertunusedattach($sortaid, $tid, $pid);
        }
    }
    if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) {
        updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']);
        if (!$threadimageaid) {
            $threadimage = DB::fetch_first("SELECT aid, attachment, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1");
            $threadimageaid = $threadimage['aid'];
        }
        if ($_G['forum']['picstyle']) {
            setthreadcover($pid, 0, $threadimageaid);
        }
    }
    /*删除附件*/
    if ($old_arr['forum_id']) {
        $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'");
        while ($v = DB::fetch($query)) {
            $attach[] = $v;
        }
        dunlink($attach);
        DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE tid='{$old_arr['forum_id']}'");
        DB::query("DELETE FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'");
        DB::delete('forum_threadimage', "tid='{$old_arr['forum_id']}'");
        //图片表
    }
    $param = array('fid' => $arr['fid'], 'tid' => $tid, 'pid' => $pid);
    $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
    include_once libfile('function/stat');
    updatestat($isgroup ? 'groupthread' : $statarr[$special]);
    dsetcookie('clearUserdata', 'forum');
    if ($specialextra) {
        $classname = 'threadplugin_' . $specialextra;
        if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'newthread_submit_end')) {
            $threadpluginclass->newthread_submit_end($_G['fid'], $tid);
        }
    }
    $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
    if (!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) {
        $message = !$price ? $message : '';
        if ($special == 0) {
            $feed['icon'] = 'thread';
            $feed['title_template'] = 'feed_thread_title';
            $feed['body_template'] = 'feed_thread_message';
            $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150));
            if (!empty($_G['forum_attachexist'])) {
                $firstaid = DB::result_first("SELECT aid FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1");
                if ($firstaid) {
                    $feed['images'] = array(getforumimg($firstaid));
                    $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}");
                }
            }
        }
    }
    $feed['title_data']['hash_data'] = "tid{$tid}";
    $feed['id'] = $tid;
    $feed['idtype'] = 'tid';
    if ($feed['icon']) {
        postfeed($feed);
    }
    if ($displayorder != -4) {
        if ($digest) {
            updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
        }
        updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
        if ($isgroup) {
            DB::query("UPDATE " . DB::table('forum_groupuser') . " SET threads=threads+1, lastupdate='" . $arr['public_time'] . "' WHERE uid='{$_G['uid']}' AND fid='{$_G['fid']}'");
        }
        $subject = str_replace("\t", ' ', $subject);
        $f_lastpost = "{$tid}\t{$subject}\t" . $arr['public_time'] . "\t{$author}";
        if ($_G['forum']['type'] == 'sub') {
            DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}' WHERE fid='" . $_G['forum'][fup] . "'", 'UNBUFFERED');
        }
    }
    $subject = str_replace("\t", ' ', $subject);
    $replys = $replys ? $replys : 1;
    //今日发帖
    $todayposts = date("Yjn", $arr['public_time']) == date("Yjn", $v) ? 1 : 0;
    foreach ((array) $time_arr as $k => $v) {
        if (date("Yjn", $_G['timestamp']) == date("Yjn", $v)) {
            $todayposts++;
        }
    }
    DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}', threads=threads+1, posts=posts+{$replys}, todayposts=todayposts+{$todayposts} WHERE fid='{$arr['fid']}'", 'UNBUFFERED');
    //更新今日发帖这些数据
    if ($_G['forum']['status'] == 3) {
        require_once libfile('function/group');
        updateactivity($_G['fid'], 0);
        require_once libfile('function/grouplog');
        updategroupcreditlog($_G['fid'], $_G['uid']);
    }
    return $re;
}