public function newthread($parameters)
 {
     require_once libfile('function/post');
     $this->tid = $this->pid = 0;
     $this->_init_parameters($parameters);
     if (trim($this->param['subject']) == '') {
         return $this->showmessage('post_sm_isnull');
     }
     if (!$this->param['sortid'] && !$this->param['special'] && trim($this->param['message']) == '') {
         return $this->showmessage('post_sm_isnull');
     }
     list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']);
     if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $this->param['special'] || $this->param['sortid'])) {
         return $this->showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize']));
     }
     if (checkflood()) {
         return $this->showmessage('post_flood_ctrl', '', array('floodctrl' => $this->setting['floodctrl']));
     } elseif (checkmaxperhour('tid')) {
         return $this->showmessage('thread_flood_ctrl_threads_per_hour', '', array('threads_per_hour' => $this->group['maxthreadsperhour']));
     }
     $this->param['save'] = $this->member['uid'] ? $this->param['save'] : 0;
     $this->param['typeid'] = isset($this->param['typeid']) && isset($this->forum['threadtypes']['types'][$this->param['typeid']]) && (!$this->forum['threadtypes']['moderators'][$this->param['typeid']] || $this->forum['ismoderator']) ? $this->param['typeid'] : 0;
     $this->param['displayorder'] = $this->param['modnewthreads'] ? -2 : ($this->forum['ismoderator'] && $this->group['allowstickthread'] && !empty($this->param['sticktopic']) ? 1 : (empty($this->param['save']) ? 0 : -4));
     if ($this->param['displayorder'] == -2) {
         C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1'));
     }
     $this->param['digest'] = $this->forum['ismoderator'] && $this->group['allowdigestthread'] && !empty($this->param['digest']) ? 1 : 0;
     $this->param['readperm'] = $this->group['allowsetreadperm'] ? $this->param['readperm'] : 0;
     $this->param['isanonymous'] = $this->group['allowanonymous'] && $this->param['isanonymous'] ? 1 : 0;
     $this->param['price'] = intval($this->param['price']);
     if (!$this->param['special']) {
         $this->param['price'] = $this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] : $this->group['maxprice'] : 0;
     }
     if (!$this->param['typeid'] && $this->forum['threadtypes']['required'] && !$this->param['special']) {
         return $this->showmessage('post_type_isnull');
     }
     if (!$this->param['sortid'] && $this->forum['threadsorts']['required'] && !$this->param['special']) {
         return $this->showmessage('post_sort_isnull');
     }
     if (!$this->param['special'] && $this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) {
         return $this->showmessage('post_net_price_iszero');
     }
     $this->param['sortid'] = $this->param['special'] && $this->forum['threadsorts']['types'][$this->param['sortid']] ? 0 : $this->param['sortid'];
     $this->param['typeexpiration'] = intval($this->param['typeexpiration']);
     if ($this->forum['threadsorts']['expiration'][$this->param['typeid']] && !$this->param['typeexpiration']) {
         return $this->showmessage('threadtype_expiration_invalid');
     }
     $author = !$this->param['isanonymous'] ? $this->member['username'] : '';
     $this->param['moderated'] = $this->param['digest'] || $this->param['displayorder'] > 0 ? 1 : 0;
     $this->param['ordertype'] && ($this->param['tstatus'] = setstatus(4, 1, $this->param['tstatus']));
     $this->param['imgcontent'] && ($this->param['tstatus'] = setstatus(15, $this->param['imgcontent'], $this->param['tstatus']));
     $this->param['hiddenreplies'] && ($this->param['tstatus'] = setstatus(2, 1, $this->param['tstatus']));
     $this->param['allownoticeauthor'] && ($this->param['tstatus'] = setstatus(6, 1, $this->param['tstatus']));
     $this->param['isgroup'] = $this->forum['status'] == 3 ? 1 : 0;
     $this->param['publishdate'] = !$this->param['modnewthreads'] ? $this->param['publishdate'] : TIMESTAMP;
     $newthread = array('fid' => $this->forum['fid'], 'posttableid' => 0, 'readperm' => $this->param['readperm'], 'price' => $this->param['price'], 'typeid' => $this->param['typeid'], 'sortid' => $this->param['sortid'], 'author' => $author, 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'lastpost' => $this->param['publishdate'], 'lastposter' => $author, 'displayorder' => $this->param['displayorder'], 'digest' => $this->param['digest'], 'special' => $this->param['special'], 'attachment' => 0, 'moderated' => $this->param['moderated'], 'status' => $this->param['tstatus'], 'isgroup' => $this->param['isgroup'], 'replycredit' => $this->param['replycredit'], 'closed' => $this->param['closed'] ? 1 : 0);
     $this->tid = C::t('forum_thread')->insert($newthread, true);
     C::t('forum_newthread')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid'], 'dateline' => $this->param['publishdate']));
     useractionlog($this->member['uid'], 'tid');
     if (!getuserprofile('threads') && $this->setting['newbie']) {
         C::t('forum_thread')->update($this->tid, array('icon' => $this->setting['newbie']));
     }
     if ($this->param['publishdate'] != TIMESTAMP) {
         $cron_publish_ids = dunserialize($this->cache('cronpublish'));
         $cron_publish_ids[$this->tid] = $this->tid;
         $cron_publish_ids = serialize($cron_publish_ids);
         savecache('cronpublish', $cron_publish_ids);
     }
     if (!$this->param['isanonymous']) {
         C::t('common_member_field_home')->update($this->member['uid'], array('recentnote' => $this->param['subject']));
     }
     if ($this->param['moderated']) {
         updatemodlog($this->tid, $this->param['displayorder'] > 0 ? 'STK' : 'DIG');
         updatemodworks($this->param['displayorder'] > 0 ? 'STK' : 'DIG', 1);
     }
     $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff']));
     $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff']));
     $this->param['parseurloff'] = !empty($this->param['parseurloff']);
     $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0;
     $this->param['usesig'] = !empty($this->param['usesig']) && $this->group['maxsigsize'] ? 1 : 0;
     $class_tag = new tag();
     $this->param['tagstr'] = $class_tag->add_tag($this->param['tags'], $this->tid, 'tid');
     $this->param['pinvisible'] = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3);
     $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']);
     $this->param['pstatus'] = intval($this->param['pstatus']);
     defined('IN_MOBILE') && ($this->param['pstatus'] = setstatus(4, 1, $this->param['pstatus']));
     if ($this->param['imgcontent']) {
         stringtopic($this->param['message'], $this->tid, true, $this->param['imgcontentwidth']);
     }
     $this->pid = insertpost(array('fid' => $this->forum['fid'], 'tid' => $this->tid, 'first' => '1', 'author' => $this->member['username'], 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'message' => $this->param['message'], 'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'), 'port' => $this->param['remoteport'] ? $this->param['remoteport'] : getglobal('remoteport'), 'invisible' => $this->param['pinvisible'], 'anonymous' => $this->param['isanonymous'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'smileyoff' => $this->param['smileyoff'], 'parseurloff' => $this->param['parseurloff'], 'attachment' => '0', 'tags' => $this->param['tagstr'], 'replycredit' => 0, 'status' => $this->param['pstatus']));
     $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
     include_once libfile('function/stat');
     updatestat($this->param['isgroup'] ? 'groupthread' : $statarr[$this->param['special']]);
     if ($this->param['geoloc'] && IN_MOBILE == 2) {
         list($mapx, $mapy, $location) = explode('|', $this->param['geoloc']);
         if ($mapx && $mapy && $location) {
             C::t('forum_post_location')->insert(array('pid' => $this->pid, 'tid' => $this->tid, 'uid' => $this->member['uid'], 'mapx' => $mapx, 'mapy' => $mapy, 'location' => $location));
         }
     }
     if ($this->param['modnewthreads']) {
         updatemoderate('tid', $this->tid);
         C::t('forum_forum')->update_forum_counter($this->forum['fid'], 0, 0, 1);
         manage_addnotify('verifythread');
         return 'post_newthread_mod_succeed';
     } else {
         if ($this->param['displayorder'] != -4) {
             if ($this->param['digest']) {
                 updatepostcredits('+', $this->member['uid'], 'digest', $this->forum['fid']);
             }
             updatepostcredits('+', $this->member['uid'], 'post', $this->forum['fid']);
             if ($this->param['isgroup']) {
                 C::t('forum_groupuser')->update_counter_for_user($this->member['uid'], $this->forum['fid'], 1);
             }
             $subject = str_replace("\t", ' ', $this->param['subject']);
             $lastpost = "{$this->tid}\t" . $subject . "\t" . TIMESTAMP . "\t{$author}";
             C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost));
             C::t('forum_forum')->update_forum_counter($this->forum['fid'], 1, 1, 1);
             if ($this->forum['type'] == 'sub') {
                 C::t('forum_forum')->update($this->forum['fup'], array('lastpost' => $lastpost));
             }
         }
         if ($this->param['isgroup']) {
             C::t('forum_forumfield')->update($this->forum['fid'], array('lastupdate' => TIMESTAMP));
             require_once libfile('function/grouplog');
             updategroupcreditlog($this->forum['fid'], $this->member['uid']);
         }
         C::t('forum_sofa')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid']));
         return 'post_newthread_succeed';
     }
 }
function threadsortshow($sortid, $tid)
{
    global $_G;
    loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
    $sortoptionarray = $_G['cache']['threadsort_option_' . $sortid];
    $templatearray = $_G['cache']['threadsort_template_' . $sortid];
    $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array();
    $sql = "SELECT p.pid,p.fid,p.authorid FROM " . DB::table('forum_post') . " p WHERE p.tid =" . $tid . " and p.position=1 LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_tid = 0;
    $vanfon_fid = 0;
    $vanfon_uid = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_tid = $result['pid'];
        $vanfon_fid = $result['fid'];
        $vanfon_uid = $result['authorid'];
    }
    $vanfon_verify = '';
    $verifyuids = array();
    $verifyuids[$vanfon_uid] = $vanfon_uid;
    foreach (C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
        foreach ($_G['setting']['verify'] as $vid => $vsetting) {
            if ($vsetting['available'] && $vsetting['showicon'] && $value['verify' . $vid] == 1) {
                $srcurl = '';
                if (!empty($vsetting['icon'])) {
                    $srcurl = $vsetting['icon'];
                }
                $vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid={$vid}\" target=\"_blank\">" . (!empty($srcurl) ? '<img src="' . $srcurl . '" class="vm" alt="' . $vsetting['title'] . '" title="' . $vsetting['title'] . '" />' : $vsetting['title']) . '</a>';
            } else {
                /*$srcurl = '';
                		$srcurl =   $vsetting['unverifyicon'];
                			$vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid=$vid\" target=\"_blank\">".(!empty($srcurl) ? '<img src="'.$srcurl.'" class="vm" alt="'.$vsetting['title'].'" title="'.$vsetting['title'].'" />' : $vsetting['title']).'</a>';*/
            }
        }
    }
    $sql = "SELECT m.groupid,g.icon FROM " . DB::table('common_member') . " m ," . DB::table('common_usergroup') . " g WHERE m.uid =" . $vanfon_uid . " and m.groupid=g.groupid LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_usergroup = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_usergroup = $result['icon'];
    }
    if ($sortoptionarray) {
        foreach (C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) {
            $optiondata[$option['optionid']]['value'] = $option['value'];
            $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0;
            $sortdataexpiration = $option['expiration'];
        }
        foreach ($sortoptionarray as $optionid => $option) {
            $_G['forum_option'][$option['identifier']]['title'] = $option['title'];
            $_G['forum_option'][$option['identifier']]['unit'] = $option['unit'];
            $_G['forum_option'][$option['identifier']]['type'] = $option['type'];
            if ($option['expiration'] && !$optiondata[$optionid]['expiration'] || empty($option['expiration'])) {
                if (!protectguard($option['protect'])) {
                    if ($option['type'] == 'checkbox') {
                        $_G['forum_option'][$option['identifier']]['value'] = '';
                        foreach (explode("\t", $optiondata[$optionid]['value']) as $choiceid) {
                            $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid] . '&nbsp;';
                        }
                    } elseif ($option['type'] == 'radio') {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']];
                    } elseif ($option['type'] == 'select') {
                        $tmpchoiceid = $tmpidentifiervalue = array();
                        foreach (explode('.', $optiondata[$optionid]['value']) as $choiceid) {
                            $tmpchoiceid[] = $choiceid;
                            $tmpidentifiervalue[] = $option['choices'][implode('.', $tmpchoiceid)];
                        }
                        $_G['forum_option'][$option['identifier']]['value'] = implode(' &raquo; ', $tmpidentifiervalue);
                        unset($tmpchoiceid, $tmpidentifiervalue);
                    } elseif ($option['type'] == 'image') {
                        $imgoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $threadsortshow['sortaids'][] = $imgoptiondata['aid'];
                        if (empty($templatearray['viewthread'])) {
                            $maxwidth = $option['maxwidth'] ? 'width="' . $option['maxwidth'] . '"' : '';
                            $maxheight = $option['maxheight'] ? 'height="' . $option['maxheight'] . '"' : '';
                            if (!defined('IN_MOBILE')) {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"" . $imgoptiondata['url'] . "\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                            } else {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href=\"" . $imgoptiondata['url'] . "\" target=\"_blank\">" . lang('forum/misc', 'click_view') . "</a>" : '';
                            }
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif';
                        }
                    } elseif ($option['type'] == 'face') {
                        $faceoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $_G['forum_option'][$option['identifier']]['value'] = "forum.php?mod=attachment&aid=" . aidencode($faceoptiondata['aid']);
                        $attach = C::t('forum_attachment')->fetch($faceoptiondata['aid']);
                        $_G['forum_option'][$option['identifier']]['downloads'] = $attach['downloads'];
                        $threadsortshow['sortaids'][] = $faceoptiondata['aid'];
                    } elseif ($option['type'] == 'url') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href=\"" . $optiondata[$optionid]['value'] . "\" target=\"_blank\">" . $optiondata[$optionid]['value'] . "</a>" : '';
                    } elseif ($option['type'] == 'number') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'];
                    } else {
                        if ($option['protect']['status'] && $optiondata[$optionid]['value']) {
                            $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="' . stringtopic($optiondata[$optionid]['value']) . '">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_' . $option['identifier'] . '"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid=' . $tid . '&optionid=' . $optionid . '\', \'sortmessage_' . $option['identifier'] . '\');return false;">' . lang('forum/misc', 'click_view') . '</a></span>' : $optiondata[$optionid]['value']);
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        } elseif ($option['type'] == 'textarea') {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? nl2br($optiondata[$optionid]['value']) : '';
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        }
                    }
                } else {
                    if (empty($option['permprompt'])) {
                        $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm');
                    } else {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt'];
                    }
                }
            } else {
                $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired');
            }
        }
        $typetemplate = '';
        if ($templatearray['viewthread']) {
            foreach ($sortoptionarray as $option) {
                $searchtitle[] = '/{(' . $option['identifier'] . ')}/e';
                $searchvalue[] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                $searchvalue[] = '/{(' . $option['identifier'] . ')_value}/e';
                $searchunit[] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                $searchunit[] = '/{(' . $option['identifier'] . ')_unit}/e';
                $searchdownloads[] = '/\\[(' . $option['identifier'] . ')downloads\\]/e';
                $searchdownloads[] = '/{(' . $option['identifier'] . ')_downloads}/e';
            }
            $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired');
            $typetemplate = preg_replace(array("/\\{expiration\\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread']));
            $typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $typetemplate);
            $typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
            $typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
            $typetemplate = preg_replace($searchdownloads, "showoption('\\1', 'downloads')", $typetemplate);
            $typetemplate = str_replace("{vanfon_uid}", $vanfon_uid, $typetemplate);
            $typetemplate = str_replace("{vanfon_pid}", $vanfon_tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_tid}", $tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_fid}", $vanfon_fid, $typetemplate);
            $typetemplate = str_replace("{vanfon_verify}", $vanfon_verify, $typetemplate);
            $typetemplate = str_replace("{vanfon_usergroup}", $vanfon_usergroup, $typetemplate);
        }
    }
    $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire';
    $threadsortshow['typetemplate'] = $typetemplate;
    $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd');
    return $threadsortshow;
}
function threadsortshow($sortid, $tid)
{
    global $_G;
    loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
    $sortoptionarray = $_G['cache']['threadsort_option_' . $sortid];
    $templatearray = $_G['cache']['threadsort_template_' . $sortid];
    $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array();
    if ($sortoptionarray) {
        foreach (C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) {
            $optiondata[$option['optionid']]['value'] = $option['value'];
            $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0;
            $sortdataexpiration = $option['expiration'];
        }
        foreach ($sortoptionarray as $optionid => $option) {
            $_G['forum_option'][$option['identifier']]['title'] = $option['title'];
            $_G['forum_option'][$option['identifier']]['unit'] = $option['unit'];
            $_G['forum_option'][$option['identifier']]['type'] = $option['type'];
            if ($option['expiration'] && !$optiondata[$optionid]['expiration'] || empty($option['expiration'])) {
                if (!protectguard($option['protect'])) {
                    if ($option['type'] == 'checkbox') {
                        $_G['forum_option'][$option['identifier']]['value'] = '';
                        foreach (explode("\t", $optiondata[$optionid]['value']) as $choiceid) {
                            $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid] . '&nbsp;';
                        }
                    } elseif ($option['type'] == 'radio') {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']];
                    } elseif ($option['type'] == 'select') {
                        $tmpchoiceid = $tmpidentifiervalue = array();
                        foreach (explode('.', $optiondata[$optionid]['value']) as $choiceid) {
                            $tmpchoiceid[] = $choiceid;
                            $tmpidentifiervalue[] = $option['choices'][implode('.', $tmpchoiceid)];
                        }
                        $_G['forum_option'][$option['identifier']]['value'] = implode(' &raquo; ', $tmpidentifiervalue);
                        unset($tmpchoiceid, $tmpidentifiervalue);
                    } elseif ($option['type'] == 'image') {
                        $imgoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $threadsortshow['sortaids'][] = $imgoptiondata['aid'];
                        if (empty($templatearray['viewthread'])) {
                            $maxwidth = $option['maxwidth'] ? 'width="' . $option['maxwidth'] . '"' : '';
                            $maxheight = $option['maxheight'] ? 'height="' . $option['maxheight'] . '"' : '';
                            if (!defined('IN_MOBILE')) {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"" . $imgoptiondata['url'] . "\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                            } else {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href=\"" . $imgoptiondata['url'] . "\" target=\"_blank\">" . lang('forum/misc', 'click_view') . "</a>" : '';
                            }
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif';
                        }
                    } elseif ($option['type'] == 'url') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href=\"" . $optiondata[$optionid]['value'] . "\" target=\"_blank\">" . $optiondata[$optionid]['value'] . "</a>" : '';
                    } elseif ($option['type'] == 'number') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'];
                    } else {
                        if ($option['protect']['status'] && $optiondata[$optionid]['value']) {
                            $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="' . stringtopic($optiondata[$optionid]['value']) . '">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_' . $option['identifier'] . '"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid=' . $tid . '&optionid=' . $optionid . '\', \'sortmessage_' . $option['identifier'] . '\');return false;">' . lang('forum/misc', 'click_view') . '</a></span>' : $optiondata[$optionid]['value']);
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        } elseif ($option['type'] == 'textarea') {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? nl2br($optiondata[$optionid]['value']) : '';
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        }
                    }
                } else {
                    if (empty($option['permprompt'])) {
                        $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm');
                    } else {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt'];
                    }
                }
            } else {
                $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired');
            }
        }
        $typetemplate = '';
        if ($templatearray['viewthread']) {
            foreach ($sortoptionarray as $option) {
                $searchtitle[] = '/{(' . $option['identifier'] . ')}/e';
                $searchvalue[] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                $searchvalue[] = '/{(' . $option['identifier'] . ')_value}/e';
                $searchunit[] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                $searchunit[] = '/{(' . $option['identifier'] . ')_unit}/e';
            }
            $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired');
            $typetemplate = preg_replace(array("/\\{expiration\\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread']));
            $typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $typetemplate);
            $typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
            $typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
        }
    }
    $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire';
    $threadsortshow['typetemplate'] = $typetemplate;
    $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd');
    return $threadsortshow;
}
function viewthread_procpost($post, $lastvisit, $ordertype, $maxposition = 0)
{
    global $_G, $rushreply;
    if (!$_G['forum_newpostanchor'] && $post['dateline'] > $lastvisit) {
        $post['newpostanchor'] = '<a name="newpost"></a>';
        $_G['forum_newpostanchor'] = 1;
    } else {
        $post['newpostanchor'] = '';
    }
    $post['lastpostanchor'] = $ordertype != 1 && $_G['forum_numpost'] == $_G['forum_thread']['replies'] || $ordertype == 1 && $_G['forum_numpost'] == $_G['forum_thread']['replies'] + 2 ? '<a name="lastpost"></a>' : '';
    if (!$post['hotrecommended']) {
        if ($_G['forum_pagebydesc']) {
            if ($ordertype != 1) {
                $post['number'] = $_G['forum_numpost'] + $_G['forum_ppp2']--;
            } else {
                $post['number'] = $post['first'] == 1 ? 1 : $_G['forum_numpost'] - 1 - $_G['forum_ppp2']--;
            }
        } else {
            if ($ordertype != 1) {
                $post['number'] = ++$_G['forum_numpost'];
            } else {
                $post['number'] = $post['first'] == 1 ? 1 : --$_G['forum_numpost'];
                $post['number'] = $post['number'] - 1;
            }
        }
    }
    if ($post['existinfirstpage']) {
        if ($_G['forum_pagebydesc']) {
            $_G['forum_ppp2']--;
        } else {
            if ($ordertype != 1) {
                ++$_G['forum_numpost'];
            } else {
                --$_G['forum_numpost'];
            }
        }
    }
    if ($maxposition) {
        $post['number'] = $post['position'];
    }
    if ($post['hotrecommended']) {
        $post['number'] = -1;
    }
    if (!$_G['forum_thread']['special'] && !$rushreply && !$hiddenreplies && $_G['setting']['threadfilternum'] && getstatus($post['status'], 11)) {
        $post['isWater'] = true;
        if ($_G['setting']['hidefilteredpost'] && !$_G['forum']['noforumhidewater']) {
            $post['inblacklist'] = true;
        }
    } else {
        $_G['allblocked'] = false;
    }
    if ($post['inblacklist']) {
        $_G['blockedpids'][] = $post['pid'];
    }
    $_G['forum_postcount']++;
    $post['dbdateline'] = $post['dateline'];
    $post['dateline'] = dgmdate($post['dateline'], 'u', '9999', getglobal('setting/dateformat') . ' H:i:s');
    $post['groupid'] = $_G['cache']['usergroups'][$post['groupid']] ? $post['groupid'] : 7;
    if ($post['username']) {
        $_G['forum_onlineauthors'][$post['authorid']] = 0;
        $post['usernameenc'] = rawurlencode($post['username']);
        $post['readaccess'] = $_G['cache']['usergroups'][$post['groupid']]['readaccess'];
        if ($_G['cache']['usergroups'][$post['groupid']]['userstatusby'] == 1) {
            $post['authortitle'] = $_G['cache']['usergroups'][$post['groupid']]['grouptitle'];
            $post['stars'] = $_G['cache']['usergroups'][$post['groupid']]['stars'];
        }
        $post['upgradecredit'] = false;
        if ($_G['cache']['usergroups'][$post['groupid']]['type'] == 'member' && $_G['cache']['usergroups'][$post['groupid']]['creditslower'] != 999999999) {
            $post['upgradecredit'] = $_G['cache']['usergroups'][$post['groupid']]['creditslower'] - $post['credits'];
            $post['upgradeprogress'] = 100 - ceil($post['upgradecredit'] / ($_G['cache']['usergroups'][$post['groupid']]['creditslower'] - $_G['cache']['usergroups'][$post['groupid']]['creditshigher']) * 100);
            $post['upgradeprogress'] = min(max($post['upgradeprogress'], 2), 100);
        }
        $post['taobaoas'] = addslashes($post['taobao']);
        $post['regdate'] = dgmdate($post['regdate'], 'd');
        $post['lastdate'] = dgmdate($post['lastvisit'], 'd');
        $post['authoras'] = !$post['anonymous'] ? ' ' . addslashes($post['author']) : '';
        if ($post['medals']) {
            loadcache('medals');
            foreach ($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
                list($medalid, $medalexpiration) = explode("|", $medalid);
                if (isset($_G['cache']['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > TIMESTAMP)) {
                    $post['medals'][$key] = $_G['cache']['medals'][$medalid];
                    $post['medals'][$key]['medalid'] = $medalid;
                    $_G['medal_list'][$medalid] = $_G['cache']['medals'][$medalid];
                } else {
                    unset($post['medals'][$key]);
                }
            }
        }
        $post['avatar'] = avatar($post['authorid']);
        $post['groupicon'] = $post['avatar'] ? g_icon($post['groupid'], 1) : '';
        $post['banned'] = $post['status'] & 1;
        $post['warned'] = ($post['status'] & 2) >> 1;
    } else {
        if (!$post['authorid']) {
            $post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')) . '.x';
        }
    }
    $post['attachments'] = array();
    $post['imagelist'] = $post['attachlist'] = '';
    if ($post['attachment']) {
        if (!empty($_G['setting']['guestviewthumb']['flag']) && !$_G['uid'] || $_G['group']['allowgetattach'] || $_G['group']['allowgetimage']) {
            $_G['forum_attachpids'][] = $post['pid'];
            $post['attachment'] = 0;
            if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $post['message'], $matchaids)) {
                $_G['forum_attachtags'][$post['pid']] = $matchaids[1];
            }
        } else {
            $post['message'] = preg_replace("/\\[attach\\](\\d+)\\[\\/attach\\]/i", '', $post['message']);
        }
    }
    if ($_G['setting']['ratelogrecord'] && $post['ratetimes']) {
        $_G['forum_cachepid'][$post['pid']] = $post['pid'];
    }
    if ($_G['setting']['commentnumber'] && ($post['first'] && $_G['setting']['commentfirstpost'] || !$post['first']) && $post['comment']) {
        $_G['forum_cachepid'][$post['pid']] = $post['pid'];
    }
    $post['allowcomment'] = $_G['setting']['commentnumber'] && in_array(1, $_G['setting']['allowpostcomment']) && ($_G['setting']['commentpostself'] || $post['authorid'] != $_G['uid']) && ($post['first'] && $_G['setting']['commentfirstpost'] && in_array($_G['group']['allowcommentpost'], array(1, 3)) || !$post['first'] && in_array($_G['group']['allowcommentpost'], array(2, 3)));
    $forum_allowbbcode = $_G['forum']['allowbbcode'] ? -$post['groupid'] : 0;
    $post['signature'] = $post['usesig'] ? $_G['setting']['sigviewcond'] ? strlen($post['message']) > $_G['setting']['sigviewcond'] ? $post['signature'] : '' : $post['signature'] : '';
    $imgcontent = $post['first'] ? getstatus($_G['forum_thread']['status'], 15) : 0;
    if (!defined('IN_ARCHIVER')) {
        if ($post['first']) {
            if (!defined('IN_MOBILE')) {
                $messageindex = false;
                if (strpos($post['message'], '[/index]') !== FALSE) {
                    $post['message'] = preg_replace("/\\s?\\[index\\](.+?)\\[\\/index\\]\\s?/ies", "parseindex('\\1', '{$post['pid']}')", $post['message']);
                    $messageindex = true;
                    unset($_GET['threadindex']);
                }
                if (strpos($post['message'], '[page]') !== FALSE) {
                    if ($_GET['cp'] != 'all') {
                        $postbg = '';
                        if (strpos($post['message'], '[/postbg]') !== FALSE) {
                            preg_match("/\\s?\\[postbg\\]\\s*([^\\[\\<\r\n;'\"\\?\\(\\)]+?)\\s*\\[\\/postbg\\]\\s?/is", $post['message'], $r);
                            $postbg = $r[0];
                        }
                        $messagearray = explode('[page]', $post['message']);
                        $cp = max(intval($_GET['cp']), 1);
                        $post['message'] = $messagearray[$cp - 1];
                        if ($postbg && strpos($post['message'], '[/postbg]') === FALSE) {
                            $post['message'] = $postbg . $post['message'];
                        }
                        unset($postbg);
                    } else {
                        $cp = 0;
                        $post['message'] = preg_replace("/\\s?\\[page\\]\\s?/is", '', $post['message']);
                    }
                    if ($_GET['cp'] != 'all' && strpos($post['message'], '[/index]') === FALSE && empty($_GET['threadindex']) && !$messageindex) {
                        $_G['forum_posthtml']['footer'][$post['pid']] .= '<div id="threadpage"></div><script type="text/javascript" reload="1">show_threadpage(' . $post['pid'] . ', ' . $cp . ', ' . count($messagearray) . ', ' . ($_GET['from'] == 'preview' ? '1' : '0') . ');</script>';
                    }
                }
            }
        }
        if (!empty($_GET['threadindex'])) {
            $_G['forum_posthtml']['header'][$post['pid']] .= '<div id="threadindex"></div><script type="text/javascript" reload="1">show_threadindex(0, ' . ($_GET['from'] == 'preview' ? '1' : '0') . ');</script>';
        }
        if (!$imgcontent) {
            $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, $_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0, $_G['forum']['allowhtml'], $_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0, 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);
            if ($post['first']) {
                $_G['relatedlinks'] = '';
                $relatedtype = !$_G['forum_thread']['isgroup'] ? 'forum' : 'group';
                if (!$_G['setting']['relatedlinkstatus']) {
                    $_G['relatedlinks'] = get_related_link($relatedtype);
                } else {
                    $post['message'] = parse_related_link($post['message'], $relatedtype);
                }
                if (strpos($post['message'], '[/begin]') !== FALSE) {
                    $post['message'] = preg_replace("/\\[begin(=\\s*([^\\[\\<\r\n]*?)\\s*,(\\d*),(\\d*),(\\d*),(\\d*))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/begin\\]/ies", $_G['cache']['usergroups'][$post['groupid']]['allowbegincode'] ? "parsebegin('\\2', '\\7', '\\3', '\\4', '\\5', '\\6');" : '', $post['message']);
                }
            }
        }
    }
    if (defined('IN_ARCHIVER') || defined('IN_MOBILE') || !$post['first']) {
        if (strpos($post['message'], '[page]') !== FALSE) {
            $post['message'] = preg_replace("/\\s?\\[page\\]\\s?/is", '', $post['message']);
        }
        if (strpos($post['message'], '[/index]') !== FALSE) {
            $post['message'] = preg_replace("/\\s?\\[index\\](.+?)\\[\\/index\\]\\s?/is", '', $post['message']);
        }
        if (strpos($post['message'], '[/begin]') !== FALSE) {
            $post['message'] = preg_replace("/\\[begin(=\\s*([^\\[\\<\r\n]*?)\\s*,(\\d*),(\\d*),(\\d*),(\\d*))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/begin\\]/ies", '', $post['message']);
        }
    }
    if ($imgcontent) {
        $post['message'] = '<img id="threadimgcontent" src="./' . stringtopic('', $post['tid']) . '">';
    }
    $_G['forum_firstpid'] = intval($_G['forum_firstpid']);
    $post['numbercard'] = viewthread_numbercard($post);
    $post['mobiletype'] = getstatus($post['status'], 4) ? base_convert(getstatus($post['status'], 10) . getstatus($post['status'], 9) . getstatus($post['status'], 8), 2, 10) : 0;
    return $post;
}
 public function editpost($parameters)
 {
     $this->_init_parameters($parameters);
     $isfirstpost = $this->post['first'] ? 1 : 0;
     $isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid'];
     $this->param['audit'] = $this->post['invisible'] == -2 || $this->thread['displayorder'] == -2 ? $this->param['audit'] : 0;
     list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']);
     if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $isfirstpost && ($this->param['special'] || $this->param['sortid']))) {
         showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize']));
     }
     if (!$isorigauthor && !$this->group['allowanonymous']) {
         if ($this->post['anonymous'] && !$this->param['isanonymous']) {
             $this->param['isanonymous'] = 0;
             $this->param['threadupdatearr']['author'] = $this->post['author'];
             $anonymousadd = 0;
         } else {
             $this->param['isanonymous'] = $this->post['anonymous'];
             $anonymousadd = '';
         }
     } else {
         $this->param['threadupdatearr']['author'] = $this->param['isanonymous'] ? '' : $this->post['author'];
         $anonymousadd = $this->param['isanonymous'];
     }
     if ($isfirstpost) {
         if (trim($this->param['subject']) == '' && $this->thread['special'] != 2) {
             showmessage('post_sm_isnull');
         }
         if (!$this->param['sortid'] && !$this->thread['special'] && trim($this->param['message']) == '') {
             showmessage('post_sm_isnull');
         }
         $publishdate = null;
         if ($this->group['allowsetpublishdate'] && $this->thread['displayorder'] == -4) {
             $cron_publish_ids = dunserialize($this->cache('cronpublish'));
             if (!$this->param['cronpublish'] && in_array($this->thread['tid'], $cron_publish_ids) || $this->param['modnewthreads']) {
                 $this->param['threadupdatearr']['dateline'] = $publishdate = TIMESTAMP;
                 unset($cron_publish_ids[$this->thread['tid']]);
                 $cron_publish_ids = serialize($cron_publish_ids);
                 savecache('cronpublish', $cron_publish_ids);
             } elseif ($this->param['cronpublish'] && $this->param['cronpublishdate']) {
                 $this->param['threadupdatearr']['dateline'] = $publishdate = strtotime($this->param['cronpublishdate']);
                 $this->param['save'] = 1;
                 if (!in_array($this->thread['tid'], $cron_publish_ids)) {
                     $cron_publish_ids[$this->thread['tid']] = $this->thread['tid'];
                     $cron_publish_ids = serialize($cron_publish_ids);
                     savecache('cronpublish', $cron_publish_ids);
                 }
             }
         }
         $this->param['readperm'] = $this->group['allowsetreadperm'] ? intval($this->param['readperm']) : ($isorigauthor ? 0 : 'ignore');
         if ($this->thread['special'] != 3) {
             $this->param['price'] = intval($this->param['price']);
             $this->param['price'] = $this->thread['price'] < 0 && !$this->thread['special'] ? $isorigauthor || !$this->param['price'] ? -1 : $this->param['price'] : ($this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] > 0 ? $this->param['price'] : 0 : $this->group['maxprice'] : ($isorigauthor ? $this->param['price'] : $this->thread['price']));
             if ($this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) {
                 return $this->showmessage('post_net_price_iszero');
             }
         }
         $this->thread['status'] = setstatus(4, $this->param['ordertype'], $this->thread['status']);
         $this->thread['status'] = setstatus(15, $this->param['imgcontent'], $this->thread['status']);
         if ($this->param['imgcontent']) {
             stringtopic($this->param['message'], $this->post['tid'], true, $this->param['imgcontentwidth']);
         }
         $this->thread['status'] = setstatus(2, $this->param['hiddenreplies'], $this->thread['status']);
         $this->thread['status'] = setstatus(6, $this->param['allownoticeauthor'] ? 1 : 0, $this->thread['status']);
         $displayorder = empty($this->param['save']) ? $this->thread['displayorder'] == -4 ? -4 : $this->thread['displayorder'] : -4;
         $this->param['threadupdatearr']['typeid'] = $this->param['typeid'];
         $this->param['threadupdatearr']['sortid'] = $this->param['sortid'];
         $this->param['threadupdatearr']['subject'] = $this->param['subject'];
         if ($this->param['readperm'] !== 'ignore') {
             $this->param['threadupdatearr']['readperm'] = $this->param['readperm'];
         }
         $this->param['threadupdatearr']['price'] = $this->param['price'];
         $this->param['threadupdatearr']['status'] = $this->thread['status'];
         if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
             $this->param['threadupdatearr']['displayorder'] = 0;
             $this->param['threadupdatearr']['moderated'] = 1;
         } else {
             $this->param['threadupdatearr']['displayorder'] = $displayorder;
         }
         C::t('forum_thread')->update($this->thread['tid'], $this->param['threadupdatearr'], true);
         if ($this->thread['tid'] > 1) {
             if ($this->thread['closed'] > 1) {
                 C::t('forum_thread')->update($this->thread['closed'], array('subject' => $this->param['subject']), true);
             } elseif (empty($this->thread['isgroup'])) {
                 $threadclosed = C::t('forum_threadclosed')->fetch($thread['tid']);
                 if ($threadclosed['redirect']) {
                     C::t('forum_thread')->update($threadclosed['redirect'], array('subject' => $this->param['subject']), true);
                 }
             }
         }
         $class_tag = new tag();
         $tagstr = $class_tag->update_field($this->param['tags'], $this->thread['tid'], 'tid', $this->thread);
     } else {
         if ($this->param['subject'] == '' && $this->param['message'] == '' && $this->thread['special'] != 2) {
             showmessage('post_sm_isnull');
         }
     }
     $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0;
     if ($this->setting['editedby'] && TIMESTAMP - $this->post['dateline'] > 60 && $this->member['adminid'] != 1) {
         $editor = $this->param['isanonymous'] && $isorigauthor ? lang('forum/misc', 'anonymous') : $this->member['username'];
         $edittime = dgmdate(TIMESTAMP);
         $this->param['message'] = lang('forum/misc', $this->param['htmlon'] ? 'post_edithtml' : (!$this->forum['allowbbcode'] || $this->param['bbcodeoff'] ? 'post_editnobbcode' : 'post_edit'), array('editor' => $editor, 'edittime' => $edittime)) . $this->param['message'];
     }
     $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff']));
     $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff']));
     $tagoff = $isfirstpost ? !empty($tagoff) : 0;
     if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
         C::t('forum_post')->update($this->thread['posttableid'], $this->post['pid'], array('status' => 4), false, false, null, -2, null, 0);
         updatepostcredits('+', $this->post['authorid'], $isfirstpost ? 'post' : 'reply', $this->forum['fid']);
         updatemodworks('MOD', 1);
         updatemodlog($this->thread['tid'], 'MOD');
     }
     $displayorder = $pinvisible = 0;
     if ($isfirstpost) {
         $displayorder = $this->param['modnewthreads'] ? -2 : $this->thread['displayorder'];
         $pinvisible = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3);
     } else {
         $pinvisible = $this->param['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
     }
     $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']);
     $this->param['parseurloff'] = !empty($this->param['parseurloff']);
     $setarr = array('message' => $this->param['message'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'parseurloff' => $this->param['parseurloff'], 'smileyoff' => $this->param['smileyoff'], 'subject' => $this->param['subject'], 'tags' => $tagstr, 'port' => getglobal('remoteport'));
     $setarr['status'] = $this->post['status'];
     if ($this->param['modstatus']) {
         foreach ($this->param['modstatus'] as $modbit => $modvalue) {
             $setarr['status'] = setstatus($modbit, $modvalue, $setarr['status']);
         }
     }
     if ($anonymousadd !== '') {
         $setarr['anonymous'] = $anonymousadd;
     }
     if ($publishdate) {
         $setarr['dateline'] = $publishdate;
     }
     if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
         $setarr['invisible'] = 0;
     } else {
         $setarr['invisible'] = $pinvisible;
     }
     C::t('forum_post')->update('tid:' . $this->thread['tid'], $this->post['pid'], $setarr);
     $this->forum['lastpost'] = explode("\t", $this->forum['lastpost']);
     if ($this->post['dateline'] == $this->forum['lastpost'][2] && ($this->post['author'] == $this->forum['lastpost'][3] || $this->forum['lastpost'][3] == '' && $this->post['anonymous'])) {
         $lastpost = $this->thread['tid'] . "\t" . ($isfirstpost ? $this->param['subject'] : $this->thread['subject']) . "\t" . $this->post['dateline'] . "\t" . ($this->param['isanonymous'] ? '' : $this->post['author']);
         C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost));
     }
     if (!getglobal('forum_auditstatuson') || $this->param['audit'] != 1) {
         if ($isfirstpost && $this->param['modnewthreads']) {
             C::t('forum_thread')->update($this->thread['tid'], array('displayorder' => -2));
             manage_addnotify('verifythread');
         } elseif (!$isfirstpost && $this->param['modnewreplies']) {
             C::t('forum_thread')->increase($this->thread['tid'], array('replies' => -1));
             manage_addnotify('verifypost');
         }
         if ($this->param['modnewreplies'] || $this->param['modnewthreads']) {
             C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1'));
         }
     }
     if ($this->thread['lastpost'] == $this->post['dateline'] && (!$this->post['anonymous'] && $this->thread['lastposter'] == $this->post['author'] || $this->post['anonymous'] && $this->thread['lastposter'] == '') && $this->post['anonymous'] != $this->param['isanonymous']) {
         C::t('forum_thread')->update($this->thread['tid'], array('lastposter' => $this->param['isanonymous'] ? '' : $this->post['author']), true);
     }
     if (!$isorigauthor) {
         updatemodworks('EDT', 1);
         require_once libfile('function/misc');
         modlog($this->thread, 'EDT');
     }
     if ($isfirstpost && $this->thread['displayorder'] == -4 && empty($this->param['save'])) {
         threadpubsave($this->thread['tid']);
     }
 }