예제 #1
0
     $query2 = $db->query("SELECT pid, first, authorid FROM {$tablepre}posts WHERE tid IN ({$tidsdelete})");
     while (($post = $db->fetch_array($query1)) || ($post = $db->fetch_array($query2))) {
         $postsarray[$post['pid']] = $post;
     }
     foreach ($postsarray as $post) {
         if ($post['first']) {
             $tuidarray[] = $post['authorid'];
         } else {
             $ruidarray[] = $post['authorid'];
         }
     }
     if ($tuidarray) {
         updatepostcredits('-', $tuidarray, $creditspolicy['post']);
     }
     if ($ruidarray) {
         updatepostcredits('-', $ruidarray, $creditspolicy['reply']);
     }
 }
 $db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ({$pidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}threads WHERE tid IN ({$tidsdelete})");
 $deletedthreads = $db->affected_rows();
 $db->query("DELETE FROM {$tablepre}posts WHERE pid IN ({$pidsdelete})");
 $deletedposts = $db->affected_rows();
 $db->query("DELETE FROM {$tablepre}posts WHERE tid IN ({$tidsdelete})");
 $deletedposts += $db->affected_rows();
 $db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}polls WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
 $db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ({$tidsdelete})", 'UNBUFFERED');
예제 #2
0
function undeletethreads($tids)
{
    global $_G;
    $threadsundel = 0;
    if ($tids && is_array($tids)) {
        foreach ($tids as $t) {
            my_thread_log('restore', array('tid' => $t));
        }
        $tids = '\'' . implode('\',\'', $tids) . '\'';
        $tuidarray = $ruidarray = $fidarray = array();
        $postarray = getfieldsofposts('fid, first, authorid', "tid IN ({$tids})");
        foreach ($postarray as $post) {
            if ($post['first']) {
                $tuidarray[] = $post['authorid'];
            } else {
                $ruidarray[] = $post['authorid'];
            }
            if (!in_array($post['fid'], $fidarray)) {
                $fidarray[] = $post['fid'];
            }
        }
        if ($tuidarray) {
            updatepostcredits('+', $tuidarray, 'post');
        }
        if ($ruidarray) {
            updatepostcredits('+', $ruidarray, 'reply');
        }
        updatepost(array('invisible' => '0'), "tid IN ({$tids})", true);
        DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='0', moderated='1' WHERE tid IN ({$tids})");
        $threadsundel = DB::affected_rows();
        updatemodlog($tids, 'UDL');
        updatemodworks('UDL', $threadsundel);
        foreach ($fidarray as $fid) {
            updateforumcount($fid);
        }
    }
    return $threadsundel;
}
예제 #3
0
 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';
     }
 }
예제 #4
0
 if (!empty($_GET['commentitem']) && !empty($_G['uid']) && $post['authorid'] != $_G['uid']) {
     foreach ($_GET['commentitem'] as $itemk => $itemv) {
         if ($itemv !== '') {
             $commentscore .= strip_tags(trim($itemk)) . ': <i>' . intval($itemv) . '</i> ';
         }
     }
 }
 $comment = cutstr(($commentscore ? $commentscore . '<br />' : '') . censor(trim(dhtmlspecialchars($_GET['message'])), '***'), 200, ' ');
 if (!$comment) {
     showmessage('post_sm_isnull');
 }
 $pcid = C::t('forum_postcomment')->insert(array('tid' => $post['tid'], 'pid' => $post['pid'], 'author' => $_G['username'], 'authorid' => $_G['uid'], 'dateline' => TIMESTAMP, 'comment' => $comment, 'score' => $commentscore ? 1 : 0, 'useip' => $_G['clientip'], 'port' => $_G['remoteport']), true);
 C::t('forum_post')->update('tid:' . $_G['tid'], $_GET['pid'], array('comment' => 1));
 $comments = $thread['comments'] ? $thread['comments'] + 1 : C::t('forum_postcomment')->count_by_tid($_G['tid']);
 C::t('forum_thread')->update($_G['tid'], array('comments' => $comments));
 !empty($_G['uid']) && updatepostcredits('+', $_G['uid'], 'reply', $_G['fid']);
 if (!empty($_G['uid']) && $_G['uid'] != $post['authorid']) {
     notification_add($post['authorid'], 'pcomment', 'comment_add', array('tid' => $_G['tid'], 'pid' => $_GET['pid'], 'subject' => $thread['subject'], 'from_id' => $_G['tid'], 'from_idtype' => 'pcomment', 'commentmsg' => cutstr(str_replace(array('[b]', '[/b]', '[/color]'), '', preg_replace("/\\[color=([#\\w]+?)\\]/i", "", $comment)), 200)));
 }
 update_threadpartake($post['tid']);
 $pcid = C::t('forum_postcomment')->fetch_standpoint_by_pid($_GET['pid']);
 $pcid = $pcid['id'];
 if (!empty($_G['uid']) && $_GET['commentitem']) {
     $totalcomment = array();
     foreach (C::t('forum_postcomment')->fetch_all_by_pid_score($_GET['pid'], 1) as $comment) {
         $comment['comment'] = addslashes($comment['comment']);
         if (strexists($comment['comment'], '<br />')) {
             if (preg_match_all("/([^:]+?):\\s<i>(\\d+)<\\/i>/", $comment['comment'], $a)) {
                 foreach ($a[1] as $k => $itemk) {
                     $totalcomment[trim($itemk)][] = $a[2][$k];
                 }
예제 #5
0
function undeletethreads($tids)
{
    global $db, $tablepre, $creditspolicy;
    $threadsundel = 0;
    if ($tids && is_array($tids)) {
        $tids = '\'' . implode('\',\'', $tids) . '\'';
        $tuidarray = $ruidarray = $fidarray = array();
        $query = $db->query("SELECT fid, first, authorid FROM {$tablepre}posts WHERE tid IN ({$tids})");
        while ($post = $db->fetch_array($query)) {
            if ($post['first']) {
                $tuidarray[] = $post['authorid'];
            } else {
                $ruidarray[] = $post['authorid'];
            }
            if (!in_array($post['fid'], $fidarray)) {
                $fidarray[] = $post['fid'];
            }
        }
        if ($tuidarray) {
            updatepostcredits('+', $tuidarray, $creditspolicy['post']);
        }
        if ($ruidarray) {
            updatepostcredits('+', $ruidarray, $creditspolicy['reply']);
        }
        $db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ({$tids})", 'UNBUFFERED');
        $db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ({$tids})");
        $threadsundel = $db->affected_rows();
        updatemodlog($tids, 'UDL');
        updatemodworks('UDL', $threadsundel);
        foreach ($fidarray as $fid) {
            updateforumcount($fid);
        }
    }
    return $threadsundel;
}
예제 #6
0
 $query = DB::query("SELECT pid, authorid, dateline, message, first FROM " . DB::table($posttable) . " WHERE pid IN ({$deletepids}) AND tid='{$_G['tid']}'");
 while ($post = DB::fetch($query)) {
     if (!$post['first']) {
         $posts[] = $post;
         $pids .= $comma . $post['pid'];
         if ($post['dateline'] < $losslessdel) {
             updatemembercount($post['authorid'], array('posts' => -1), false);
         } else {
             $puidarray[] = $post['authorid'];
         }
         $modpostsnum++;
         $comma = ',';
     }
 }
 if ($puidarray) {
     updatepostcredits('-', $puidarray, 'reply', $_G['fid']);
 }
 if ($pids) {
     $query = DB::query("SELECT uid, attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$pids})");
 }
 while ($attach = DB::fetch($query)) {
     if (in_array($attach['uid'], $puidarray)) {
         $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
     }
     dunlink($attach);
 }
 if ($auidarray) {
     updateattachcredits('-', $auidarray, $postattachcredits);
 }
 $logs = array();
 if ($pids) {
예제 #7
0
         updatemodworks('MOD', $rows);
         C::t('forum_post')->update_by_tid(0, explode(',', $recyclebintids), array('invisible' => -1), true);
         updatemodlog($recyclebintids, 'DEL');
     }
     require_once libfile('function/delete');
     deletethread($deletetids);
     updatemoderate('tid', $moderation['delete'], 2);
 }
 if ($validatetids = dimplode($moderation['validate'])) {
     $tids = $moderatedthread = array();
     foreach (C::t('forum_thread')->fetch_all_by_tid_displayorder($moderation['validate'], $pstat, '=', $modfids ? explode(',', $modfids) : null) as $thread) {
         $tids[] = $thread['tid'];
         $poststatus = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
         $poststatus = $poststatus['status'];
         if (getstatus($poststatus, 3) == 0) {
             updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
             $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $thread['tid'], 'tid', $thread['tid']);
             updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']);
         }
         $validatedthreads[] = $thread;
         if ($thread['authorid'] && $thread['authorid'] != $_G['uid']) {
             $pmlist[] = array('act' => 'modthreads_validate', 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'tid' => $thread['tid'], 'threadsubject' => $thread['subject'], 'from_id' => 0, 'from_idtype' => 'modthreads'), 'authorid' => $thread['authorid']);
         }
     }
     if ($tids) {
         $tidstr = dimplode($tids);
         C::t('forum_post')->update_by_tid(0, $tids, array('invisible' => 0), true, false, 1);
         C::t('forum_thread')->update($tids, array('displayorder' => 0, 'moderated' => 1));
         $threadsmod = DB::affected_rows();
         if ($_G['fid']) {
             updateforumcount($_G['fid']);
예제 #8
0
                    $feed['body_data'] = array('subject' => "<a href=\"{$boardurl}viewthread.php?tid={$tid}\">{$subject}</a>", 'play' => "<a href=\"{$boardurl}viewthread.php?tid={$tid}\" class=\"playbutton\">Play</a>", 'message' => cutstr(strip_tags(preg_replace(array("/\\[hide=?\\d*\\].+?\\[\\/hide\\]/is", "/\\[.+?\\]/is"), array('', ''), $message)), 150), 'vlength' => sprintf("%02d", intval($vlength / 60)) . ':' . sprintf("%02d", intval($vlength % 60)));
                }
            }
            if ($special == 6) {
                $feed['images'][] = array('url' => VideoClient_Util::getThumbUrl($vid, 'small'), 'link' => "{$boardurl}viewthread.php?tid={$tid}");
            } else {
                if (in_array($attachments[1]['type'], array('image/gif', 'image/jpeg', 'image/png'))) {
                    $attachurl = preg_match("/^((https?|ftps?):\\/\\/|www\\.)/i", $attachurl) ? $attachurl : $boardurl . $attachurl;
                    $imgurl = $attachurl . '/' . $attachments[1]['attachment'] . ($attachments[1]['thumb'] && $attachments[1]['type'] != 'image/gif' ? '.thumb.jpg' : '');
                    $feed['images'][] = $attachments[1]['attachment'] ? array('url' => $imgurl, 'link' => "{$boardurl}viewthread.php?tid={$tid}") : array();
                }
            }
            if ($feed) {
                postfeed($feed);
            }
        }
        if ($digest) {
            foreach ($digestcredits as $id => $addcredits) {
                $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits;
            }
        }
        updatepostcredits('+', $discuz_uid, $postcredits);
        $subject = str_replace("\t", ' ', $subject);
        $lastpost = "{$tid}\t{$subject}\t{$timestamp}\t{$author}";
        $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$fid}'", 'UNBUFFERED');
        if ($forum['type'] == 'sub') {
            $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}' WHERE fid='{$forum['fup']}'", 'UNBUFFERED');
        }
        showmessage('post_newthread_succeed', "viewthread.php?tid={$tid}&extra={$extra}");
    }
}
예제 #9
0
 private function sendPost($extract)
 {
     global $_G;
     extract($extract);
     // 获取主题和帖子要插入的状态信息
     $topicStatus = ForumUtils::getPostSendStatus('topic', $_GET['platType']);
     $postStatus = ForumUtils::getPostSendStatus('post', $_GET['platType']);
     //copy from dz source/include/post/post_newthread.php
     if (empty($_G['forum']['fid']) || $_G['forum']['type'] == 'group') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_nonexistence');
     }
     if ($special == 1 && !$_G['group']['allowpostpoll'] || $special == 2 && !$_G['group']['allowposttrade'] || $special == 3 && !$_G['group']['allowpostreward'] || $special == 4 && !$_G['group']['allowpostactivity'] || $special == 5 && !$_G['group']['allowpostdebate']) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle']));
     }
     if (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
         if (!defined('IN_MOBILE')) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission', array('{login}' => 1));
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission_mobile', array('{login}' => 1));
         }
     } elseif (empty($_G['forum']['allowpost'])) {
         if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_none_nopermission');
         } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
             $msg = mobcent_showmessagenoperm('postperm', $_G['fid'], $_G['forum']['formulaperm']);
             return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']);
         }
     } elseif ($_G['forum']['allowpost'] == -1) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_forum_newthread_nopermission');
     }
     if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission');
     }
     if (trim($subject) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if (!$sortid && !$special && trim($message) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if ($post_invalid = checkpost($subject, $message, $special || $sortid)) {
         return WebUtils::makeErrorInfo_oldVersion($res, $post_invalid, array('{minpostsize}' => $_G['setting']['minpostsize'], '{maxpostsize}' => $_G['setting']['maxpostsize']));
         //showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
     }
     if (checkflood()) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl']));
     } elseif (checkmaxperhour('tid')) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'thread_flood_ctrl_threads_per_hour', array('{threads_per_hour}' => $_G['group']['maxthreadsperhour']));
     }
     $_GET['save'] = $_G['uid'] ? $_GET['save'] : 0;
     if ($_G['group']['allowsetpublishdate'] && $_GET['cronpublish'] && $_GET['cronpublishdate']) {
         $publishdate = strtotime($_GET['cronpublishdate']);
         if ($publishdate > $_G['timestamp']) {
             $_GET['save'] = 1;
         } else {
             $publishdate = $_G['timestamp'];
         }
     } else {
         $publishdate = $_G['timestamp'];
     }
     $typeid = isset($typeid) && isset($_G['forum']['threadtypes']['types'][$typeid]) && (empty($_G['forum']['threadtypes']['moderators'][$typeid]) || $_G['forum']['ismoderator']) ? $typeid : 0;
     $displayorder = $modnewthreads ? -2 : ($_G['forum']['ismoderator'] && $_G['group']['allowstickthread'] && !empty($_GET['sticktopic']) ? 1 : (empty($_GET['save']) ? 0 : -4));
     if ($displayorder == -2) {
         C::t('forum_forum')->update($_G['fid'], array('modworks' => '1'));
     } elseif ($displayorder == -4) {
         $_GET['addfeed'] = 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 WebUtils::makeErrorInfo_oldVersion($res, 'post_type_isnull');
     }
     //强制主题分类判断
     if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sort_isnull');
     }
     //主题售价 客户端暂不支持
     if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
         showmessage('post_net_price_iszero');
     }
     //投票贴相关
     if ($special == 1) {
         $polloption = $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption'];
         $pollarray = array();
         foreach ($polloption as $key => $value) {
             $polloption[$key] = censor($polloption[$key]);
             if (trim($value) === '') {
                 unset($polloption[$key]);
             }
         }
         if (count($polloption) > $_G['setting']['maxpolloptions']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $_G['setting']['maxpolloptions']));
         } elseif (count($polloption) < 2) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_inputmore');
         }
         $curpolloption = count($polloption);
         $pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
         $pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
         $pollarray['options'] = $polloption;
         $pollarray['visible'] = empty($_GET['visibilitypoll']);
         $pollarray['overt'] = !empty($_GET['overt']);
         if (preg_match("/^\\d*\$/", trim($_GET['expiration']))) {
             if (empty($_GET['expiration'])) {
                 $pollarray['expiration'] = 0;
             } else {
                 $pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['expiration'];
             }
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('poll_maxchoices_expiration_invalid');
         }
     }
     // 分类信息有效期
     $_GET['typeexpiration'] = $_GET['typeoption']['typeexpiration'];
     $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
     $typeexpiration = intval($_GET['typeexpiration']);
     if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'threadtype_expiration_invalid');
     }
     $_G['forum_optiondata'] = array();
     if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
         Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_threadsort.php');
         $_G['forum_optiondata'] = mobcent_threadsort_validator($_GET['typeoption'], $pid);
         if ($_G['forum_optiondata']['message'] != '') {
             return WebUtils::makeErrorInfo_oldVersion($res, $_G['forum_optiondata']['message'], $_G['forum_optiondata']['params']);
         }
     }
     $author = !$isanonymous ? $_G['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']));
     /*             if($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
              $_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
             $_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
             $_GET['rewardfloor'] = trim($_GET['rewardfloor']);
             $_GET['stopfloor'] = intval($_GET['stopfloor']);
             $_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
             if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_rushreply_timewrong');
             }
             if(($_GET['rushreplyfrom'] > $_G['timestamp']) || (!empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] == 1) ) {
             $closed = true;
             }
             if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
             $floors = explode(',', $_GET['rewardfloor']);
             if(!empty($floors) && is_array($floors)) {
             foreach($floors AS $key => $floor) {
             if(strpos($floor, '*') === false) {
             if(intval($floor) == 0) {
             unset($floors[$key]);
             } elseif($floor > $_GET['stopfloor']) {
             unset($floors[$key]);
             }
             }
             }
             $_GET['rewardfloor'] = implode(',', $floors);
             }
             }
             $thread['status'] = setstatus(3, 1, $thread['status']);
             $thread['status'] = setstatus(1, 1, $thread['status']);
             } */
     $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
     $isgroup = $_G['forum']['status'] == 3 ? 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($_GET['replycredit_extcredits'] > 0 && $_GET['replycredit_times'] > 0) {
             $replycredit_real = ceil(($_GET['replycredit_extcredits'] * $_GET['replycredit_times']) + ($_GET['replycredit_extcredits'] * $_GET['replycredit_times'] *  $_G['setting']['creditstax']));
             if($replycredit_real > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][10])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('replycredit_morethan_self');
             } else {
             $replycredit = ceil($_GET['replycredit_extcredits'] * $_GET['replycredit_times']);
             }
             }
             } */
     $newthread = array('fid' => $_G['fid'], 'posttableid' => 0, 'readperm' => $readperm, 'price' => $price, 'typeid' => $typeid, 'sortid' => $sortid, 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'lastpost' => $publishdate, 'lastposter' => $author, 'displayorder' => $displayorder, 'digest' => $digest, 'special' => $special, 'attachment' => 0, 'moderated' => $moderated, 'status' => $thread['status'] | $topicStatus, 'isgroup' => $isgroup, 'replycredit' => $replycredit, 'closed' => $closed ? 1 : 0);
     $tid = C::t('forum_thread')->insert($newthread, true);
     useractionlog($_G['uid'], 'tid');
     if (!getuserprofile('threads') && $_G['setting']['newbie']) {
         C::t('forum_thread')->update($tid, array('icon' => $_G['setting']['newbie']));
     }
     if ($publishdate != $_G['timestamp']) {
         loadcache('cronpublish');
         $cron_publish_ids = dunserialize($_G['cache']['cronpublish']);
         $cron_publish_ids[$tid] = $tid;
         $cron_publish_ids = serialize($cron_publish_ids);
         savecache('cronpublish', $cron_publish_ids);
     }
     if (!$isanonymous) {
         C::t('common_member_field_home')->update($_G['uid'], array('recentnote' => $subject));
     }
     if ($special == 3 && $_G['group']['allowpostreward']) {
         updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][2] => -$realprice), 1, 'RTC', $tid);
     }
     if ($moderated) {
         updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
         updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
     }
     /* if($special == 1) {
     
             foreach($pollarray['options'] as $polloptvalue) {
             $polloptvalue = dhtmlspecialchars(trim($polloptvalue));
             C::t('forum_polloption')->insert(array('tid' => $tid, 'polloption' => $polloptvalue));
             }
             $polloptionpreview = '';
             $query = C::t('forum_polloption')->fetch_all_by_tid($tid, 1, 2);
             foreach($query as $option) {
             $polloptvalue = preg_replace("/\[url=(https?){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $option['polloption']);
             $polloptionpreview .= $polloptvalue."\t";
             }
     
             $polloptionpreview = daddslashes($polloptionpreview);
     
             $data = array('tid' => $tid, 'multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
             C::t('forum_poll')->insert($data);
             } */
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata'])) {
         $filedname = $valuelist = $separator = '';
         foreach ($_G['forum_optiondata'] as $optionid => $value) {
             if ($value) {
                 $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier'];
                 $valuelist .= $separator . "'" . daddslashes($value) . "'";
                 $separator = ' ,';
             }
             if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
                 $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                 $sortaids[] = intval($_GET['typeoption'][$identifier]['aid']);
             }
             C::t('forum_typeoptionvar')->insert(array('sortid' => $sortid, 'tid' => $tid, 'fid' => $_G['fid'], 'optionid' => $optionid, 'value' => censor($value), 'expiration' => $typeexpiration ? $publishdate + $typeexpiration : 0));
         }
         if ($filedname && $valuelist) {
             C::t('forum_optionvalue')->insert($sortid, "({$filedname}, tid, fid) VALUES ({$valuelist}, '{$tid}', '{$_G['fid']}')");
         }
     }
     if ($_G['group']['allowat']) {
         $atlist = $atlist_tmp = array();
         preg_match_all("/@([^\r\n]*?)\\s/i", $message . ' ', $atlist_tmp);
         $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
         if (!empty($atlist_tmp)) {
             if (empty($_G['setting']['at_anyone'])) {
                 foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
                     $atlist[$row['followuid']] = $row['fusername'];
                 }
                 if (count($atlist) < $_G['group']['allowat']) {
                     $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
                     foreach ($query as $row) {
                         $atlist[$row['fuid']] = $row['fusername'];
                     }
                 }
             } else {
                 foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
                     $atlist[$row['uid']] = $row['username'];
                 }
             }
         }
         if ($atlist) {
             foreach ($atlist as $atuid => $atusername) {
                 $atsearch[] = "/@" . str_replace('/', '\\/', preg_quote($atusername)) . " /i";
                 $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] ";
             }
             $message = preg_replace($atsearch, $atreplace, $message . ' ', 1);
         }
     }
     $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff']));
     $smileyoff = checksmilies($message, !empty($_GET['smileyoff']));
     $parseurloff = !empty($_GET['parseurloff']);
     $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
     $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
     $class_tag = new tag();
     $tagstr = $class_tag->add_tag($_GET['tags'], $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);
        $insertdata = array(
                'tid' => $tid,
                'extcredits' => $_GET['replycredit_extcredits'],
                'extcreditstype' => $_G['setting']['creditstransextra'][10],
                'times' => $_GET['replycredit_times'],
                'membertimes' => $_GET['replycredit_membertimes'],
                'random' => $_GET['replycredit_random']
        );
        C::t('forum_replycredit')->insert($insertdata);
        }
        } */
     if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
         $rushdata = array('tid' => $tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit']);
         C::t('forum_threadrush')->insert($rushdata);
     }
     $pinvisible = $modnewthreads ? -2 : (empty($_GET['save']) ? 0 : -3);
     $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
     $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'tags' => $tagstr, 'replycredit' => 0, 'status' => (defined('IN_MOBILE') ? 8 : 0) | $postStatus));
     if ($_G['group']['allowat'] && $atlist) {
         foreach ($atlist as $atuid => $atusername) {
             notification_add($atuid, 'at', 'at_message', array('from_id' => $tid, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $tid, 'subject' => $subject, 'pid' => $pid, 'message' => messagecutstr($message, 150)));
         }
         set_atlist_cookie(array_keys($atlist));
     }
     $threadimageaid = 0;
     $threadimage = array();
     if ($special == 4 && $_GET['activityaid']) {
         $threadimageaid = $_GET['activityaid'];
         convertunusedattach($_GET['activityaid'], $tid, $pid);
     }
     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 = C::t('forum_attachment_n')->fetch_max_image('tid:' . $tid, 'tid', $tid);
             $threadimageaid = $threadimage['aid'];
         }
     }
     $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '', 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : '');
     $param = array();
     Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
     if ($_G['forum']['picstyle']) {
         if (!mobcent_setthreadcover($pid, 0, $threadimageaid)) {
             preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
             $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
             $param['clean_msgforward'] = 1;
             $param['timeout'] = $param['refreshtime'] = 15;
         }
     }
     if ($threadimageaid) {
         if (!$threadimage) {
             $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
         }
         $threadimage = daddslashes($threadimage);
         C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
     }
     $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]);
     if ($modnewthreads) {
         updatemoderate('tid', $tid);
         C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1);
         manage_addnotify('verifythread');
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_newthread_mod_succeed', array('noError' => 1));
         //showmessage('post_newthread_mod_succeed', $returnurl, $values, $param);
     } else {
         if ($displayorder >= 0 && helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) {
             require_once libfile('function/discuzcode');
             require_once libfile('function/followcode');
             $feedcontent = array('tid' => $tid, 'content' => followcode($message, $tid, $pid, 1000));
             C::t('forum_threadpreview')->insert($feedcontent);
             C::t('forum_thread')->update_status_by_tid($tid, '512');
             $followfeed = array('uid' => $_G['uid'], 'username' => $_G['username'], 'tid' => $tid, 'note' => '', 'dateline' => TIMESTAMP);
             $values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
             C::t('common_member_count')->increase($_G['uid'], array('feeds' => 1));
         }
         $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
         if ($displayorder != -4) {
             if ($digest) {
                 updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
             }
             //updatepostcredits('+',  $_G['uid'], 'post', $_G['fid']);
             Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
             //Yii::import('application.components.discuz.source.function.function_post', true);
             mobcent_updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
             if ($isgroup) {
                 C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 1);
             }
             $subject = str_replace("\t", ' ', $subject);
             $lastpost = "{$tid}\t" . $subject . "\t{$_G['timestamp']}\t{$author}";
             C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
             C::t('forum_forum')->update_forum_counter($_G['fid'], 1, 1, 1);
             if ($_G['forum']['type'] == 'sub') {
                 C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
             }
         }
         if ($_G['forum']['status'] == 3) {
             C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
             require_once libfile('function/grouplog');
             updategroupcreditlog($_G['fid'], $_G['uid']);
         }
         /*如果显示地理位置,入库到表里*/
         if ($jsonInfo['isShowPostion']) {
             $data = DB::query('INSERT INTO  %t VALUES(null,%f,%f,%d,%d,%s)', array('home_surrounding_user', $jsonInfo['longitude'], $jsonInfo['latitude'], $tid, 3, (string) $jsonInfo['location']));
         }
         /*  //客户端发表主题积分入库
                $temp = DB::fetch_first('SELECT extcredits3  FROM '.DB::table('common_credit_rule').' WHERE rid =%d ',array(1));
                $extcredits3 = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_member_count').' WHERE uid = %d',array($_G['uid']));
                $temp = $extcredits3['extcredits3'] + $temp['extcredits3'];
                DB::query('UPDATE '.DB::table('common_member_count').' set extcredits3 = %d WHERE uid = %d',array($temp,$_G['uid']));
             */
         //showmessage('post_newthread_succeed', $returnurl, $values, $param);
         // return array('rs'=>1,'errcode'=>WebUtils::t('发贴成功'));
         return $this->makeErrorInfo($res, 'mobcent_post_newthread_success', array('noError' => 1));
     }
 }
예제 #10
0
             } else {
                 $ruidarray[$post['fid']][] = $post['authorid'];
             }
             $fids[$post['fid']] = $post['fid'];
         }
     }
     if ($tuidarray) {
         foreach ($tuidarray as $fid => $uids) {
             $_G['fid'] = $fid;
             updatepostcredits('-', $uids, 'post');
         }
     }
     if ($ruidarray) {
         foreach ($ruidarray as $fid => $uids) {
             $_G['fid'] = $fid;
             updatepostcredits('-', $uids, 'reply');
         }
     }
     require_once libfile('function/delete');
     deletethread($moderate);
     DB::query("DELETE FROM " . DB::table('forum_postcomment') . " WHERE {$tidsadd} AND authorid='{$space['uid']}'");
     foreach ($fids as $fid) {
         updateforumcount(intval($fid));
     }
     foreach ($moderate as $tid) {
         my_thread_log('delete', array('tid' => $tid));
     }
     $_G['cache']['space_thread'][$alltype] = array();
     save_syscache('space_thread', $_G['cache']['space_thread']);
     showmessage('thread_delete_succeed', 'home.php?mod=space&uid=' . $space['uid'] . '&do=thread&view=all');
 }
예제 #11
0
 public function deletepost($parameters)
 {
     $this->_init_parameters($parameters);
     if (!$this->setting['editperdel']) {
         return $this->showmessage('post_edit_thread_ban_del', NULL);
     }
     $isfirstpost = $this->post['first'] ? 1 : 0;
     if ($isfirstpost && $this->thread['replies'] > 0) {
         return $this->showmessage($this->thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_thread_already_reply', NULL);
     }
     if ($this->thread['displayorder'] >= 0) {
         updatepostcredits('-', $this->post['authorid'], $isfirstpost ? 'post' : 'reply', $this->forum['fid']);
     }
     if (!$this->param['handlereplycredit']) {
         if (!$isfirstpost && !$this->param['isanonymous']) {
             $postreplycredit = C::t('forum_post')->fetch('tid:' . $this->thread['tid'], $this->post['pid']);
             $postreplycredit = $postreplycredit['replycredit'];
             if ($postreplycredit) {
                 C::t('forum_post')->update('tid:' . $this->thread['tid'], $this->post['pid'], array('replycredit' => 0));
                 updatemembercount($this->post['authorid'], array($replycredit_rule['extcreditstype'] => '-' . $postreplycredit));
             }
         }
     }
     C::t('forum_post')->delete('tid:' . $this->thread['tid'], $this->post['pid']);
     $forumcounter = array();
     if ($isfirstpost) {
         $forumcounter['threads'] = $forumcounter['posts'] = -1;
         $tablearray = array('forum_relatedthread', 'forum_debate', 'forum_debatepost', 'forum_polloption', 'forum_poll');
         foreach ($tablearray as $table) {
             C::t($table)->delete_by_tid($this->thread['tid']);
         }
         C::t('forum_thread')->delete_by_tid($this->thread['tid']);
         C::t('common_moderate')->delete($this->thread['tid'], 'tid');
         C::t('forum_threadmod')->delete_by_tid($this->thread['tid']);
         if ($this->setting['globalstick'] && in_array($this->thread['displayorder'], array(2, 3))) {
             require_once libfile('function/cache');
             updatecache('globalstick');
         }
     } else {
         $forumcounter['posts'] = -1;
         $lastpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:' . $this->thread['tid'], $this->thread['tid'], 0, 1);
         $lastpost['author'] = !$lastpost['anonymous'] ? addslashes($lastpost['author']) : '';
         $this->param['updatefieldarr']['replies'] = -1;
         $this->param['updatefieldarr']['lastposter'] = array($lastpost['author']);
         $this->param['updatefieldarr']['lastpost'] = array($lastpost['dateline']);
         C::t('forum_thread')->increase($this->thread['tid'], $this->param['updatefieldarr']);
     }
     $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'])) {
         $lastthread = C::t('forum_thread')->fetch_by_fid_displayorder($this->forum['fid']);
         C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => "{$lastthread['tid']}\t{$lastthread['subject']}\t{$lastthread['lastpost']}\t{$lastthread['lastposter']}"));
     }
     C::t('forum_forum')->update_forum_counter($this->forum['fid'], $forumcounter['threads'], $forumcounter['posts']);
 }
예제 #12
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    require_once libfile('function/forum');
    foreach ($tids as $tid) {
        my_post_log('delete', array('tid' => $tid));
    }
    $count = count($tids);
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    DB::delete('common_moderate', "id IN ({$tids}) AND idtype='tid'");
    $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        $threadtable = !$tableid ? "forum_thread" : "forum_thread_{$tableid}";
        $query = DB::query("SELECT cover, tid, fid, posttableid FROM " . DB::table($threadtable) . " WHERE tid IN ({$tids})");
        while ($row = DB::fetch($query)) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $threadtable;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            $query = DB::query('SELECT tid, first, authorid, dateline, replycredit, invisible FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($posttabletids) . ')');
            while ($post = DB::fetch($query)) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        $query = DB::query("SELECT tid, extcreditstype FROM " . DB::table('forum_replycredit') . " WHERE tid IN ({$tids})");
        while ($rule = DB::fetch($query)) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[] = $post['authorid'];
                    } else {
                        $ruidarray[] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                updatepostcredits('-', $tuidarray, 'post', $_G['forum']['fid']);
            }
            if ($ruidarray) {
                updatepostcredits('-', $ruidarray, 'reply', $_G['forum']['fid']);
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtablebytid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                $query = DB::query("SELECT uid, dateline FROM " . DB::table($attachtable) . " WHERE tid IN (" . dimplode($attachtids) . ")");
                while ($attach = DB::fetch($query)) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    if ($ponly) {
        if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        return $count;
    }
    DB::delete('forum_replycredit', "tid IN ({$tids})");
    DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN ({$tids})");
    deletethreadcover($tids);
    foreach ($threadtables as $threadtable) {
        DB::delete($threadtable, "tid IN ({$tids})");
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        foreach ($fids as $fid => $tableids) {
            $tableids = array_unique($tableids);
            foreach ($tableids as $tableid) {
                $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$fid}'");
                while ($row = DB::fetch($query)) {
                    DB::insert('forum_forum_threadtable', array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true);
                }
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_poststick', 'forum_pollvoter', 'forum_threadimage') as $table) {
        DB::delete($table, "tid IN ({$tids})");
    }
    DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$tids}) AND idtype='tid'", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_tagitem') . " WHERE idtype='tid' AND itemid IN ({$tids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('forum_threadrush') . " WHERE tid IN ({$tids})", 'UNBUFFERED');
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
예제 #13
0
     } else {
         if ($post['first']) {
             $tuidarray[] = $post['authorid'];
         } else {
             $ruidarray[] = $post['authorid'];
         }
     }
 }
 if ($uidarray) {
     updatepostcredits('-', $uidarray, array());
 }
 if ($tuidarray) {
     updatepostcredits('-', $tuidarray, $postcredits);
 }
 if ($ruidarray) {
     updatepostcredits('-', $ruidarray, $replycredits);
 }
 $modaction = 'DEL';
 if ($forum['recyclebin']) {
     $db->query("UPDATE {$tablepre}threads SET displayorder='-1', digest='0', moderated='1' WHERE tid IN ({$moderatetids})");
     $db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ({$moderatetids})");
 } else {
     $auidarray = array();
     $query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ({$moderatetids})");
     while ($attach = $db->fetch_array($query)) {
         dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
         if ($attach['dateline'] > $losslessdel) {
             $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
         }
     }
     if ($auidarray) {
예제 #14
0
        $thread['views'] = $thread['replies'] = $thread['highlight'] = $thread['digest'] = 0;
        $thread['rate'] = $thread['displayorder'] = $thread['attachment'] = 0;
        $posttableid = getposttableid('p');
        $thread['posttableid'] = $posttableid;
        $threadid = DB::insert('forum_thread', $thread, true);
        $posttable = getposttablebytid($_G['tid']);
        if ($post = DB::fetch_first("SELECT * FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND first=1 LIMIT 1")) {
            $post['pid'] = '';
            $post['tid'] = $threadid;
            $post['fid'] = $copyto;
            $post['dateline'] = TIMESTAMP;
            $post['attachment'] = 0;
            $post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
            $pid = insertpost($post);
        }
        updatepostcredits('+', $post['authorid'], 'post', $_G['fid']);
        updateforumcount($copyto);
        updateforumcount($_G['fid']);
        $modpostsnum++;
        $resultarray = array('redirect' => "forum.php?mod=forumdisplay&fid={$_G['fid']}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason), 'threadid' => $threadid), 'modtids' => $thread['tid'], 'modlog' => array($thread, $other));
    }
} elseif ($_G['gp_action'] == 'removereward' && $_G['group']['allowremovereward']) {
    if (!submitcheck('modsubmit')) {
        include template('forum/topicadmin_action');
    } else {
        if (!is_array($thread) || $thread['special'] != '3') {
            showmessage('reward_end');
        }
        $modaction = 'RMR';
        $reason = checkreasonpm();
        $answererid = DB::result_first("SELECT uid FROM " . DB::table('common_credit_log') . " WHERE operation='RAC' AND relatedid='{$thread['tid']}'");
예제 #15
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    $count = count($tids);
    $arrtids = $tids;
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    C::t('common_moderate')->delete($arrtids, 'tid');
    C::t('forum_threadclosed')->delete($arrtids);
    $cachefids = $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        foreach (C::t('forum_thread')->fetch_all_by_tid($arrtids, 0, 0, $tableid) as $row) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
            $cachefids[$row['fid']] = $row['fid'];
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $tableid;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            foreach (C::t('forum_post')->fetch_all_by_tid($posttableid, $posttabletids, false) as $post) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        foreach (C::t('forum_replycredit')->fetch_all($arrtids) as $rule) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[$post['fid']][] = $post['authorid'];
                    } else {
                        $ruidarray[$post['fid']][] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                foreach ($tuidarray as $fid => $tuids) {
                    updatepostcredits('-', $tuids, 'post', $fid);
                }
            }
            if ($ruidarray) {
                foreach ($ruidarray as $fid => $ruids) {
                    updatepostcredits('-', $ruids, 'reply', $fid);
                }
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtableid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                foreach (C::t('forum_attachment_n')->fetch_all_by_id($attachtable, 'tid', $attachtids) as $attach) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    $relatecollection = C::t('forum_collectionthread')->fetch_all_by_tids($arrtids);
    if (count($relatecollection) > 0) {
        $collectionids = array();
        foreach ($relatecollection as $collection) {
            $collectionids[] = $collection['ctid'];
        }
        $collectioninfo = C::t('forum_collection')->fetch_all($collectionids);
        foreach ($relatecollection as $collection) {
            $decthread = C::t('forum_collectionthread')->delete_by_ctid_tid($collection['ctid'], $arrtids);
            $lastpost = null;
            if (in_array($collectioninfo[$collection['ctid']]['lastpost'], $arrtids) && $collectioninfo[$collection['ctid']]['threadnum'] - $decthread > 0) {
                $collection_thread = C::t('forum_collectionthread')->fetch_by_ctid_dateline($collection['ctid']);
                if ($collection_thread) {
                    $thread = C::t('forum_thread')->fetch($collection_thread['tid']);
                    $lastpost = array('lastpost' => $thread['tid'], 'lastsubject' => $thread['subject'], 'lastposttime' => $thread['dateline'], 'lastposter' => $thread['authorid']);
                }
            }
            C::t('forum_collection')->update_by_ctid($collection['ctid'], -$decthread, 0, 0, 0, 0, 0, $lastpost);
        }
        C::t('forum_collectionrelated')->delete($arrtids);
    }
    if ($cachefids) {
        C::t('forum_thread')->clear_cache($cachefids, 'forumdisplay_');
    }
    if ($ponly) {
        if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        C::t('forum_thread')->update($arrtids, array('displayorder' => -1, 'digest' => 0, 'moderated' => 1));
        foreach ($postids as $posttableid => $oneposttids) {
            C::t('forum_post')->update_by_tid($posttableid, $oneposttids, array('invisible' => '-1'));
        }
        return $count;
    }
    C::t('forum_replycredit')->delete($arrtids);
    C::t('forum_post_location')->delete_by_tid($arrtids);
    C::t('common_credit_log')->delete_by_operation_relatedid(array('RCT', 'RCA', 'RCB'), $arrtids);
    deletethreadcover($arrtids);
    foreach ($threadtables as $tableid) {
        C::t('forum_thread')->delete_by_tid($arrtids, false, $tableid);
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        loadcache('forums');
        foreach ($fids as $fid => $tableids) {
            if (empty($_G['cache']['forums'][$fid]['archive'])) {
                continue;
            }
            foreach (C::t('forum_thread')->count_posts_by_fid($fid) as $row) {
                C::t('forum_forum_threadtable')->insert(array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => $row['threads'], 'posts' => $row['posts']), false, true);
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_pollvoter', 'forum_threadimage', 'forum_threadpreview') as $table) {
        C::t($table)->delete_by_tid($arrtids);
    }
    C::t('forum_typeoptionvar')->delete_by_tid($arrtids);
    C::t('forum_poststick')->delete_by_tid($arrtids);
    C::t('home_feed')->delete_by_id_idtype($arrtids, 'tid');
    C::t('common_tagitem')->delete(0, $tids, 'tid');
    C::t('forum_threadrush')->delete($arrtids);
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
예제 #16
0
         if ($post['replycredits']) {
             updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
         } else {
             $authoridarray[] = $post['authorid'];
         }
         $forums[] = $post['fid'];
         $threads[$post['tid']]['posts']++;
         $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : '';
         $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
         $pm = 'pm_' . $post['pid'];
         if (isset(${$pm}) && ${$pm} != '' && $post['authorid']) {
             $pmlist[] = array('action' => 'modreplies_validate', 'notevar' => array('tid' => $_G['tid'], 'post' => $post, 'reason' => stripslashes($reason)), 'authorid' => $post['authorid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars(${$pm}));
         }
     }
     if ($authoridarray) {
         updatepostcredits('+', $authoridarray, 'reply');
     }
     foreach ($threads as $tid => $thread) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+{$thread['posts']} {$thread['lastpostadd']} {$thread['attachadd']} WHERE tid='{$tid}'", 'UNBUFFERED');
     }
     foreach (array_unique($forums) as $fid) {
         updateforumcount($fid);
     }
     if (!empty($pidarray)) {
         updatepost(array('invisible' => '0'), "pid IN (0," . implode(',', $pidarray) . ")");
         $validates = DB::affected_rows();
         updatemodworks('MOD', $validates);
     } else {
         updatemodworks('MOD', 1);
     }
 }
예제 #17
0
     $postarray2 = getfieldsofposts('pid, first, authorid', "tid IN ({$tidsdelete})");
     while ((list($tmpkey, $post) = each($postarray1)) || (list($tmpkey, $post) = each($postarray2))) {
         $postsarray[$post['pid']] = $post;
     }
     foreach ($postsarray as $post) {
         if ($post['first']) {
             $tuidarray[] = $post['authorid'];
         } else {
             $ruidarray[] = $post['authorid'];
         }
     }
     if ($tuidarray) {
         updatepostcredits('-', $tuidarray, 'post');
     }
     if ($ruidarray) {
         updatepostcredits('-', $ruidarray, 'reply');
     }
 }
 require_once libfile('function/delete');
 $deletedposts = deletepost("pid IN ({$pidsdelete})");
 $deletedposts += deletepost("tid IN ({$tidsdelete})");
 $deletedthreads = deletethread("tid IN ({$tidsdelete})");
 if (count($prune['thread']) < 50) {
     foreach ($prune['thread'] as $tid => $decrease) {
         updatethreadcount($tid);
     }
 } else {
     $repliesarray = array();
     foreach ($prune['thread'] as $tid => $decrease) {
         $repliesarray[$decrease][] = $tid;
     }
예제 #18
0
function recyclebinpostundelete($undeletepids, $posttableid = false)
{
    global $_G;
    $postsundel = 0;
    if (empty($undeletepids)) {
        return $postsundel;
    }
    foreach ($undeletepids as $pid) {
        my_post_log('restore', array('pid' => $pid));
    }
    $undeletepids = dimplode($undeletepids);
    loadcache('posttableids');
    $posttableids = !empty($_G['cache']['posttableids']) ? $posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids'] : array('0');
    $postarray = $ruidarray = $fidarray = $tidarray = array();
    foreach ($posttableids as $ptid) {
        $query = DB::query('SELECT fid, tid, first, authorid FROM ' . DB::table(getposttable($ptid)) . " WHERE pid IN ({$undeletepids})");
        while ($post = DB::fetch($query)) {
            $postarray[] = $post;
        }
    }
    if (empty($postarray)) {
        return $postsundel;
    }
    foreach ($postarray as $key => $post) {
        if (!$post['first']) {
            $ruidarray[] = $post['authorid'];
        }
        $fidarray[$post['fid']] = $post['fid'];
        $tidarray[$post['tid']] = $post['tid'];
    }
    $postsundel = updatepost(array('invisible' => '0'), "pid IN ({$undeletepids})", true, $posttableid);
    include_once libfile('function/post');
    if ($ruidarray) {
        updatepostcredits('+', $ruidarray, $creditspolicy['reply']);
    }
    foreach ($tidarray as $tid) {
        updatethreadcount($tid, 1);
    }
    foreach ($fidarray as $fid) {
        updateforumcount($fid);
    }
    return $postsundel;
}
예제 #19
0
 $modaction = 'DCM';
 $commentid = intval($_GET['topiclist']);
 $postcomment = C::t('forum_postcomment')->fetch($commentid);
 if (!$postcomment) {
     showmessage('postcomment_not_found');
 }
 C::t('forum_postcomment')->delete($commentid);
 $result = C::t('forum_postcomment')->count_by_pid($postcomment['pid']);
 if (!$result) {
     C::t('forum_post')->update($_G['thread']['posttableid'], $postcomment['pid'], array('comment' => 0));
 }
 if ($thread['comments']) {
     C::t('forum_thread')->update($_G['tid'], array('comments' => $thread['comments'] - 1));
 }
 if (!$postcomment['rpid']) {
     updatepostcredits('-', $postcomment['authorid'], 'reply', $_G['fid']);
 }
 $totalcomment = array();
 foreach (C::t('forum_postcomment')->fetch_all_by_pid_score($postcomment['pid'], 1) as $comment) {
     if (strexists($comment['comment'], '<br />')) {
         if (preg_match_all("/([^:]+?):\\s<i>(\\d+)<\\/i>/", $comment['comment'], $a)) {
             foreach ($a[1] as $k => $itemk) {
                 $totalcomment[trim($itemk)][] = $a[2][$k];
             }
         }
     }
 }
 $totalv = '';
 foreach ($totalcomment as $itemk => $itemv) {
     $totalv .= strip_tags(trim($itemk)) . ': <i>' . sprintf('%1.1f', array_sum($itemv) / count($itemv)) . '</i> ';
 }
예제 #20
0
function recyclebinpostundelete($undeletepids, $posttableid = false)
{
    global $_G;
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['recyclebinpostundelete']) {
        $param = func_get_args();
        hookscript('recyclebinpostundelete', 'global', 'funcs', array('param' => $param), 'recyclebinpostundelete');
    }
    $postsundel = 0;
    if (empty($undeletepids)) {
        return $postsundel;
    }
    loadcache('posttableids');
    $posttableids = !empty($_G['cache']['posttableids']) ? $posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids'] : array('0');
    $postarray = $ruidarray = $fidarray = $tidarray = array();
    foreach ($posttableids as $ptid) {
        foreach (C::t('forum_post')->fetch_all($ptid, $undeletepids, false) as $post) {
            if (!$post['first']) {
                $ruidarray[$post['fid']][] = $post['authorid'];
            }
            $fidarray[$post['fid']] = $post['fid'];
            $tidarray[$post['tid']] = $post['tid'];
        }
    }
    if (empty($fidarray)) {
        return $postsundel;
    }
    C::t('forum_post')->update($posttableid, $undeletepids, array('invisible' => '0'), true);
    include_once libfile('function/post');
    if ($ruidarray) {
        foreach ($ruidarray as $fid => $ruids) {
            updatepostcredits('+', $ruids, 'reply', $fid);
        }
    }
    foreach ($tidarray as $tid) {
        updatethreadcount($tid, 1);
    }
    foreach ($fidarray as $fid) {
        updateforumcount($fid);
    }
    return count($undeletepids);
}
예제 #21
0
 if (!$_G['setting']['editperdel']) {
     showmessage('post_edit_thread_ban_del', NULL);
 }
 if ($isfirstpost && $thread['replies'] > 0) {
     showmessage($thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_thread_already_reply', NULL);
 }
 if ($thread['special'] == 3) {
     if ($thread['price'] < 0 && $thread['dateline'] + 1 == $orig['dateline']) {
         showmessage('post_edit_reward_nopermission', NULL);
     }
 }
 if ($rushreply) {
     showmessage('post_edit_delete_rushreply_nopermission', NULL);
 }
 if ($thread['displayorder'] >= 0) {
     updatepostcredits('-', $orig['authorid'], $isfirstpost ? 'post' : 'reply', $_G['fid']);
 }
 if ($thread['special'] == 3 && $isfirstpost) {
     updatemembercount($orig['authorid'], array($_G['setting']['creditstransextra'][2] => $thread['price']));
     DB::delete('common_credit_log', array('uid' => $thread['authorid'], 'operation' => 'RTC', 'relatedid' => $_G['tid']));
 }
 if ($thread['replycredit'] && $isfirstpost && !$isanonymous) {
     updatemembercount($orig['authorid'], array($replycredit_rule['extcreditstype'] => $thread['replycredit']), true, 'RCB', $_G['tid']);
     DB::delete('forum_replycredit', array('tid' => $_G['tid']));
 } elseif (!$isfirstpost && !$isanonymous) {
     if ($postreplycredit = DB::result_first("SELECT replycredit FROM " . DB::table($posttable) . " WHERE pid = '{$pid}' LIMIT 1")) {
         DB::query("UPDATE " . DB::table($posttable) . " SET replycredit = 0 WHERE pid = '{$pid}' LIMIT 1");
         updatemembercount($orig['authorid'], array($replycredit_rule['extcreditstype'] => '-' . $postreplycredit));
     }
 }
 $thread_attachment = $post_attachment = 0;
예제 #22
0
     while ($thread = $db->fetch_array($query)) {
         $tids .= $comma . $thread['tid'];
         $comma = ',';
         if ($thread['postcredits']) {
             updatepostcredits('+', $thread['authorid'], $forum['postcredits']);
         } else {
             $authoridarray[] = $thread['authorid'];
         }
         $validatedthreads[] = $thread;
         if ($reason != '' && $thread['authorid']) {
             $pmlist[] = array('act' => 'modthreads_validate_', 'authorid' => $thread['authorid'], 'tid' => $thread['tid'], 'thread' => $thread['subject'], 'reason' => dhtmlspecialchars($reason));
         }
     }
     if ($tids) {
         if ($authoridarray) {
             updatepostcredits('+', $authoridarray, $creditspolicy['post']);
         }
         $db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ({$tids})");
         $db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ({$tids})");
         $threadsmod = $db->affected_rows();
         updateforumcount($fid);
         updatemodworks('MOD', $threadsmod);
         updatemodlog($tids, 'MOD');
     }
 }
 if ($pmlist) {
     foreach ($pmlist as $pm) {
         $reason = $pm['reason'];
         $threadsubject = $pm['thread'];
         $tid = intval($pm['tid']);
         sendpm($pm['authorid'], $pm['act'] . 'subject', $pm['act'] . 'message', 0);
예제 #23
0
function threadpubsave($tid, $passapproval = false)
{
    global $_G;
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['threadpubsave']) {
        $hookparam = func_get_args();
        hookscript('threadpubsave', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'threadpubsave');
    }
    $thread = C::t('forum_thread')->fetch_by_tid_displayorder($tid, -4, '=', !$passapproval ? $_G['uid'] : null);
    if (!$thread) {
        return 0;
    }
    $threadpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($tid);
    $thread['message'] = $threadpost['message'];
    $modworksql = 0;
    $displayorder = 0;
    $dateline = $_G['timestamp'];
    $moderatepids = $saveposts = array();
    $return = 1;
    list($modnewthreads) = threadmodstatus($thread['subject'] . "\t" . $thread['message']);
    if ($modnewthreads && $passapproval === false) {
        updatemoderate('tid', $tid);
        manage_addnotify('verifythread');
        $displayorder = -2;
        $modworksql = 1;
        $return = -1;
    } else {
        C::t('forum_post')->update_by_tid('tid:' . $tid, $tid, array('dateline' => $dateline, 'invisible' => '0'), false, false, 1);
    }
    C::t('forum_thread')->update($tid, array('displayorder' => $displayorder, 'dateline' => $_G['timestamp'], 'lastpost' => $_G['timestamp']));
    $posts = $thread['replies'] + 1;
    if ($thread['replies']) {
        $saveposts = C::t('forum_post')->fetch_all_by_tid('tid:' . $tid, $tid, true, '', 0, 0, 0);
        foreach ($saveposts as $post) {
            $dateline++;
            $invisible = 0;
            list(, $modnewreplies) = threadmodstatus($post['subject'] . "\t" . $post['message']);
            if ($modnewreplies) {
                $moderatepids[] = $post['pid'];
                $verifypost = true;
                $invisible = -2;
                $modworksql = 1;
                $return = -2;
            }
            C::t('forum_post')->update('tid:' . $tid, $post['pid'], array('dateline' => $dateline, 'invisible' => $invisible));
            updatepostcredits('+', $thread['authorid'], 'reply', $thread['fid']);
        }
    }
    if ($moderatepids) {
        updatemoderate('pid', $moderatepids);
        manage_addnotify('verifypost');
    }
    updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
    $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $thread['tid'], 'tid', $thread['tid']);
    updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']);
    if ($_G['forum']['status'] == 3) {
        C::t('forum_groupuser')->update_counter_for_user($thread['authorid'], $thread['fid'], 1);
    }
    $subject = str_replace("\t", ' ', $thread['subject']);
    $lastpost = $thread['tid'] . "\t" . $subject . "\t" . $thread['lastpost'] . "\t" . $thread['lastposter'];
    C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
    C::t('forum_forum')->update_forum_counter($thread['fid'], 1, $posts, $posts, $modworksql);
    if ($_G['forum']['type'] == 'sub') {
        C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
    }
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['threadpubsave']) {
        hookscript('threadpubsave', 'global', 'funcs', array('param' => $hookparam, 'step' => 'save', 'posts' => $saveposts), 'threadpubsave');
    }
    return $return;
}
예제 #24
0
        }
        if ($_G['gp_tradeaid']) {
            $attachment = DB::fetch_first("SELECT * FROM " . DB::table('forum_attachment') . " WHERE aid='{$_G['gp_tradeaid']}'");
            if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) {
                $_G['setting']['attachurl'] = preg_match("/^((https?|ftps?):\\/\\/|www\\.)/i", $_G['setting']['attachurl']) ? $_G['setting']['attachurl'] : $_G['siteurl'] . $_G['setting']['attachurl'];
                $imgurl = $_G['setting']['attachurl'] . '/forum/' . $attachment['attachment'] . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? '.thumb.jpg' : '');
                $feed['images'][] = $attachment['attachment'] ? $imgurl : '';
                $feed['image_links'][] = $attachment['attachment'] ? "{$_G['siteurl']}forum.php?mod=viewthread&tid={$tid}" : '';
            }
        }
        $feed['title_data']['hash_data'] = "tid{$tid}";
        $feed['id'] = $tid;
        $feed['idtype'] = 'tid';
        postfeed($feed);
    }
    if ($digest) {
        foreach ($digestcredits as $id => $addcredits) {
            $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits;
        }
    }
    updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
    DB::query("UPDATE " . DB::table('common_member_count') . " SET threads=threads+1 WHERE uid='{$_G['uid']}'");
    $lastpost = "{$tid}\t{$subject}\t{$_G['timestamp']}\t{$author}";
    DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', threads=threads+1, posts=posts+2, todayposts=todayposts+1 WHERE fid='{$_G['fid']}'", 'UNBUFFERED');
    if ($_G['forum']['type'] == 'sub') {
        DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='" . $_G['forum']['fup'] . "'", 'UNBUFFERED');
    }
    include_once libfile('function/stat');
    updatestat('trade');
    showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid={$tid}&extra={$extra}", $param);
}
예제 #25
0
파일: sign.inc.php 프로젝트: v998/dsu
         DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$var['fidnumber']}'", 'UNBUFFERED');
         $tidnumber = $tid;
     } else {
         $tidnumber = $stats['qdtidnumber'];
         $thread = DB::fetch_first("SELECT subject FROM " . DB::table('forum_thread') . " WHERE tid='{$tidnumber}'");
         $hft = dgmdate($_G['timestamp'], 'Y-m-d H:i', $var['tos']);
         if ($num >= 1 && $num <= 9 && $exacr && $exacz) {
             $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_02]}[color=red]{$lang[tsn_03]}[/color][color=darkorange]{$lang[tsn_04]}{$psc}{$lang[tsn_05]}[/color]{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit}[/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][color=gray]{$lang[tsn_17]}[/color] [color=gray]{$_G[setting][extcredits][$exacr][title]} [/color][color=darkorange]{$exacz}[/color][color=gray]{$_G[setting][extcredits][$exacr][unit]}[/color][/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
         } else {
             $message = "[quote][size=2][color=gray][color=teal] [/color][color=gray]{$lang[tsn_01]}[/color] [color=darkorange]{$hft}[/color] {$lang[tsn_09]}{$lang[tsn_06]} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][title]} [/color][color=darkorange]{$credit} [/color][color=gray]{$_G[setting][extcredits][$var[nrcredit]][unit]}[/color][/size][/quote][size=3][color=dimgray]{$lang[tsn_07]}[color=red]{$todaysay}[/color]{$lang[tsn_08]}[/color][/size]";
         }
         require_once libfile('function/post');
         require_once libfile('function/forum');
         $pid = insertpost(array('fid' => $var['fidnumber'], 'tid' => $tidnumber, 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => '', 'dateline' => $_G['timestamp'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => '0', 'anonymous' => '0', 'usesig' => '0', 'htmlon' => '0', 'bbcodeoff' => '0', 'smileyoff' => '0', 'parseurloff' => '0', 'attachment' => '0'));
         DB::query("UPDATE " . DB::table('forum_thread') . " SET lastposter='{$_G['username']}', lastpost='{$_G['timestamp']}', replies=replies+1 WHERE tid='{$tidnumber}' AND fid='{$var['fidnumber']}'", 'UNBUFFERED');
         updatepostcredits('+', $_G['uid'], 'reply', $var['fidnumber']);
         $lastpost = "{$tidnumber}\t" . addslashes($thread['subject']) . "\t{$_G['timestamp']}\t{$_G['username']}";
         DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', posts=posts+1, todayposts=todayposts+1 WHERE fid='{$var['fidnumber']}'", 'UNBUFFERED');
     }
 }
 if (memory('check')) {
     memory('set', 'dsu_pualsign_' . $_G['uid'], $_G['timestamp'], 86400);
 }
 if ($num == 0) {
     if ($stats['todayq'] > $stats['highestq']) {
         DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET highestq='{$stats['todayq']}' WHERE id='1'");
     }
     DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET yesterdayq='{$stats['todayq']}',todayq=1 WHERE id='1'");
 } else {
     DB::query("UPDATE " . DB::table('dsu_paulsignset') . " SET todayq=todayq+1 WHERE id='1'");
 }
예제 #26
0
         $pricediff = $rewardprice - $thread['price'];
         $db->query("UPDATE {$tablepre}members SET extcredits{$creditstransextra['2']}=extcredits{$creditstransextra['2']}-{$pricediff} WHERE uid='{$orig['authorid']}'", 'UNBUFFERED');
     }
 } else {
     if ($isfirstpost && $thread['replies'] > 0) {
         showmessage($thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_thread_already_reply', NULL, 'HALTED');
     }
     if ($thread['special'] == 3) {
         if ($thread['price'] < 0 && $thread['dateline'] + 1 == $orig['dateline']) {
             showmessage('post_edit_reward_nopermission', NULL, 'HALTED');
         }
     }
     if ($rushreply) {
         showmessage('post_edit_delete_rushreply_nopermission', NULL, 'HALTED');
     }
     updatepostcredits('-', $orig['authorid'], $isfirstpost ? $postcredits : $replycredits);
     if ($thread['special'] == 3 && $isfirstpost) {
         $db->query("UPDATE {$tablepre}members SET extcredits{$creditstransextra['2']}=extcredits{$creditstransextra['2']}+{$thread['price']} WHERE uid='{$orig['authorid']}'", 'UNBUFFERED');
         $db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='{$tid}'", 'UNBUFFERED');
     }
     $thread_attachment = $post_attachment = 0;
     $query = $db->query("SELECT pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE tid='{$tid}'");
     while ($attach = $db->fetch_array($query)) {
         if ($attach['pid'] == $pid) {
             $post_attachment++;
             dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
         } else {
             $thread_attachment = 1;
         }
     }
     if ($post_attachment) {
function insenz_runcron()
{
    global $timestamp, $db, $tablepre, $_DCACHE;
    $lockfile = DISCUZ_ROOT . './forumdata/insenzcron_' . gmdate('ymdH', $timestamp + 8 * 3600) . '.lock';
    if (is_writable($lockfile) && filemtime($lockfile) > $timestamp - 180) {
        return NULL;
    } else {
        @touch($lockfile);
    }
    @set_time_limit(1000);
    @ignore_user_abort(TRUE);
    $globalstick = $floatthreads = 0;
    $query = $db->query("SELECT c.id, c.type, c.fid AS virtualfid, c.tid, c.status, c.begintime, c.starttime, c.endtime, t.fid, t.authorid, t.author, t.subject, t.lastpost, t.displayorder FROM {$tablepre}campaigns c LEFT JOIN {$tablepre}threads t ON t.tid=c.tid WHERE c.nextrun<='{$timestamp}'");
    while ($c = $db->fetch_array($query)) {
        $moderated = in_array($c['displayorder'], array(-11, -12, 1, 2)) ? 1 : 0;
        $moderatedadd = $moderated ? ", moderated=1" : '';
        if ($c['status'] == 1) {
            if ($c['type'] != 4) {
                $db->query("UPDATE {$tablepre}threads SET displayorder=-displayorder-10 {$moderatedadd} WHERE tid='{$c['tid']}'", 'UNBUFFERED');
                $db->query("UPDATE {$tablepre}campaigns SET status=2, starttime='{$timestamp}', nextrun=endtime+starttime-begintime WHERE id='{$c['id']}' AND type='{$c['type']}'", 'UNBUFFERED');
                $lastpost = "{$c['tid']}\t{$c['subject']}\t{$c['lastpost']}\t{$c['author']}";
                $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$c['fid']}'", 'UNBUFFERED');
                if ($moderated) {
                    $expiration = $c['endtime'] + $c['starttime'] - $c['begintime'];
                    $db->query("INSERT INTO {$tablepre}threadsmod (tid, uid, username, dateline, action, expiration, status) VALUES ('{$c['tid']}', '" . $_DCACHE[settings][insenz][uid] . "', '" . $_DCACHE[settings][insenz][username] . "', '{$timestamp}', 'EST', '{$expiration}', '0')", 'UNBUFFERED');
                }
                if ($c['displayorder'] < -13) {
                    $floatthreads = 1;
                } elseif ($c['displayorder'] < -11) {
                    $globalstick = 1;
                }
                require_once DISCUZ_ROOT . './include/post.func.php';
                updatepostcredits('+', $c['authorid'], $_DCACHE['settings']['creditspolicy']['post']);
            } else {
                $db->query("UPDATE {$tablepre}campaigns SET status=2, starttime='{$timestamp}', nextrun=endtime+starttime-begintime WHERE id='{$c['id']}' AND type=4", 'UNBUFFERED');
                $db->query("UPDATE {$tablepre}forums SET status='1' WHERE fid='{$c['virtualfid']}'");
            }
        } elseif ($c['status'] == 2) {
            if ($c['type'] != 4) {
                if ($c['displayorder'] > 0) {
                    $db->query("UPDATE {$tablepre}threads SET displayorder=0 {$moderatedadd} WHERE tid='{$c['tid']}'", 'UNBUFFERED');
                    if ($moderated) {
                        $db->query("INSERT INTO {$tablepre}threadsmod (tid, uid, username, dateline, action, expiration, status) VALUES ('{$c['tid']}', '" . $_DCACHE[settings][insenz][uid] . "', '" . $_DCACHE[settings][insenz][username] . "', '{$timestamp}', 'UES', '0', '0')", 'UNBUFFERED');
                    }
                    if ($c['displayorder'] > 3) {
                        $floatthreads = 1;
                    } elseif ($c['displayorder'] > 1) {
                        $globalstick = 1;
                    }
                }
            } else {
                $db->query("UPDATE {$tablepre}forums SET status='0' WHERE fid='{$c['virtualfid']}'");
            }
            $db->query("UPDATE {$tablepre}campaigns SET status=3, nextrun=expiration WHERE id='{$c['id']}' AND type='{$c['type']}'", 'UNBUFFERED');
        } elseif ($c['status'] == 3) {
            if ($c['type'] != 4) {
                $db->query("UPDATE {$tablepre}threads SET digest=0 WHERE tid='{$c['tid']}'", 'UNBUFFERED');
            }
            $db->query("DELETE FROM {$tablepre}campaigns WHERE id='{$c['id']}' AND type='{$c['type']}'", 'UNBUFFERED');
        }
    }
    require_once DISCUZ_ROOT . './include/cache.func.php';
    $query = $db->query("SELECT nextrun FROM {$tablepre}campaigns WHERE nextrun>'{$timestamp}' ORDER BY nextrun LIMIT 1");
    $_DCACHE['settings']['insenz']['cronnextrun'] = $db->result($query, 0);
    updatesettings();
    $globalstick && updatecache('globalstick');
    $floatthreads && updatecache('floatthreads');
    @unlink($lockfile);
}
예제 #28
0
        $thread['views'] = $thread['replies'] = 0;
        $thread['digest'] = $thread['blog'] = $thread['rate'] = 0;
        $thread['displayorder'] = 0;
        $thread['attachment'] = 0;
        $db->query("INSERT INTO {$tablepre}threads VALUES ('" . implode("', '", daddslashes($thread, 1)) . "')");
        $threadid = $db->insert_id();
        if ($post = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE tid='{$tid}' AND first=1 LIMIT 1")) {
            $post['pid'] = '';
            $post['tid'] = $threadid;
            $post['fid'] = $copyto;
            $post['dateline'] = $timestamp;
            $post['attachment'] = 0;
            $post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
            $db->query("INSERT INTO {$tablepre}posts VALUES  ('" . implode("', '", daddslashes($post, 1)) . "')");
        }
        updatepostcredits('+', $post['authorid'], '');
        updateforumcount($copyto);
        updateforumcount($fid);
        $modpostsnum++;
        $resultarray = array('redirect' => "forumdisplay.php?fid={$fid}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array(), 'modtids' => $thread['tid'], 'modlog' => array($thread, $other));
    }
} elseif ($action == 'removereward') {
    $modaction = 'RMR';
    if (!is_array($thread) || $thread['special'] != '3' || $thread['price'] >= 0) {
        showmessage('reward_end');
    }
    $answererid = $db->result_first("SELECT answererid FROM {$tablepre}rewardlog WHERE tid='{$thread['tid']}'");
    $thread[price] = abs($thread[price]);
    $db->query("UPDATE {$tablepre}members SET extcredits{$creditstrans}=extcredits{$creditstrans}+{$thread['price']} WHERE uid='{$thread['authorid']}'", 'UNBUFFERED');
    $db->query("UPDATE {$tablepre}members SET extcredits{$creditstrans}=extcredits{$creditstrans}-{$thread['price']} WHERE uid='{$answererid}'", 'UNBUFFERED');
    $db->query("UPDATE {$tablepre}threads SET special='0', price='0' WHERE tid='{$thread['tid']}'", 'UNBUFFERED');
예제 #29
0
    } else {
        if ($message == '') {
            wapmsg('post_sm_isnull');
        }
        if ($post_invalid = checkpost()) {
            wapmsg($post_invalid);
        }
        if ($formhash != formhash()) {
            wapmsg('wap_submit_invalid');
        }
        if (checkflood()) {
            wapmsg('post_flood_ctrl');
        }
        $pinvisible = $modnewreplies ? -2 : 0;
        $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, dateline, message, useip, invisible, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)\r\n\t\t\t\tVALUES ('{$fid}', '{$tid}', '0', '{$discuz_user}', '{$discuz_uid}', '{$timestamp}', '{$message}', '{$onlineip}', '{$pinvisible}', '1', '0', '0', '0', '0', '0')");
        $pid = $db->insert_id();
        $db->query("REPLACE INTO {$tablepre}myposts (uid, tid, pid, position, dateline) VALUES ('{$discuz_uid}', '{$tid}', '{$pid}', '" . ($thread['replies'] + 1) . "', '{$timestamp}')", 'UNBUFFERED');
        if ($modnewreplies) {
            wapmsg('post_mod_succeed', array('title' => 'post_mod_forward', 'link' => "index.php?action=forum&amp;fid={$fid}"));
        } else {
            $db->query("UPDATE {$tablepre}threads SET lastposter='{$discuz_user}', lastpost='{$timestamp}', replies=replies+1 WHERE tid='{$tid}' AND fid='{$fid}'", 'UNBUFFERED');
            updatepostcredits('+', $discuz_uid, $replycredits);
            $lastpost = "{$thread['tid']}\t" . addslashes($thread['subject']) . "\t{$timestamp}\t{$discuz_user}";
            $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}', posts=posts+1, todayposts=todayposts+1 WHERE fid='{$fid}'", 'UNBUFFERED');
            if ($forum['type'] == 'sub') {
                $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}' WHERE fid='{$forum['fup']}'", 'UNBUFFERED');
            }
            wapmsg('post_newreply_succeed', array('title' => 'post_newreply_forward', 'link' => "index.php?action=thread&amp;tid={$tid}&amp;page=" . @ceil(($thread['replies'] + 2) / $wapppp)));
        }
    }
}
예제 #30
0
         require_once libfile('function/delete');
         $deletes = deletepost($pids, 'pid', false, $posttable);
     }
     $deletes += count($recyclebinpids);
     updatemodworks('DLP', count($moderation['delete']));
     updatemoderate('pid', $moderation['delete'], 2);
 }
 if ($validatepids = dimplode($moderation['validate'])) {
     require_once libfile('function/forum');
     $forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
     $query = DB::query("SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, p.status\n\t\t\tFROM " . DB::table(getposttable($posttable)) . " p LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid\n\t\t\tWHERE pid IN ({$validatepids})  AND first='0'");
     while ($post = DB::fetch($query)) {
         $pidarray[] = $post['pid'];
         my_post_log('validate', array('pid' => $post['pid']));
         if (getstatus($post['status'], 3) == 0) {
             updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
             $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($post['tid'])) . " WHERE pid='{$post['pid']}'");
             updatecreditbyaction('postattach', $post['authorid'], array(), '', $attachcount, 1, $post['fid']);
         }
         $forums[] = $post['fid'];
         $threads[$post['tid']]['posts']++;
         $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : '';
         $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
         $pm = 'pm_' . $post['pid'];
         if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $post['authorid']) {
             $pmlist[] = array('action' => 'modreplies_validate', 'notevar' => array('pid' => $post['pid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $post['authorid']);
         }
     }
     foreach ($threads as $tid => $thread) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+{$thread['posts']} {$thread['lastpostadd']} {$thread['attachadd']} WHERE tid='{$tid}'", 'UNBUFFERED');
     }