Exemplo n.º 1
0
 public function before_editpost($parameters)
 {
     global $_G;
     $sortid = $parameters['sortid'];
     $isfirstpost = $this->post['first'] ? 1 : 0;
     if ($isfirstpost) {
         $parameters['typeid'] = isset($this->forum['threadtypes']['types'][$parameters['typeid']]) ? $parameters['typeid'] : 0;
         if (!$this->forum['ismoderator'] && !empty($this->forum['threadtypes']['moderators'][$this->thread['typeid']])) {
             $parameters['typeid'] = $this->thread['typeid'];
         }
         $parameters['sortid'] = isset($this->forum['threadsorts']['types'][$parameters['sortid']]) ? $parameters['sortid'] : 0;
         $typeexpiration = intval($_GET['typeexpiration']);
         if (!$parameters['typeid'] && $this->forum['threadtypes']['required'] && !$this->thread['special']) {
             showmessage('post_type_isnull');
         }
         if ($this->forum['threadsorts']['types'][$sortid] && $_G['forum_checkoption']) {
             $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $this->post['pid']);
         }
         $this->param['threadimageaid'] = 0;
         $this->param['threadimage'] = array();
         if ($this->forum['threadsorts']['types'][$parameters['sortid']] && $_G['forum_optiondata'] && is_array($_G['forum_optiondata'])) {
             $sql = $separator = $filedname = $valuelist = '';
             foreach ($_G['forum_optiondata'] as $optionid => $value) {
                 $value = censor(daddslashes($value));
                 if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
                     $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                     $newsortaid = intval($_GET['typeoption'][$identifier]['aid']);
                     if ($newsortaid && $_GET['oldsortaid'][$identifier] && $newsortaid != $_GET['oldsortaid'][$identifier]) {
                         $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]);
                         C::t('forum_attachment')->delete($_GET['oldsortaid'][$identifier]);
                         C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]);
                         dunlink($attach);
                         $this->param['threadimageaid'] = $newsortaid;
                         convertunusedattach($newsortaid, $this->thread['tid'], $this->post['pid']);
                     }
                 } else {
                     if ($_G['forum_optionlist'][$optionid]['type'] == 'face') {
                         $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                         $newsortaid = intval($_GET['typeoption'][$identifier]['aid']);
                         if ($newsortaid && $_GET['oldsortaid'][$identifier] && $newsortaid != $_GET['oldsortaid'][$identifier]) {
                             $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]);
                             C::t('forum_attachment')->delete($_GET['oldsortaid'][$identifier]);
                             C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]);
                             dunlink($attach);
                             $this->param['threadimageaid'] = $newsortaid;
                             convertunusedattach($newsortaid, $this->thread['tid'], $this->post['pid']);
                         }
                     }
                 }
                 if ($_G['forum_optionlist'][$optionid]['unchangeable']) {
                     continue;
                 }
                 if (($_G['forum_optionlist'][$optionid]['search'] || in_array($_G['forum_optionlist'][$optionid]['type'], array('radio', 'select', 'number'))) && $value) {
                     $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier'];
                     $valuelist .= $separator . "'{$value}'";
                     $sql .= $separator . $_G['forum_optionlist'][$optionid]['identifier'] . "='{$value}'";
                     $separator = ' ,';
                 }
                 C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('value' => $value, 'sortid' => $parameters['sortid']), false, false, $optionid);
             }
             if ($typeexpiration) {
                 C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('expiration' => TIMESTAMP + $typeexpiration), false, false, null, $parameters['sortid']);
             }
             if ($sql || $filedname && $valuelist) {
                 if (C::t('forum_optionvalue')->fetch_all_tid($parameters['sortid'], "WHERE tid='" . $this->thread['tid'] . "'")) {
                     if ($sql) {
                         C::t('forum_optionvalue')->update($parameters['sortid'], $this->thread['tid'], $this->forum['fid'], $sql);
                     }
                 } elseif ($filedname && $valuelist) {
                     C::t('forum_optionvalue')->insert($parameters['sortid'], "({$filedname}, tid, fid) VALUES ({$valuelist}, '" . $this->thread['tid'] . "', '" . $this->forum['fid'] . "')");
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
             showmessage('debate_umpire_invalid');
         }
     }
     $affirmpoint = censor(dhtmlspecialchars($_G['gp_affirmpoint']));
     $negapoint = censor(dhtmlspecialchars($_G['gp_negapoint']));
     DB::query("UPDATE " . DB::table('forum_debate') . " SET affirmpoint='{$affirmpoint}', negapoint='{$negapoint}', endtime='{$endtime}', umpire='{$_G['gp_umpire']}' WHERE tid='{$_G['tid']}'");
 } elseif ($specialextra) {
     @(include_once DISCUZ_ROOT . './source/plugin/' . $_G['setting']['threadplugins'][$specialextra]['module'] . '.class.php');
     $classname = 'threadplugin_' . $specialextra;
     if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'editpost_submit')) {
         $threadpluginclass->editpost_submit($_G['fid'], $_G['tid']);
     }
 }
 $_G['forum_optiondata'] = array();
 if ($_G['forum']['threadsorts']['types'][$sortid] && $_G['forum_checkoption']) {
     $_G['forum_optiondata'] = threadsort_validator($_G['gp_typeoption'], $pid);
 }
 $threadimageaid = 0;
 $threadimage = array();
 if ($_G['forum']['threadsorts']['types'][$sortid] && $_G['forum_optiondata'] && is_array($_G['forum_optiondata'])) {
     $sql = $separator = $filedname = $valuelist = '';
     foreach ($_G['forum_optiondata'] as $optionid => $value) {
         if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
             $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
             $newsortaid = intval($_G['gp_typeoption'][$identifier]['aid']);
             if ($newsortaid && $newsortaid != $_G['gp_oldsortaid'][$identifier]) {
                 $attach = DB::fetch_first("SELECT attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE aid='{$_G['gp_oldsortaid'][$identifier]}'");
                 DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE aid='{$_G['gp_oldsortaid'][$identifier]}'");
                 DB::query("DELETE FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE aid='{$_G['gp_oldsortaid'][$identifier]}'");
                 dunlink($attach);
                 $threadimageaid = $newsortaid;
Exemplo n.º 3
0
 if (!submitcheck('editsubmit')) {
     threadsort_optiondata($sortid, $_G['cache']['category_option_' . $sortid], $_G['cache']['category_template_' . $sortid], $tid);
     $attachs = array();
     if ($sortdata['attachid']) {
         $query = DB::query("SELECT * FROM " . DB::table('category_' . $modidentifier . '_pic') . " WHERE tid='{$tid}'");
         while ($attach = DB::fetch($query)) {
             $attachs[] = $attach;
         }
     }
     if (count($attachs) < $category_sort['imgnum']) {
         $imgnum = array();
         $uploadnum = $category_sort['imgnum'] - count($attachs);
         $imgnum = array_pad($imgnum, $uploadnum, 0);
     }
 } else {
     $_G['category_optiondata'] = threadsort_validator($_G['gp_typeoption'], $pid);
     $_G['gp_expiration'] = $_G['gp_expiration'] ? $sortdata['expiration'] ? $sortdata['expiration'] + intval($_G['gp_expiration']) : $_G['timestamp'] + intval($_G['gp_expiration']) : $sortdata['expiration'];
     $sql = $separator = $newaidadd = '';
     foreach ($_G['category_optiondata'] as $optionid => $value) {
         if (($_G['category_optionlist'][$optionid]['search'] || in_array($_G['category_optionlist'][$optionid]['type'], array('radio', 'select', 'number'))) && $value) {
             $sql .= $separator . $_G['category_optionlist'][$optionid]['identifier'] . "='{$value}'";
             $separator = ' ,';
         }
         DB::query("UPDATE " . DB::table('category_sortoptionvar') . " SET value='{$value}', sortid='{$sortid}', expiration='{$_G['gp_expiration']}' WHERE tid='{$tid}' AND optionid='{$optionid}'");
     }
     if ($sql) {
         DB::query("UPDATE " . DB::table('category_sortvalue') . "{$sortid} SET {$sql} WHERE tid='{$tid}'");
     }
     if (!empty($subject) || !empty($message)) {
         $message = censor(trim($_G['gp_message']));
         DB::query("UPDATE " . DB::table('category_' . $modidentifier . '_thread') . " SET subject='{$subject}', message='{$message}' WHERE tid='{$tid}'");
Exemplo n.º 4
0
     }
 }
 $allowpostattach && ($attachnew || $attachdel || $special == 2 && $tradeaid || $isfirstpost && $sortid) && updateattach();
 if ($uattachment || $attachdel) {
     $tattachment = $db->result_first("SELECT count(*) FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='{$tid}' AND a.isimage IN ('1', '-1') AND a.pid=p.pid AND p.invisible='0' LIMIT 1") ? 2 : ($db->result_first("SELECT count(*) FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='{$tid}' AND a.pid=p.pid AND p.invisible='0' LIMIT 1") ? 1 : 0);
     $db->query("UPDATE {$tablepre}threads SET attachment='{$tattachment}' WHERE tid='{$tid}'");
 }
 if ($special == 2 && $allowposttrade) {
     $oldtypeid = $db->result_first("SELECT typeid FROM {$tablepre}trades WHERE pid='{$pid}'");
     $oldtypeid = isset($tradetypes[$oldtypeid]) ? $oldtypeid : 0;
     $tradetypeid = !$tradetypeid ? $oldtypeid : $tradetypeid;
     $optiondata = array();
     threadsort_checkoption($oldtypeid, 1);
     $optiondata = array();
     if ($tradetypes && $typeoption && is_array($typeoption) && $checkoption) {
         $optiondata = threadsort_validator($typeoption);
     }
     if ($tradetypes && $optiondata && is_array($optiondata)) {
         foreach ($optiondata as $optionid => $value) {
             if ($oldtypeid) {
                 $db->query("UPDATE {$tablepre}tradeoptionvars SET value='{$value}' WHERE pid='{$pid}' AND optionid='{$optionid}'");
             } else {
                 $db->query("INSERT INTO {$tablepre}tradeoptionvars (sortid, pid, optionid, value)\r\n\t\t\t\t\t\t\tVALUES ('{$tradetypeid}', '{$pid}', '{$optionid}', '{$value}')");
             }
         }
     }
     if (!$oldtypeid) {
         $db->query("UPDATE {$tablepre}trades SET typeid='{$tradetypeid}' WHERE pid='{$pid}'");
     }
     if ($trade = $db->fetch_first("SELECT * FROM {$tablepre}trades WHERE tid='{$tid}' AND pid='{$pid}'")) {
         $seller = dhtmlspecialchars(trim($seller));
Exemplo n.º 5
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;
}