protected function _handleEvilPost($tid, $pid, $evilType, $evilLevel = 1) { /*vot*/ include_once DISCUZ_ROOT.'./source/language/'.DISCUZ_LANG.'/lang_admincp_cloud.php'; $securityService = Cloud::loadClass('Service_Security'); $securityService->writeLog($pid, 'pid'); $evilPost = C::t('#security#security_evilpost')->fetch($pid); if (count($evilPost)) { return true; } else { require_once libfile('function/delete'); require_once libfile('function/forum'); require_once libfile('function/post'); $data = array('pid' => $pid, 'tid' => $tid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP); $post = get_post_by_pid($pid); if (is_array($post) && count($post) > 0) { if ($tid != $post['tid']) { return false; } $thread = get_thread_by_tid($tid); if ($post['first']) { $data['type'] = 1; if ($this->_checkThreadIgnore($tid)) { return false; } C::t('#security#security_evilpost')->insert($data, false, true); $this->_updateEvilCount('thread'); deletethread(array($tid), true, true, true); updatemodlog($tid, 'DEL', 0, 1, $extend_lang['security_modreason']); } else { $data['type'] = 0; if ($this->_checkPostIgnore($pid, $post)) { return false; } C::t('#security#security_evilpost')->insert($data, false, true); $this->_updateEvilCount('post'); deletepost(array($pid), 'pid', true, false, true); } if(!empty($post['authorid'])) { $data = array('uid' => $post['authorid'], 'createtime' => TIMESTAMP); C::t('#security#security_eviluser')->insert($data, false, true); } } else { $data['operateresult'] = 2; C::t('#security#security_evilpost')->insert($data, false, true); } } return true; }
function set_stamp($typeid, $stampaction, &$threadlist, $expiration) { global $_G; $moderatetids = dimplode(array_keys($threadlist)); if (empty($threadlist)) { return false; } if (array_key_exists($typeid, $_G['cache']['stamptypeid'])) { DB::query("UPDATE " . DB::table('forum_thread') . " SET " . buildbitsql('status', 5, TRUE) . " WHERE tid IN ({$moderatetids})"); if ($stampaction == 'SPD') { $stamptids = array(); foreach ($threadlist as $stamptid => $thread) { $currentstamp = DB::fetch_first("SELECT * FROM " . DB::table('forum_threadmod') . " WHERE tid='{$stamptid}' AND status='1' ORDER BY dateline DESC LIMIT 1"); if (!empty($currentstamp) && $currentstamp['stamp'] == $_G['cache']['stamptypeid'][$typeid]) { $stamptids[] = $stamptid; } } if (!empty($stamptids)) { $moderatetids = dimplode($stamptids); } else { $moderatetids = ''; } } !empty($moderatetids) && updatemodlog($moderatetids, $stampaction, $expiration, 0, $_G['cache']['stamptypeid'][$typeid]); } }
} $uids = @array_unique($uids); $count = count($uids); $limit = intval($_GET['limit']); $per = 200; $uids = @array_slice($uids, $limit, $per); if ($uids) { foreach ($uids as $uid) { if (empty($uid)) { continue; } foreach ($tagarray as $tagid => $tagname) { C::t('common_tagitem')->insert(array('tagid' => $tagid, 'itemid' => $uid, 'idtype' => 'uid'), 0, 1); } } updatemodlog($_G['tid'], 'AUT', 0, 0, implode(',', $tagarray)); showmessage('forum_usertag_set_continue', '', array('limit' => $limit, 'next' => min($limit + $per, $count), 'count' => $count), array('alert' => 'right')); } showmessage('forum_usertag_succeed', '', array(), array('alert' => 'right')); } else { showmessage('parameters_error', '', array('haserror' => 1)); } } } else { showmessage('parameters_error', '', array('haserror' => 1)); } include_once template("forum/usertag"); } function getratelist($raterange) { global $_G;
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; }
$threadimage = DB::fetch_first("SELECT attachment, remote FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1"); } DB::delete('forum_threadimage', "tid='{$_G['tid']}'"); $threadimage = daddslashes($threadimage); DB::insert('forum_threadimage', array('tid' => $_G['tid'], 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote'])); } } $feed = array(); if ($special == 127) { $message .= chr(0) . chr(0) . chr(0) . $specialextra; } if ($_G['forum_auditstatuson'] && $audit == 1) { DB::query("UPDATE " . DB::table(getposttable($thread['posttableid'])) . " SET status='4' WHERE pid='{$pid}' AND status='0' AND invisible='-2'"); updatepostcredits('+', $orig['authorid'], $isfirstpost ? 'post' : 'reply', $_G['fid']); updatemodworks('MOD', 1); updatemodlog($_G['tid'], 'MOD'); } $displayorder = $pinvisible = 0; if ($isfirstpost) { $displayorder = $modnewthreads ? -2 : $thread['displayorder']; $pinvisible = $modnewthreads ? -2 : (empty($_G['gp_save']) ? 0 : -3); if ($thread['displayorder'] == -4 && empty($_G['gp_save'])) { DB::query("UPDATE " . DB::table($posttable) . " SET dateline='{$_G['timestamp']}', invisible='0' WHERE tid='{$thread['tid']}'"); DB::query("UPDATE " . DB::table('forum_thread') . " SET dateline='{$_G['timestamp']}', lastpost='{$_G['timestamp']}' WHERE tid='{$thread['tid']}'"); $posts = $thread['replies'] + 1; if ($thread['replies']) { $dateline = $_G['timestamp']; $query = DB::query("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='0'"); while ($post = DB::fetch($query)) { $dateline++; DB::query("UPDATE " . DB::table($posttable) . " SET dateline='{$dateline}' WHERE pid='{$post['pid']}'");
case 'UEH': $db->query("UPDATE {$tablepre}threads SET highlight='0' WHERE tid IN ({$tids})", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ({$tids}) AND action IN ('EHL', 'CCK')", 'UNBUFFERED'); break; case 'UEC': case 'UEO': $closed = $action == 'UEO' ? 1 : 0; $db->query("UPDATE {$tablepre}threads SET closed='{$closed}' WHERE tid IN ({$tids})", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ({$tids}) AND action IN ('EOP', 'ECL', 'CLK')", 'UNBUFFERED'); break; case 'UED': $db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ({$tids}) AND action='EDI'", 'UNBUFFERED'); $digestarray = $authoridarry = array(); $query = $db->query("SELECT authorid, digest FROM {$tablepre}threads WHERE tid IN ({$tids})"); while ($digest = $db->fetch_array($query)) { $authoridarry[] = $digest['authorid']; $digestarray[$digest['digest']][] = $digest['authorid']; } $db->query("UPDATE {$tablepre}members SET digestposts=digestposts-1 WHERE uid IN (" . implode(',', $authoridarry) . ")", 'UNBUFFERED'); foreach ($digestarray as $digest => $authorids) { updatecredits(implode('\',\'', $authorids), $creditspolicy['digest'], 0 - $digest); } $db->query("UPDATE {$tablepre}threads SET digest='0' WHERE tid IN ({$tids})", 'UNBUFFERED'); break; } } require_once DISCUZ_ROOT . './include/post.func.php'; foreach ($actionarray as $action => $tids) { updatemodlog(implode(',', $tids), $action, 0, 1); } }
if ($pidsdelete) { require_once libfile('function/post'); require_once libfile('function/delete'); $forums = array(); $query = DB::query('SELECT fid, recyclebin FROM ' . DB::table('forum_forum') . " WHERE fid IN (" . dimplode($prune['forums']) . ")"); while ($value = DB::fetch($query)) { $forums[$value['fid']] = $value; } foreach ($pidsdelete as $fid => $pids) { foreach ($pids as $pid) { if (!$tidsdelete[$pid]) { $deletedposts = deletepost($pid, 'pid', !getgpc('nocredit'), $posttableid, $forums[$fid]['recyclebin']); updatemodlog($pids_tids[$pid], 'DLP'); } else { $deletedthreads = deletethread($tidsdelete[$pid], false, !getgpc('nocredit'), $forums[$fid]['recyclebin']); updatemodlog($tidsdelete[$pid], 'DEL'); } } } 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; } foreach ($repliesarray as $decrease => $tidarray) { DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies-'{$decrease}' WHERE tid IN (" . implode(',', $tidarray) . ")"); }
} } } $typeid = isset($typeid) ? $typeid : 0; $displayorder = $modnewthreads ? -2 : ($_G['forum']['ismoderator'] && !empty($_G['gp_sticktopic']) ? 1 : 0); $digest = $_G['forum']['ismoderator'] && !empty($addtodigest) ? 1 : 0; $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0; $isanonymous = $_G['gp_isanonymous'] && $_G['group']['allowanonymous'] ? 1 : 0; $author = !$isanonymous ? $_G['username'] : ''; $moderated = $digest || $displayorder > 0 ? 1 : 0; $posttableid = getposttableid('p'); $isgroup = $_G['forum']['status'] == 3 ? 1 : 0; DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment, moderated, replies, status, isgroup)\n\tVALUES ('{$_G['fid']}', '{$posttableid}', '{$readperm}', '{$price}', '{$typeid}', '{$author}', '{$_G['uid']}', '{$subject}', '{$_G['timestamp']}', '{$_G['timestamp']}', '{$author}', '{$displayorder}', '{$digest}', '{$special}', '{$attachment}', '{$moderated}', '1', '{$thread['status']}', '{$isgroup}')"); $tid = DB::insert_id(); if ($moderated) { updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG'); updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1); } $bbcodeoff = checkbbcodes($message, !empty($_G['gp_bbcodeoff'])); $smileyoff = checksmilies($message, !empty($_G['gp_smileyoff'])); $parseurloff = !empty($_G['gp_parseurloff']); $htmlon = bindec(($_G['setting']['tagstatus'] && !empty($tagoff) ? 1 : 0) . ($_G['group']['allowhtml'] && !empty($_G['gp_htmlon']) ? 1 : 0)); $attentionon = empty($_G['gp_attention_add']) ? 0 : 1; $pinvisible = $modnewthreads ? -2 : 0; insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $_G['timestamp'], 'message' => '', 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $_G['gp_usesig'], 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0')); if ($_G['setting']['tagstatus'] && $_G['gp_tags'] != '') { $tags = str_replace(array(chr(0xa3) . chr(0xac), chr(0xa1) . chr(0x41), chr(0xef) . chr(0xbc) . chr(0x8c)), ',', censor($_G['gp_tags'])); if (strexists($tags, ',')) { $tagarray = array_unique(explode(',', $tags)); } else { $tags = str_replace(array(chr(0xa1) . chr(0xa1), chr(0xa1) . chr(0x40), chr(0xe3) . chr(0x80) . chr(0x80)), ' ', $tags);
$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 ({$undeletetids})", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ({$undeletetids})"); $threadsundel = $db->affected_rows(); updatemodlog($undeletetids, 'UDL'); updatemodworks('UDL', $threadsundel); foreach ($fidarray as $fid) { updateforumcount($fid); } } cpmsg('recyclebin_succeed'); } if (submitcheck('searchsubmit')) { $sql = ''; $sql .= $inforum ? " AND t.fid='{$inforum}'" : ''; $sql .= $authors != '' ? " AND t.author IN ('" . str_replace(',', '\',\'', str_replace(' ', '', $authors)) . "')" : ''; $sql .= $admins != '' ? " AND tm.username IN ('" . str_replace(',', '\',\'', str_replace(' ', '', $admins)) . "')" : ''; $sql .= $pstarttime != '' ? " AND t.dateline>='" . (strtotime($pstarttime) - $timeoffset * 3600) . "'" : ''; $sql .= $pendtime != '' ? " AND t.dateline<'" . (strtotime($pendtime) - $timeoffset * 3600) . "'" : ''; $sql .= $mstarttime != '' ? " AND tm.dateline>='" . (strtotime($mstarttime) - $timeoffset * 3600) . "'" : '';
*/ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } if (!$_G['group']['allowlivethread']) { showmessage('no_privilege_livethread'); } if (!submitcheck('modsubmit')) { include template('forum/topicadmin_action'); } else { $modaction = $_GET['live'] ? 'LIV' : 'LIC'; $reason = checkreasonpm(); $expiration = $_GET['expirationlive'] ? dintval($_GET['expirationlive']) : 0; //删除缓存 $mem_key = 'forum_forum_fetch_all_info_by_fids_' . $_G['fid']; memory('rm', $mem_key); //删除板块缓存 $mem_key = 'forum_forum_fetch_info_by_fid_' . $_G['fid']; $res1 = memory('rm', $mem_key); if ($modaction == 'LIV') { C::t('forum_forumfield')->update($_G['fid'], array('livetid' => $_G['tid'])); } elseif ($modaction == 'LIC') { if ($_G['tid'] != $_G['forum']['livetid']) { showmessage('topicadmin_live_noset_error'); } C::t('forum_forumfield')->update($_G['fid'], array('livetid' => 0)); } $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'notictype' => 'post', 'item' => $_GET['live'] ? 'reason_live_update' : 'reason_live_cancle') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modaction' => $modaction, 'modlog' => $thread); $modpostsnum = 1; updatemodlog($_G['tid'], $modaction, $expiration, 0, '', $modaction == 'LIV' ? 1 : 0); }
function handleEvilPost($tid, $pid, $evilType, $evilLevel = 1) { global $_G; if (notOpenService()) { return false; } include_once DISCUZ_ROOT . './source/language/lang_admincp_cloud.php'; loadSecLog($pid, 'pid'); $evilPost = DB::fetch_first("SELECT * FROM " . DB::table('security_evilpost') . " WHERE pid='{$pid}'"); if (is_array($evilPost)) { $data = $evilPost; $data['evilcount'] = $evilPost['evilcount'] + 1; } else { require_once libfile('function/delete'); require_once libfile('function/forum'); require_once libfile('function/post'); $data = array('pid' => $pid, 'tid' => $tid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP); $post = get_post_by_pid($pid); if (is_array($post) && count($post) > 0) { if ($tid != $post['tid']) { return false; } if ($post['first']) { $data['type'] = 1; if (checkThreadIgnore($tid)) { return false; } DB::insert('security_evilpost', $data, 0, 1); updateEvilCount('thread'); DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='-1', digest='0', moderated='1' WHERE tid = '" . $tid . "'"); deletethread(array($tid), true, true, true); updatepost(array('invisible' => '-1'), "tid = '" . $tid . "'"); updatemodlog($tid, 'DEL', 0, 1, $extend_lang['security_modreason']); } else { $data['type'] = 0; if (checkPostIgnore($pid, $post)) { return false; } DB::insert('security_evilpost', $data, 0, 1); updateEvilCount('post'); deletepost(array($pid), 'pid', true, false, true); } } else { $data['operateresult'] = 2; DB::insert('security_evilpost', $data, 0, 1); } } return true; }
function set_stamp($typeid, $stampaction, &$threadlist, $expiration) { global $_G; $moderatetids = array_keys($threadlist); if (empty($threadlist)) { return false; } if (array_key_exists($typeid, $_G['cache']['stamptypeid'])) { if ($stampaction == 'SPD') { C::t('forum_thread')->update($moderatetids, array('stamp' => -1), true); } else { C::t('forum_thread')->update($moderatetids, array('stamp' => $_G['cache']['stamptypeid'][$typeid]), true); } !empty($moderatetids) && updatemodlog($moderatetids, $stampaction, $expiration, 0, '', $_G['cache']['stamptypeid'][$typeid]); } }
if ($globalstick && $stickmodify) { require_once DISCUZ_ROOT . './include/cache.func.php'; updatecache('globalstick'); } $modaction = 'MOV'; updateforumcount($moveto); updateforumcount($fid); } elseif ($operation == 'type') { if (!isset($forum['threadtypes']['types'][$typeid]) && ($typeid != 0 || $forum['threadtypes']['required'])) { showmessage('admin_type_invalid'); } $db->query("UPDATE {$tablepre}threads SET typeid='{$typeid}', moderated='1' WHERE tid IN ({$moderatetids})"); $modaction = 'TYP'; } if ($updatemodlog) { updatemodlog($moderatetids, $modaction, $expiration); } updatemodworks($modaction, $modpostsnum); foreach ($threadlist as $thread) { modlog($thread, $modaction); } if ($sendreasonpm) { include_once language('modactions'); $modaction = $modactioncode[$modaction]; foreach ($threadlist as $thread) { sendreasonpm('thread', $operation == 'move' ? 'reason_move' : 'reason_moderate'); } } procreportlog($moderatetids, '', $operation == 'delete'); } showmessage('admin_succeed', $referer);
<?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: topicadmin_stamplist.php 20099 2011-02-15 01:55:29Z monkey $ */ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } if (!$_G['group']['allowstamplist']) { showmessage('no_privilege_stamplist'); } loadcache('stamps'); if (!submitcheck('modsubmit')) { include template('forum/topicadmin_action'); } else { $_G['gp_stamplist'] = $_G['gp_stamplist'] !== '' ? $_G['gp_stamplist'] : -1; $modaction = $_G['gp_stamplist'] >= 0 ? 'L' . sprintf('%02d', $_G['gp_stamplist']) : 'SLD'; $reason = checkreasonpm(); DB::query("UPDATE " . DB::table('forum_thread') . " SET moderated='1', icon='{$_G['gp_stamplist']}' WHERE tid='{$_G['tid']}'"); $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => $_G['gp_stamplist'] !== '' ? 'reason_stamplist_update' : 'reason_stamplist_delete') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason), 'stamp' => $_G['cache']['stamps'][$_G['gp_stamplist']]['text']), 'modaction' => $modaction, 'modlog' => $thread); $modpostsnum = 1; updatemodlog($_G['tid'], $modaction); }
function set_stamp($typeid) { global $tablepre, $db, $_DCACHE, $moderatetids, $expiration; if (array_key_exists($typeid, $_DCACHE['stamptypeid'])) { $db->query("UPDATE {$tablepre}threads SET " . buildbitsql('status', 5, TRUE) . " WHERE tid IN ({$moderatetids})"); updatemodlog($moderatetids, 'SPA', $expiration, 0, $_DCACHE['stamptypeid'][$typeid]); } }
function set_stamp($typeid, $stampaction, &$threadlist, $expiration) { global $_G; $moderatetids = dimplode(array_keys($threadlist)); if (empty($threadlist)) { return false; } if (array_key_exists($typeid, $_G['cache']['stamptypeid'])) { if ($stampaction == 'SPD') { DB::query("UPDATE " . DB::table('forum_thread') . " SET stamp='-1' WHERE tid IN ({$moderatetids})"); } else { DB::query("UPDATE " . DB::table('forum_thread') . " SET stamp='" . $_G['cache']['stamptypeid'][$typeid] . "' WHERE tid IN ({$moderatetids})"); } !empty($moderatetids) && updatemodlog($moderatetids, $stampaction, $expiration, 0, '', $_G['cache']['stamptypeid'][$typeid]); } }
public function editpost($parameters) { $this->_init_parameters($parameters); $isfirstpost = $this->post['first'] ? 1 : 0; $isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid']; $this->param['audit'] = $this->post['invisible'] == -2 || $this->thread['displayorder'] == -2 ? $this->param['audit'] : 0; list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']); if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $isfirstpost && ($this->param['special'] || $this->param['sortid']))) { showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize'])); } if (!$isorigauthor && !$this->group['allowanonymous']) { if ($this->post['anonymous'] && !$this->param['isanonymous']) { $this->param['isanonymous'] = 0; $this->param['threadupdatearr']['author'] = $this->post['author']; $anonymousadd = 0; } else { $this->param['isanonymous'] = $this->post['anonymous']; $anonymousadd = ''; } } else { $this->param['threadupdatearr']['author'] = $this->param['isanonymous'] ? '' : $this->post['author']; $anonymousadd = $this->param['isanonymous']; } if ($isfirstpost) { if (trim($this->param['subject']) == '' && $this->thread['special'] != 2) { showmessage('post_sm_isnull'); } if (!$this->param['sortid'] && !$this->thread['special'] && trim($this->param['message']) == '') { showmessage('post_sm_isnull'); } $publishdate = null; if ($this->group['allowsetpublishdate'] && $this->thread['displayorder'] == -4) { $cron_publish_ids = dunserialize($this->cache('cronpublish')); if (!$this->param['cronpublish'] && in_array($this->thread['tid'], $cron_publish_ids) || $this->param['modnewthreads']) { $this->param['threadupdatearr']['dateline'] = $publishdate = TIMESTAMP; unset($cron_publish_ids[$this->thread['tid']]); $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } elseif ($this->param['cronpublish'] && $this->param['cronpublishdate']) { $this->param['threadupdatearr']['dateline'] = $publishdate = strtotime($this->param['cronpublishdate']); $this->param['save'] = 1; if (!in_array($this->thread['tid'], $cron_publish_ids)) { $cron_publish_ids[$this->thread['tid']] = $this->thread['tid']; $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } } } $this->param['readperm'] = $this->group['allowsetreadperm'] ? intval($this->param['readperm']) : ($isorigauthor ? 0 : 'ignore'); if ($this->thread['special'] != 3) { $this->param['price'] = intval($this->param['price']); $this->param['price'] = $this->thread['price'] < 0 && !$this->thread['special'] ? $isorigauthor || !$this->param['price'] ? -1 : $this->param['price'] : ($this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] > 0 ? $this->param['price'] : 0 : $this->group['maxprice'] : ($isorigauthor ? $this->param['price'] : $this->thread['price'])); if ($this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) { return $this->showmessage('post_net_price_iszero'); } } $this->thread['status'] = setstatus(4, $this->param['ordertype'], $this->thread['status']); $this->thread['status'] = setstatus(15, $this->param['imgcontent'], $this->thread['status']); if ($this->param['imgcontent']) { stringtopic($this->param['message'], $this->post['tid'], true, $this->param['imgcontentwidth']); } $this->thread['status'] = setstatus(2, $this->param['hiddenreplies'], $this->thread['status']); $this->thread['status'] = setstatus(6, $this->param['allownoticeauthor'] ? 1 : 0, $this->thread['status']); $displayorder = empty($this->param['save']) ? $this->thread['displayorder'] == -4 ? -4 : $this->thread['displayorder'] : -4; $this->param['threadupdatearr']['typeid'] = $this->param['typeid']; $this->param['threadupdatearr']['sortid'] = $this->param['sortid']; $this->param['threadupdatearr']['subject'] = $this->param['subject']; if ($this->param['readperm'] !== 'ignore') { $this->param['threadupdatearr']['readperm'] = $this->param['readperm']; } $this->param['threadupdatearr']['price'] = $this->param['price']; $this->param['threadupdatearr']['status'] = $this->thread['status']; if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { $this->param['threadupdatearr']['displayorder'] = 0; $this->param['threadupdatearr']['moderated'] = 1; } else { $this->param['threadupdatearr']['displayorder'] = $displayorder; } C::t('forum_thread')->update($this->thread['tid'], $this->param['threadupdatearr'], true); if ($this->thread['tid'] > 1) { if ($this->thread['closed'] > 1) { C::t('forum_thread')->update($this->thread['closed'], array('subject' => $this->param['subject']), true); } elseif (empty($this->thread['isgroup'])) { $threadclosed = C::t('forum_threadclosed')->fetch($thread['tid']); if ($threadclosed['redirect']) { C::t('forum_thread')->update($threadclosed['redirect'], array('subject' => $this->param['subject']), true); } } } $class_tag = new tag(); $tagstr = $class_tag->update_field($this->param['tags'], $this->thread['tid'], 'tid', $this->thread); } else { if ($this->param['subject'] == '' && $this->param['message'] == '' && $this->thread['special'] != 2) { showmessage('post_sm_isnull'); } } $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0; if ($this->setting['editedby'] && TIMESTAMP - $this->post['dateline'] > 60 && $this->member['adminid'] != 1) { $editor = $this->param['isanonymous'] && $isorigauthor ? lang('forum/misc', 'anonymous') : $this->member['username']; $edittime = dgmdate(TIMESTAMP); $this->param['message'] = lang('forum/misc', $this->param['htmlon'] ? 'post_edithtml' : (!$this->forum['allowbbcode'] || $this->param['bbcodeoff'] ? 'post_editnobbcode' : 'post_edit'), array('editor' => $editor, 'edittime' => $edittime)) . $this->param['message']; } $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff'])); $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff'])); $tagoff = $isfirstpost ? !empty($tagoff) : 0; if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { C::t('forum_post')->update($this->thread['posttableid'], $this->post['pid'], array('status' => 4), false, false, null, -2, null, 0); updatepostcredits('+', $this->post['authorid'], $isfirstpost ? 'post' : 'reply', $this->forum['fid']); updatemodworks('MOD', 1); updatemodlog($this->thread['tid'], 'MOD'); } $displayorder = $pinvisible = 0; if ($isfirstpost) { $displayorder = $this->param['modnewthreads'] ? -2 : $this->thread['displayorder']; $pinvisible = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3); } else { $pinvisible = $this->param['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0); } $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']); $this->param['parseurloff'] = !empty($this->param['parseurloff']); $setarr = array('message' => $this->param['message'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'parseurloff' => $this->param['parseurloff'], 'smileyoff' => $this->param['smileyoff'], 'subject' => $this->param['subject'], 'tags' => $tagstr, 'port' => getglobal('remoteport')); $setarr['status'] = $this->post['status']; if ($this->param['modstatus']) { foreach ($this->param['modstatus'] as $modbit => $modvalue) { $setarr['status'] = setstatus($modbit, $modvalue, $setarr['status']); } } if ($anonymousadd !== '') { $setarr['anonymous'] = $anonymousadd; } if ($publishdate) { $setarr['dateline'] = $publishdate; } if (getglobal('forum_auditstatuson') && $this->param['audit'] == 1) { $setarr['invisible'] = 0; } else { $setarr['invisible'] = $pinvisible; } C::t('forum_post')->update('tid:' . $this->thread['tid'], $this->post['pid'], $setarr); $this->forum['lastpost'] = explode("\t", $this->forum['lastpost']); if ($this->post['dateline'] == $this->forum['lastpost'][2] && ($this->post['author'] == $this->forum['lastpost'][3] || $this->forum['lastpost'][3] == '' && $this->post['anonymous'])) { $lastpost = $this->thread['tid'] . "\t" . ($isfirstpost ? $this->param['subject'] : $this->thread['subject']) . "\t" . $this->post['dateline'] . "\t" . ($this->param['isanonymous'] ? '' : $this->post['author']); C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost)); } if (!getglobal('forum_auditstatuson') || $this->param['audit'] != 1) { if ($isfirstpost && $this->param['modnewthreads']) { C::t('forum_thread')->update($this->thread['tid'], array('displayorder' => -2)); manage_addnotify('verifythread'); } elseif (!$isfirstpost && $this->param['modnewreplies']) { C::t('forum_thread')->increase($this->thread['tid'], array('replies' => -1)); manage_addnotify('verifypost'); } if ($this->param['modnewreplies'] || $this->param['modnewthreads']) { C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1')); } } if ($this->thread['lastpost'] == $this->post['dateline'] && (!$this->post['anonymous'] && $this->thread['lastposter'] == $this->post['author'] || $this->post['anonymous'] && $this->thread['lastposter'] == '') && $this->post['anonymous'] != $this->param['isanonymous']) { C::t('forum_thread')->update($this->thread['tid'], array('lastposter' => $this->param['isanonymous'] ? '' : $this->post['author']), true); } if (!$isorigauthor) { updatemodworks('EDT', 1); require_once libfile('function/misc'); modlog($this->thread, 'EDT'); } if ($isfirstpost && $this->thread['displayorder'] == -4 && empty($this->param['save'])) { threadpubsave($this->thread['tid']); } }
if (!empty($infloat)) { $viewpid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='{$tid}' AND first='1' LIMIT 1"); $redirecturl = "viewthread.php?tid={$tid}&viewpid={$viewpid}#pid{$viewpid}"; } else { $redirecturl = "viewthread.php?do=tradeinfo&tid={$tid}&pid={$pid}"; } } } $feed = array(); if ($special == 127) { $message .= chr(0) . chr(0) . chr(0) . $specialextra; } if ($auditstatuson && $audit == 1) { updatepostcredits('+', $orig['authorid'], $isfirstpost ? $postcredits : $replycredits); updatemodworks('MOD', 1); updatemodlog($tid, 'MOD'); } $displayorder = $pinvisible = 0; if ($isfirstpost) { $displayorder = $modnewthreads ? -2 : $thread['displayorder']; $pinvisible = $modnewthreads ? -2 : 0; } else { $pinvisible = $modnewreplies ? -2 : 0; } $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message); $db->query("UPDATE {$tablepre}posts SET message='{$message}', usesig='{$usesig}', htmlon='{$htmlon}', bbcodeoff='{$bbcodeoff}', parseurloff='{$parseurloff}',\r\n\t\t\tsmileyoff='{$smileyoff}', subject='{$subject}' " . ($db->result_first("SELECT aid FROM {$tablepre}attachments WHERE pid='{$pid}' LIMIT 1") ? ", attachment='1'" : '') . " {$anonymousadd} " . ($auditstatuson && $audit == 1 ? ",invisible='0'" : ", invisible='{$pinvisible}'") . " WHERE pid='{$pid}'"); $forum['lastpost'] = explode("\t", $forum['lastpost']); if ($orig['dateline'] == $forum['lastpost'][2] && ($orig['author'] == $forum['lastpost'][3] || $forum['lastpost'][3] == '' && $orig['anonymous'])) { $lastpost = "{$tid}\t" . ($isfirstpost ? $subject : addslashes($thread['subject'])) . "\t{$orig['dateline']}\t" . ($isanonymous ? '' : addslashes($orig['author'])); $db->query("UPDATE {$tablepre}forums SET lastpost='{$lastpost}' WHERE fid='{$fid}'", 'UNBUFFERED'); }
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)); } }
$banid .= '<input type="hidden" name="topiclist[]" value="' . $id . '" />'; } include template('topicadmin_banpost'); } else { $banned = intval($banned); $modaction = $banned ? 'BNP' : 'UBN'; checkreasonpm(); $db->query("UPDATE {$tablepre}posts SET status='{$banned}' WHERE pid IN ({$banpids}) AND tid='{$tid}'", 'UNBUFFERED'); $resultarray = array('redirect' => "viewthread.php?tid={$tid}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post') : array(), 'modtids' => 0, 'modlog' => $thread); } } else { showmessage('undefined_action', NULL, 'HALTED'); } if ($resultarray) { if ($resultarray['modtids']) { updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']); } updatemodworks($modaction, $modpostsnum); if (is_array($resultarray['modlog'])) { if (isset($resultarray['modlog']['tid'])) { modlog($resultarray['modlog'], $modaction); } else { foreach ($resultarray['modlog'] as $thread) { modlog($thread, $modaction); } } } if ($resultarray['reasonpm']) { include language('modactions'); $modaction = $modactioncode[$modaction]; foreach ($resultarray['reasonpm']['data'] as ${$resultarray['reasonpm']['var']}) {
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 = $posttabletids = array(); $query = DB::query('SELECT tid, posttableid FROM ' . DB::table('forum_thread') . " WHERE tid IN ({$tids})"); while ($thread = DB::fetch($query)) { $posttabletids[$thread['posttableid'] ? $thread['posttableid'] : 0][] = $thread['tid']; } foreach ($posttabletids as $posttableid => $ptids) { $query = DB::query('SELECT fid, first, authorid FROM ' . DB::table(getposttable($posttableid)) . " WHERE tid IN (" . dimplode($ptids) . ")"); while ($post = DB::fetch($query)) { if ($post['first']) { $tuidarray[] = $post['authorid']; } else { $ruidarray[] = $post['authorid']; } if (!in_array($post['fid'], $fidarray)) { $fidarray[] = $post['fid']; } } updatepost(array('invisible' => '0'), "tid IN (" . dimplode($ptids) . ")", true, $posttableid); } if ($tuidarray) { updatepostcredits('+', $tuidarray, 'post'); } if ($ruidarray) { updatepostcredits('+', $ruidarray, 'reply'); } 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; }
} 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']); } else { $fids = array_keys($modforums['list']); foreach ($fids as $f) { updateforumcount($f); } } updatemodworks('MOD', $threadsmod); updatemodlog($tidstr, 'MOD'); updatemoderate('tid', $tids, 2); } } if ($pmlist) { foreach ($pmlist as $pm) { $threadsubject = $pm['thread']; $_G['tid'] = intval($pm['tid']); notification_add($pm['authorid'], 'system', $pm['act'], $pm['notevar'], 1); } } showmessage('modcp_mod_succeed', "{$cpscript}?mod=modcp&action={$_GET['action']}&op={$op}&filter={$filter}&fid={$_G['fid']}"); } $modcount = C::t('common_moderate')->count_by_seach_for_thread($moderatestatus, $modfids ? explode(',', $modfids) : null); $multipage = multi($modcount, $_G['tpp'], $page, "{$cpscript}?mod=modcp&action={$_GET['action']}&op={$op}&filter={$filter}&fid={$_G['fid']}"); if ($modcount) {
<?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: topicadmin_stamp.php 16938 2010-09-17 04:37:59Z monkey $ */ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } if (!$_G['group']['allowstampthread']) { showmessage('undefined_action', NULL); } loadcache('stamps'); if (!submitcheck('modsubmit')) { include template('forum/topicadmin_action'); } else { $modaction = $_G['gp_stamp'] !== '' ? 'SPA' : 'SPD'; $_G['gp_stamp'] = $_G['gp_stamp'] !== '' ? $_G['gp_stamp'] : -1; $reason = checkreasonpm(); DB::query("UPDATE " . DB::table('forum_thread') . " SET moderated='1', stamp='{$_G['gp_stamp']}' WHERE tid='{$_G['tid']}'"); if ($modaction == 'SPA' && $_G['cache']['stamps'][$_G['gp_stamp']]['icon']) { DB::query("UPDATE " . DB::table('forum_thread') . " SET icon='" . $_G['cache']['stamps'][$_G['gp_stamp']]['icon'] . "' WHERE tid='{$_G['tid']}'"); } elseif ($modaction == 'SPD' && $_G['cache']['stamps'][$thread['stamp']]['icon'] == $thread['icon']) { DB::query("UPDATE " . DB::table('forum_thread') . " SET icon='-1' WHERE tid='{$_G['tid']}'"); } $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => $_G['gp_stamp'] !== '' ? 'reason_stamp_update' : 'reason_stamp_delete') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason), 'stamp' => $_G['cache']['stamps'][$stamp]['text']), 'modaction' => $modaction, 'modlog' => $thread); $modpostsnum = 1; updatemodlog($_G['tid'], $modaction, 0, 0, '', $modaction == 'SPA' ? $_G['gp_stamp'] : 0); }
foreach ($postlist as $post) { $prune['forums'][] = $post['fid']; $prune['thread'][$post['tid']]++; if ($post['first']) { $tidsdelete[] = $post['tid']; } $pidsdelete[] = $post['pid']; $pidsthread[$post['pid']] = $post['tid']; } foreach ($pidsdelete as $key => $pid) { if (in_array($pidsthread[$pid], $tidsdelete)) { unset($pidsdelete[$key]); unset($prune['thread'][$pidsthread[$pid]]); updatemodlog($pidsthread[$pid], 'DEL'); } else { updatemodlog($pidsthread[$pid], 'DLP'); } } } deletepost($pidsdelete, 'pid', false, $posttableid, true); } unset($postlist); if ($tidsdelete) { deletethread($tidsdelete, true, true, true); } if (!empty($prune)) { foreach ($prune['thread'] as $tid => $decrease) { updatethreadcount($tid); } foreach (array_unique($prune['forums']) as $fid) { }
private function _adminTopic($fid, $tid, $pid, $act, $type) { global $_G; $errorMsg = ''; $_GET['topiclist'] = array($_GET['pid']); // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发 $_GET['topiclist'] = !empty($_GET['topiclist']) ? is_array($_GET['topiclist']) ? array_unique($_GET['topiclist']) : $_GET['topiclist'] : array(); loadcache(array('modreasons', 'stamptypeid', 'threadtableids')); require_once libfile('function/post'); require_once libfile('function/misc'); $modpostsnum = 0; $resultarray = $thread = array(); if ($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3 || !empty($_GET['sendreasonpm'])) { $forumname = strip_tags($_G['forum']['name']); $sendreasonpm = 1; } else { $sendreasonpm = 0; } if ($type == 'topic') { if ($act == 'band') { $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread'])); } else { // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_moderate.php基础上进行二次开发 $thread = $_G['forum_thread']; $thread['dblastpost'] = $thread['lastpost']; $threadlist[$thread['tid']] = $thread; $modpostsnum = count($threadlist); $stickcheck = $closecheck = $digestcheck = array('', '', '', '', ''); empty($threadlist[$_G['tid']]['displayorder']) ? $stickcheck[0] = 'selected="selected"' : ($stickcheck[$threadlist[$_G['tid']]['displayorder']] = 'selected="selected"'); empty($threadlist[$_G['tid']]['digest']) ? $digestcheck[0] = 'selected="selected"' : ($digestcheck[$threadlist[$_G['tid']]['digest']] = 'selected="selected"'); empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : ($closecheck[1] = 'checked="checked"'); if (!empty($_POST)) { $tidsarr = array_keys($threadlist); $moderatetids = dimplode($tidsarr); $reason = checkreasonpm(); $stampstatus = 0; $stampaction = 'SPA'; $operationMap = array('top' => 'stick', 'marrow' => 'digest', 'delete' => 'delete'); $operation = $operationMap[$act]; $updatemodlog = TRUE; switch ($act) { case 'top': $sticklevel = intval($_GET['sticklevel']); if ($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) { // showmessage('no_privilege_stickthread'); $this->_exitWithHtmlAlert('no_privilege_stickthread'); } $expiration = checkexpiration($_GET['expirationstick'], $operation); $expirationstick = $sticklevel ? $_GET['expirationstick'] : 0; $forumstickthreads = $_G['setting']['forumstickthreads']; $forumstickthreads = isset($forumstickthreads) ? dunserialize($forumstickthreads) : array(); C::t('forum_thread')->update($tidsarr, array('displayorder' => $sticklevel, 'moderated' => 1), true); $delkeys = array_keys($threadlist); foreach ($delkeys as $k) { unset($forumstickthreads[$k]); } C::t('common_setting')->update('forumstickthreads', $forumstickthreads); $stickmodify = 0; foreach ($threadlist as $thread) { $stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify; } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } $modaction = $sticklevel ? $expiration ? 'EST' : 'STK' : 'UST'; C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('STK', 'UST', 'EST', 'UES'), array('status' => 0)); if (!$sticklevel) { $stampaction = 'SPD'; } $stampstatus = 1; break; case 'marrow': $digestlevel = intval($_GET['digestlevel']); if ($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $_G['group']['allowdigestthread']) { // showmessage('no_privilege_digestthread'); $this->_exitWithHtmlAlert('no_privilege_digestthread'); } $expiration = checkexpiration($_GET['expirationdigest'], $operation); $expirationdigest = $digestlevel ? $expirationdigest : 0; C::t('forum_thread')->update($tidsarr, array('digest' => $digestlevel, 'moderated' => 1), true); foreach ($threadlist as $thread) { if ($thread['digest'] != $digestlevel) { if ($digestlevel == $thread['digest']) { continue; } $extsql = array(); if ($digestlevel > 0 && $thread['digest'] == 0) { $extsql = array('digestposts' => 1); } if ($digestlevel == 0 && $thread['digest'] > 0) { $extsql = array('digestposts' => -1); } if ($digestlevel == 0) { $stampaction = 'SPD'; } updatecreditbyaction('digest', $thread['authorid'], $extsql, '', $digestlevel - $thread['digest']); } } $modaction = $digestlevel ? $expiration ? 'EDI' : 'DIG' : 'UDG'; C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('DIG', 'UDI', 'EDI', 'UED'), array('status' => 0)); $stampstatus = 2; break; case 'delete': if (!$_G['group']['allowdelpost']) { // showmessage('no_privilege_delpost'); $this->_exitWithHtmlAlert('no_privilege_delpost'); } loadcache('threadtableids'); $stickmodify = 0; $deleteredirect = $remarkclosed = array(); foreach ($threadlist as $thread) { if ($thread['digest']) { updatecreditbyaction('digest', $thread['authorid'], array('digestposts' => -1), '', -$thread['digest']); } if (in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if ($_G['forum']['status'] == 3 && $thread['closed'] > 1) { $deleteredirect[] = $thread['closed']; } if ($thread['isgroup'] == 1 && $thread['closed'] > 1) { $remarkclosed[] = $thread['closed']; } } $modaction = 'DEL'; require_once libfile('function/delete'); $tids = array_keys($threadlist); if ($_G['forum']['recyclebin']) { deletethread($tids, true, true, true); manage_addnotify('verifyrecycle', $modpostsnum); } else { deletethread($tids, true, true); $updatemodlog = FALSE; } $forumstickthreads = $_G['setting']['forumstickthreads']; $forumstickthreads = !empty($forumstickthreads) ? dunserialize($forumstickthreads) : array(); $delkeys = array_keys($threadlist); foreach ($delkeys as $k) { unset($forumstickthreads[$k]); } C::t('common_setting')->update('forumstickthreads', $forumstickthreads); C::t('forum_forum_threadtable')->delete_none_threads(); if (!empty($deleteredirect)) { deletethread($deleteredirect); } if (!empty($remarkclosed)) { C::t('forum_thread')->update($remarkclosed, array('closed' => 0)); } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } updateforumcount($_G['fid']); if ($_GET['crimerecord']) { include_once libfile('function/member'); foreach ($threadlist as $thread) { crime('recordaction', $thread['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $thread['tid'], 'pid' => 0))); } } break; case 'close': if (!$_G['group']['allowclosethread']) { $this->_exitWithHtmlAlert('no_privilege_closethread'); } $expiration = checkexpiration($_GET['expirationclose'], $operation); $modaction = $expiration ? 'ECL' : 'CLS'; C::t('forum_thread')->update($tidsarr, array('closed' => 1, 'moderated' => 1), true); C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0)); break; case 'open': if (!$_G['group']['allowclosethread']) { $this->_exitWithHtmlAlert('no_privilege_openthread'); } $expiration = checkexpiration($_GET['expirationclose'], $operation); $modaction = $expiration ? 'EOP' : 'OPN'; C::t('forum_thread')->update($tidsarr, array('closed' => 0, 'moderated' => 1), true); C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0)); break; case 'move': if (!$_G['group']['allowmovethread']) { $this->_exitWithHtmlAlert('no_privilege_movethread'); } $moveto = $_GET['moveto']; $toforum = C::t('forum_forum')->fetch_info_by_fid($moveto); if (!$toforum || $_G['adminid'] != 1 && $toforum['status'] != 1 || $toforum['type'] == 'group') { // showmessage('admin_move_invalid'); $this->_exitWithHtmlAlert('admin_move_invalid'); } elseif ($_G['fid'] == $toforum['fid']) { continue; } else { $moveto = $toforum['fid']; $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0; $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0; if ($modnewthreads || $modnewreplies) { // showmessage('admin_move_have_mod'); $this->_exitWithHtmlAlert('admin_move_have_mod'); } } if ($_G['adminid'] == 3) { $priv = C::t('forum_forumfield')->check_moderator_for_uid($moveto, $_G['uid'], $_G['member']['accessmasks']); if (($priv['postperm'] && !in_array($_G['groupid'], explode("\t", $priv['postperm'])) || $_G['member']['accessmasks'] && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost']) && !$priv['istargetmod']) { // showmessage('admin_move_nopermission'); $this->_exitWithHtmlAlert('admin_move_nopermission'); } } $moderate = array(); $stickmodify = 0; $toforumallowspecial = array(1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && $toforum['allowpostspecial'] & 4, 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array()); foreach ($threadlist as $tid => $thread) { $allowmove = 0; if (!$thread['special']) { $allowmove = 1; } else { if ($thread['special'] != 127) { $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0; } else { if ($toforumallowspecial[127]) { $posttable = getposttablebytid($thread['tid']); $message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']); $message = $message['message']; $sppos = strrpos($message, chr(0) . chr(0) . chr(0)); $specialextra = substr($message, $sppos + 3); $allowmove = in_array($specialextra, $toforumallowspecial[127]); } else { $allowmove = 0; } } } if ($allowmove) { $moderate[] = $tid; if (in_array($thread['displayorder'], array(2, 3))) { $stickmodify = 1; } if ($_GET['appbyme_movetype'] == 'redirect') { // if($_GET['type'] == 'redirect') { $insertdata = array('fid' => $thread['fid'], 'readperm' => $thread['readperm'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'subject' => $thread['subject'], 'dateline' => $thread['dateline'], 'lastpost' => $thread['dblastpost'], 'lastposter' => $thread['lastposter'], 'views' => 0, 'replies' => 0, 'displayorder' => 0, 'digest' => 0, 'closed' => $thread['tid'], 'special' => 0, 'attachment' => 0, 'typeid' => $_GET['threadtypeid']); $newtid = C::t('forum_thread')->insert($insertdata, true); if ($newtid) { C::t('forum_threadclosed')->insert(array('tid' => $thread['tid'], 'redirect' => $newtid), true, true); } } } } if (!($moderatetids = implode(',', $moderate))) { showmessage('admin_moderate_invalid'); } $fieldarr = array('fid' => $moveto, 'isgroup' => 0, 'typeid' => $_GET['threadtypeid'], 'moderated' => 1); if ($_G['adminid'] == 3) { $fieldarr['displayorder'] = 0; } C::t('forum_thread')->update($tidsarr, $fieldarr, true); C::t('forum_forumrecommend')->update($tidsarr, array('fid' => $moveto)); loadcache('posttableids'); $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0'); foreach ($posttableids as $id) { C::t('forum_post')->update_by_tid($id, $tidsarr, array('fid' => $moveto)); } $typeoptionvars = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tidsarr); foreach ($typeoptionvars as $typeoptionvar) { C::t('forum_typeoptionvar')->update_by_tid($typeoptionvar['tid'], array('fid' => $moveto)); C::t('forum_optionvalue')->update($typeoptionvar['sortid'], $typeoptionvar['tid'], $_G['fid'], "fid='{$moveto}'"); } if ($_G['setting']['globalstick'] && $stickmodify) { require_once libfile('function/cache'); updatecache('globalstick'); } $modaction = 'MOV'; $_G['toforum'] = $toforum; updateforumcount($moveto); updateforumcount($_G['fid']); break; default: $errorMsg = '错误的动作参数'; break; } if ($errorMsg == '') { if ($updatemodlog) { if ($operation != 'delete') { updatemodlog($moderatetids, $modaction, $expiration); } else { updatemodlog($moderatetids, $modaction, $expiration, 0, $reason); } } updatemodworks($modaction, $modpostsnum); foreach ($threadlist as $thread) { modlog($thread, $modaction); } if ($sendreasonpm) { $modactioncode = lang('forum/modaction'); $modtype = $modaction; $modaction = $modactioncode[$modaction]; foreach ($threadlist as $thread) { if ($operation == 'move') { sendreasonpm($thread, 'reason_move', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'tofid' => $toforum['fid'], 'toname' => $toforum['name'], 'from_id' => 0, 'from_idtype' => 'movethread')); } else { sendreasonpm($thread, 'reason_moderate', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'moderate_' . $modtype)); } } } if ($stampstatus) { set_stamp($stampstatus, $stampaction, $threadlist, $expiration); } $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview')); } } else { if ($act == 'move') { require_once libfile('function/forumlist'); $forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid'], $_G['adminid'] == 1 ? TRUE : FALSE); } } } } else { if ($type == 'post') { if ($act == 'band') { $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread'])); } else { // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_delpost.php基础上进行二次开发 $resultarray = array(); $thread = $_G['forum_thread']; $topiclist = array($pid); $modpostsnum = 1; $pids = $posts = $authors = array(); $posttable = getposttablebytid($_G['tid']); foreach (C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $topiclist, false) as $post) { if ($post['tid'] != $_G['tid']) { continue; } if ($post['first'] == 1) { dheader("location: {$_G['siteurl']}forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid={$_G['fid']}&moderate[]={$thread['tid']}&inajax=yes" . ($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : '')); } else { $authors[$post['authorid']] = 1; $pids[] = $post['pid']; $posts[] = $post; } } if (!empty($_POST)) { $reason = checkreasonpm(); $uidarray = $puidarray = $auidarray = array(); $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0; if ($pids) { require_once libfile('function/delete'); if ($_G['forum']['recyclebin']) { deletepost($pids, 'pid', true, false, true); manage_addnotify('verifyrecyclepost', $modpostsnum); } else { $logs = array(); $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids); $rposts = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $pids, false); foreach (C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) { if ($author['score'] > 0) { $rpost = $rposts[$rpid]; updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score'])); $author['score'] = $_G['setting']['extcredits'][$id]['title'] . ' ' . -$author['score'] . ' ' . $_G['setting']['extcredits'][$id]['unit']; $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}"); } } if (!empty($logs)) { writelog('ratelog', $logs); unset($logs); } deletepost($pids, 'pid', true); } if ($_GET['crimerecord']) { include_once libfile('function/member'); foreach ($posts as $post) { crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid']))); } } } updatethreadcount($_G['tid'], 1); updateforumcount($_G['fid']); $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']); $modaction = 'DLP'; $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modtids' => 0, 'modlog' => $thread); } } } } // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发 if ($resultarray) { if ($resultarray['modtids']) { updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']); } updatemodworks($modaction, $modpostsnum); if (is_array($resultarray['modlog'])) { if (isset($resultarray['modlog']['tid'])) { modlog($resultarray['modlog'], $modaction); } else { foreach ($resultarray['modlog'] as $thread) { modlog($thread, $modaction); } } } if ($resultarray['reasonpm']) { $modactioncode = lang('forum/modaction'); $modaction = $modactioncode[$modaction]; foreach ($resultarray['reasonpm']['data'] as $var) { sendreasonpm($var, $resultarray['reasonpm']['item'], $resultarray['reasonvar'], $resultarray['reasonpm']['notictype']); } } // showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']); $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview')); } $this->getController()->renderPartial('topicAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $fid, 'tid' => $tid, 'pid' => $pid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'stickcheck' => $stickcheck, 'digestcheck' => $digestcheck, 'closecheck' => $closecheck, 'forumselect' => WebUtils::u($forumselect))); }
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; }
function undeletethreads($tids) { global $_G; if ($_G['setting']['plugins']['func'][HOOKTYPE]['undeletethreads']) { $param = func_get_args(); hookscript('undeletethreads', 'global', 'funcs', array('param' => $param), 'undeletethreads'); } $threadsundel = 0; if ($tids && is_array($tids)) { $arrtids = $tids; $tids = '\'' . implode('\',\'', $tids) . '\''; $tuidarray = $ruidarray = $fidarray = $posttabletids = array(); foreach (C::t('forum_thread')->fetch_all_by_tid($arrtids) as $thread) { $posttabletids[$thread['posttableid'] ? $thread['posttableid'] : 0][] = $thread['tid']; } foreach ($posttabletids as $posttableid => $ptids) { foreach (C::t('forum_post')->fetch_all_by_tid($posttableid, $ptids, false) as $post) { if ($post['first']) { $tuidarray[$post['fid']][] = $post['authorid']; } else { $ruidarray[$post['fid']][] = $post['authorid']; } if (!in_array($post['fid'], $fidarray)) { $fidarray[] = $post['fid']; } } C::t('forum_post')->update_by_tid($posttableid, $ptids, array('invisible' => '0'), true); } if ($tuidarray) { foreach ($tuidarray as $fid => $tuids) { updatepostcredits('+', $tuids, 'post', $fid); } } if ($ruidarray) { foreach ($ruidarray as $fid => $ruids) { updatepostcredits('+', $ruids, 'reply', $fid); } } $threadsundel = C::t('forum_thread')->update($arrtids, array('displayorder' => 0, 'moderated' => 1)); updatemodlog($tids, 'UDL'); updatemodworks('UDL', $threadsundel); foreach ($fidarray as $fid) { updateforumcount($fid); } } return $threadsundel; }
public function newthread($parameters) { require_once libfile('function/post'); $this->tid = $this->pid = 0; $this->_init_parameters($parameters); if (trim($this->param['subject']) == '') { return $this->showmessage('post_sm_isnull'); } if (!$this->param['sortid'] && !$this->param['special'] && trim($this->param['message']) == '') { return $this->showmessage('post_sm_isnull'); } list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject'] . "\t" . $this->param['message'] . $this->param['extramessage']); if ($post_invalid = checkpost($this->param['subject'], $this->param['message'], $this->param['special'] || $this->param['sortid'])) { return $this->showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize'])); } if (checkflood()) { return $this->showmessage('post_flood_ctrl', '', array('floodctrl' => $this->setting['floodctrl'])); } elseif (checkmaxperhour('tid')) { return $this->showmessage('thread_flood_ctrl_threads_per_hour', '', array('threads_per_hour' => $this->group['maxthreadsperhour'])); } $this->param['save'] = $this->member['uid'] ? $this->param['save'] : 0; $this->param['typeid'] = isset($this->param['typeid']) && isset($this->forum['threadtypes']['types'][$this->param['typeid']]) && (!$this->forum['threadtypes']['moderators'][$this->param['typeid']] || $this->forum['ismoderator']) ? $this->param['typeid'] : 0; $this->param['displayorder'] = $this->param['modnewthreads'] ? -2 : ($this->forum['ismoderator'] && $this->group['allowstickthread'] && !empty($this->param['sticktopic']) ? 1 : (empty($this->param['save']) ? 0 : -4)); if ($this->param['displayorder'] == -2) { C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1')); } $this->param['digest'] = $this->forum['ismoderator'] && $this->group['allowdigestthread'] && !empty($this->param['digest']) ? 1 : 0; $this->param['readperm'] = $this->group['allowsetreadperm'] ? $this->param['readperm'] : 0; $this->param['isanonymous'] = $this->group['allowanonymous'] && $this->param['isanonymous'] ? 1 : 0; $this->param['price'] = intval($this->param['price']); if (!$this->param['special']) { $this->param['price'] = $this->group['maxprice'] ? $this->param['price'] <= $this->group['maxprice'] ? $this->param['price'] : $this->group['maxprice'] : 0; } if (!$this->param['typeid'] && $this->forum['threadtypes']['required'] && !$this->param['special']) { return $this->showmessage('post_type_isnull'); } if (!$this->param['sortid'] && $this->forum['threadsorts']['required'] && !$this->param['special']) { return $this->showmessage('post_sort_isnull'); } if (!$this->param['special'] && $this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) { return $this->showmessage('post_net_price_iszero'); } $this->param['sortid'] = $this->param['special'] && $this->forum['threadsorts']['types'][$this->param['sortid']] ? 0 : $this->param['sortid']; $this->param['typeexpiration'] = intval($this->param['typeexpiration']); if ($this->forum['threadsorts']['expiration'][$this->param['typeid']] && !$this->param['typeexpiration']) { return $this->showmessage('threadtype_expiration_invalid'); } $author = !$this->param['isanonymous'] ? $this->member['username'] : ''; $this->param['moderated'] = $this->param['digest'] || $this->param['displayorder'] > 0 ? 1 : 0; $this->param['ordertype'] && ($this->param['tstatus'] = setstatus(4, 1, $this->param['tstatus'])); $this->param['imgcontent'] && ($this->param['tstatus'] = setstatus(15, $this->param['imgcontent'], $this->param['tstatus'])); $this->param['hiddenreplies'] && ($this->param['tstatus'] = setstatus(2, 1, $this->param['tstatus'])); $this->param['allownoticeauthor'] && ($this->param['tstatus'] = setstatus(6, 1, $this->param['tstatus'])); $this->param['isgroup'] = $this->forum['status'] == 3 ? 1 : 0; $this->param['publishdate'] = !$this->param['modnewthreads'] ? $this->param['publishdate'] : TIMESTAMP; $newthread = array('fid' => $this->forum['fid'], 'posttableid' => 0, 'readperm' => $this->param['readperm'], 'price' => $this->param['price'], 'typeid' => $this->param['typeid'], 'sortid' => $this->param['sortid'], 'author' => $author, 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'lastpost' => $this->param['publishdate'], 'lastposter' => $author, 'displayorder' => $this->param['displayorder'], 'digest' => $this->param['digest'], 'special' => $this->param['special'], 'attachment' => 0, 'moderated' => $this->param['moderated'], 'status' => $this->param['tstatus'], 'isgroup' => $this->param['isgroup'], 'replycredit' => $this->param['replycredit'], 'closed' => $this->param['closed'] ? 1 : 0); $this->tid = C::t('forum_thread')->insert($newthread, true); C::t('forum_newthread')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid'], 'dateline' => $this->param['publishdate'])); useractionlog($this->member['uid'], 'tid'); if (!getuserprofile('threads') && $this->setting['newbie']) { C::t('forum_thread')->update($this->tid, array('icon' => $this->setting['newbie'])); } if ($this->param['publishdate'] != TIMESTAMP) { $cron_publish_ids = dunserialize($this->cache('cronpublish')); $cron_publish_ids[$this->tid] = $this->tid; $cron_publish_ids = serialize($cron_publish_ids); savecache('cronpublish', $cron_publish_ids); } if (!$this->param['isanonymous']) { C::t('common_member_field_home')->update($this->member['uid'], array('recentnote' => $this->param['subject'])); } if ($this->param['moderated']) { updatemodlog($this->tid, $this->param['displayorder'] > 0 ? 'STK' : 'DIG'); updatemodworks($this->param['displayorder'] > 0 ? 'STK' : 'DIG', 1); } $this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff'])); $this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff'])); $this->param['parseurloff'] = !empty($this->param['parseurloff']); $this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0; $this->param['usesig'] = !empty($this->param['usesig']) && $this->group['maxsigsize'] ? 1 : 0; $class_tag = new tag(); $this->param['tagstr'] = $class_tag->add_tag($this->param['tags'], $this->tid, 'tid'); $this->param['pinvisible'] = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3); $this->param['message'] = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $this->param['message']); $this->param['pstatus'] = intval($this->param['pstatus']); defined('IN_MOBILE') && ($this->param['pstatus'] = setstatus(4, 1, $this->param['pstatus'])); if ($this->param['imgcontent']) { stringtopic($this->param['message'], $this->tid, true, $this->param['imgcontentwidth']); } $this->pid = insertpost(array('fid' => $this->forum['fid'], 'tid' => $this->tid, 'first' => '1', 'author' => $this->member['username'], 'authorid' => $this->member['uid'], 'subject' => $this->param['subject'], 'dateline' => $this->param['publishdate'], 'message' => $this->param['message'], 'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'), 'port' => $this->param['remoteport'] ? $this->param['remoteport'] : getglobal('remoteport'), 'invisible' => $this->param['pinvisible'], 'anonymous' => $this->param['isanonymous'], 'usesig' => $this->param['usesig'], 'htmlon' => $this->param['htmlon'], 'bbcodeoff' => $this->param['bbcodeoff'], 'smileyoff' => $this->param['smileyoff'], 'parseurloff' => $this->param['parseurloff'], 'attachment' => '0', 'tags' => $this->param['tagstr'], 'replycredit' => 0, 'status' => $this->param['pstatus'])); $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread'); include_once libfile('function/stat'); updatestat($this->param['isgroup'] ? 'groupthread' : $statarr[$this->param['special']]); if ($this->param['geoloc'] && IN_MOBILE == 2) { list($mapx, $mapy, $location) = explode('|', $this->param['geoloc']); if ($mapx && $mapy && $location) { C::t('forum_post_location')->insert(array('pid' => $this->pid, 'tid' => $this->tid, 'uid' => $this->member['uid'], 'mapx' => $mapx, 'mapy' => $mapy, 'location' => $location)); } } if ($this->param['modnewthreads']) { updatemoderate('tid', $this->tid); C::t('forum_forum')->update_forum_counter($this->forum['fid'], 0, 0, 1); manage_addnotify('verifythread'); return 'post_newthread_mod_succeed'; } else { if ($this->param['displayorder'] != -4) { if ($this->param['digest']) { updatepostcredits('+', $this->member['uid'], 'digest', $this->forum['fid']); } updatepostcredits('+', $this->member['uid'], 'post', $this->forum['fid']); if ($this->param['isgroup']) { C::t('forum_groupuser')->update_counter_for_user($this->member['uid'], $this->forum['fid'], 1); } $subject = str_replace("\t", ' ', $this->param['subject']); $lastpost = "{$this->tid}\t" . $subject . "\t" . TIMESTAMP . "\t{$author}"; C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost)); C::t('forum_forum')->update_forum_counter($this->forum['fid'], 1, 1, 1); if ($this->forum['type'] == 'sub') { C::t('forum_forum')->update($this->forum['fup'], array('lastpost' => $lastpost)); } } if ($this->param['isgroup']) { C::t('forum_forumfield')->update($this->forum['fid'], array('lastupdate' => TIMESTAMP)); require_once libfile('function/grouplog'); updategroupcreditlog($this->forum['fid'], $this->member['uid']); } C::t('forum_sofa')->insert(array('tid' => $this->tid, 'fid' => $this->forum['fid'])); return 'post_newthread_succeed'; } }
function article_move_forums($arr, $old_arr) { global $_G; $arr['content'] = preg_replace(array('/<center>([\\s\\S]*?)<\\/center>/', '/\\s(?=\\s)/'), array("[align=center]\\1[/align]", ''), $arr['content']); $subject = addslashes(trim($arr['title'])); if ($arr['check']) { if (!strlen($subject)) { return FALSE; } $num = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('forum_thread') . " WHERE subject='{$subject}' AND displayorder > '-1'"); if ($num) { return FALSE; } } if ($arr['contents'] > 1 && $arr['is_content_reply'] != 1) { $arr['reply'] = array(); } $time_arr = create_public_time($arr, count($arr['reply']) + 1, 1); if ($arr['contents'] == 1) { $uid_arr = get_rand_uid($arr, 'reply'); } else { if ($arr['is_content_reply'] != 1) { if ($arr['content_arr']) { $arr['content'] = content_merge($arr['content_arr']); } $uid_arr = get_rand_uid($arr); } } $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : array_shift($time_arr); require_once libfile('function/editor'); require_once libfile('function/forum'); $subject = htmlspecialchars_decode(format_html($subject)); $subject = htmlspecialchars_decode(format_html($subject)); $arr['content'] = dstripslashes($arr['content']); $arr['content'] = img_htmlbbcode($arr['content'], $arr['page_url']); $arr['content'] = media_htmlbbcode($arr['content'], $arr['page_url']); $arr['content'] = audio_htmlbbcode($arr['content'], $arr['page_url']); $message = htmlspecialchars_decode(html2bbcode($arr['content'])); $message = dstripslashes(format_html($message)); $arr['fid'] = $_G['fid'] = $_GET['forums'] ? $_GET['forums'] : $arr['forum_fid']; $_G['uid'] = $arr['uid'] ? $arr['uid'] : $_G['uid']; $view_num = $arr['view_num']; require_once libfile('function/post'); $special = 0; if (trim($subject) == '' || trim($message) == '') { return -1; } if (!$sortid && !$special && trim($message) == '') { return -1; } $_GET['save'] = $arr['uid'] ? $arr['uid'] : $_G['uid']; $uid = $_GET['save']; $typeid = intval($_GET['threadtypeid']) ? intval($_GET['threadtypeid']) : $arr['forum_typeid']; $displayorder = 0; $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0; $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0; $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0; $price = intval($price); $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0; if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) { return -2; } if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) { return -3; } if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) { return -4; } $_G['forum'] = DB::fetch_first("SELECT * FROM " . DB::table('forum_forum') . " WHERE fid = '{$arr['fid']}'"); //查询版块信息 if (!$_G['forum']) { return -5; } $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid; $typeexpiration = intval($_GET['typeexpiration']); if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) { return -5; } $_G['forum_optiondata'] = array(); if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) { $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $pid); } $author = !$arr['username'] ? $_G['username'] : $arr['username']; $moderated = $digest || $displayorder > 0 ? 1 : 0; $thread['status'] = 0; $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status'])); $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status'])); $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status'])); $isgroup = $_G['forum']['status'] == 3 ? 1 : 0; //检查各项设置 $bbcodeoff = checkbbcodes($message, FALSE); $smileyoff = checksmilies($message, FALSE); $parseurloff = FALSE; $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0; if ($_G['group']['allowreplycredit']) { $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']); $_GET['replycredit_times'] = intval($_GET['replycredit_times']); $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']); $_GET['replycredit_random'] = intval($_GET['replycredit_random']); $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random']; $replycredit = $replycredit_real = 0; } if ($old_arr['forum_id']) { $info = DB::fetch_first("SELECT p.pid,p.tid,t.tid,p.first FROM " . DB::table('forum_post') . " p Inner Join " . DB::table('forum_thread') . " t ON p.tid = t.tid WHERE p.first = '1' AND t.tid='" . $old_arr['forum_id'] . "' AND t.displayorder > '-1'"); } $reply_count = count($arr['reply']); $view_num = $view_num < $reply_count - 1 ? rand($reply_count * 2, $reply_count * 10) : $view_num; if ($info['tid']) { //更新 DB::query("UPDATE " . DB::table('forum_thread') . " SET typeid='{$typeid}', author='{$author}', authorid='{$uid}', subject='{$subject}', dateline='{$arr['public_time']}', lastpost='{$arr['public_time']}', fid='{$arr['fid']}', lastposter='{$author}', views='{$view_num}', attachment='0' WHERE tid='{$info['tid']}'", 'UNBUFFERED'); $tid = $info['tid']; } else { //添加 DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, views, displayorder, digest, special, attachment, moderated, status, isgroup, replycredit, closed)\r\n\t\t\tVALUES ('{$_G['fid']}', '0', '{$readperm}', '{$price}', '{$typeid}', '{$sortid}', '{$author}', '{$_G['uid']}', '{$subject}', '{$arr['public_time']}', '{$arr['public_time']}', '{$author}', '{$view_num}', '{$displayorder}', '{$digest}', '{$special}', '0', '{$moderated}', '32', '{$isgroup}', '{$replycredit}', '" . ($closed ? "1" : '0') . "')"); $tid = DB::insert_id(); useractionlog($uid, 'tid'); } DB::update('common_member_field_home', array('recentnote' => $subject), array('uid' => $uid)); if ($moderated) { updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG'); updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1); } if (DISCUZ_VERSION == 'X2') { //2.0版本 $tagstr = addthreadtag($arr['article_tag'], $tid); } else { $class_tag = new tag(); $tagstr = $class_tag->add_tag($arr['article_tag'], $tid, 'tid'); } if ($_G['group']['allowreplycredit']) { if ($replycredit > 0 && $replycredit_real > 0) { updatemembercount($_G['uid'], array('extcredits' . $_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid); DB::query("INSERT INTO " . DB::table('forum_replycredit') . " (tid, extcredits, extcreditstype, times, membertimes, random)VALUES('{$tid}', '{$_G['gp_replycredit_extcredits']}', '{$_G[setting][creditstransextra][10]}', '{$_G['gp_replycredit_times']}', '{$_G['gp_replycredit_membertimes']}', '{$_G['gp_replycredit_random']}')"); } } if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) { DB::query("INSERT INTO " . DB::table('forum_threadrush') . " (tid, stopfloor, starttimefrom, starttimeto, rewardfloor) VALUES ('{$tid}', '{$_G['gp_stopfloor']}', '{$_G['gp_rushreplyfrom']}', '{$_G['gp_rushreplyto']}', '{$_G['gp_rewardfloor']}')"); } $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message); $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '1', 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $isanonymous, 'usesig' => 1, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0); if (DISCUZ_VERSION != 'X2') { //2.5版本 2.5版本多了一个position字段 $post_setarr['position'] = 1; $post_setarr = dstripslashes($post_setarr); } else { $post_setarr = daddslashes($post_setarr); } $post_setarr['tags'] = $tagstr; $replys = 0; if ($info['tid']) { //更新 //发布时间要做更改 $new_post_arr = DB::fetch_first("SELECT dateline FROM " . DB::table('forum_post') . " WHERE tid='{$tid}' ORDER BY dateline ASC limit 1"); $post_setarr['dateline'] = $new_post_arr['dateline'] - 3600; DB::update('forum_post', $post_setarr, array('pid' => $info['pid'])); $pid = $info['pid']; } else { $pid = insertpost($post_setarr); $post_setarr = array(); //发布回复 if ($arr['is_public_reply'] == 1 && $arr['reply'] || $arr['is_content_reply'] == 1) { //是否开启发布回复 if ($arr['is_content_reply'] == 1) { $uid_arr = $time_arr = array(); } $reply_arr = $arr['reply']; $replys = count($reply_arr); if ($arr['public_reply_seq'] == 1) { shuffle($reply_arr); } foreach ((array) $reply_arr as $k => $v) { $message = dstripslashes($v['content']); $message = media_htmlbbcode($message, $arr['page_url']); $message = img_htmlbbcode($message, $arr['page_url']); $message = htmlspecialchars_decode(html2bbcode($message)); //print_r($v['content']);exit(); if (!$message || strlen($message) < 2) { continue; } $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '0', 'author' => $uid_arr[$k]['username'] ? $uid_arr[$k]['username'] : $arr['username'], 'authorid' => $uid_arr[$k]['uid'] ? $uid_arr[$k]['uid'] : $arr['uid'], 'subject' => '', 'dateline' => $time_arr[$k] ? $time_arr[$k] : $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $_G['group']['allowanonymous'] && !empty($_GET['isanonymous']) ? 1 : 0, 'usesig' => 1, 'htmlon' => $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0, 'bbcodeoff' => checkbbcodes($message, !empty($_GET['bbcodeoff'])), 'smileyoff' => checksmilies($message, !empty($_GET['smileyoff'])), 'parseurloff' => !empty($_GET['parseurloff']), 'attachment' => '0', 'tags' => 0, 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0); $lastpost = $post_setarr['dateline']; $lastposter = $post_setarr['author']; if (DISCUZ_VERSION != 'X2') { //2.5版本 2.5版本多了一个position字段 $post_setarr['position'] = $k + 2; $post_setarr = dstripslashes($post_setarr); } else { $post_setarr = daddslashes($post_setarr); } $reply_pid = insertpost($post_setarr); $v['tid'] = $tid; $v['pid'] = $reply_pid; $v['is_post'] = 1; //标识是回复 $v['cookie'] = $arr['cookie']; $v['is_water_img'] = $arr['is_water_img']; $v['is_download_img'] = $arr['is_download_img']; $v['is_download_file'] = $arr['is_download_file']; $forum_arr['tid'] = $tid; $forum_arr['pid'] = $reply_pid; $forum_arr['is_post'] = 1; //标识是回复 $forum_arr['cookie'] = $arr['cookie']; $forum_arr['is_water_img'] = $arr['is_water_img']; $forum_arr['is_download_img'] = $arr['is_download_img']; $forum_arr['content'] = $v['content']; //$re_arr = forum_downremotefile($forum_arr); if ($arr['is_download_img'] == 1) { $re_arr = forum_downremotefile($v); } DB::query("UPDATE " . DB::table('common_member_count') . " SET posts=posts+1 WHERE uid='{$post_setarr['authorid']}'"); //更新数 $new[$k] = $post_setarr; } unset($post_setarr); DB::update('forum_thread', array('replies' => count($reply_arr), 'lastpost' => $lastpost, 'lastposter' => $lastposter), array('tid' => $tid)); } } //exit(); $re = $arr; $re['fid'] = $fid; $re['tid'] = $tid; $re['fid'] = $fid; $re['uid'] = $arr['uid']; $re['username'] = $author; $re['pid'] = $pid; $re['message'] = $message; if ($pid && getstatus($thread['status'], 1)) { savepostposition($tid, $pid); } $threadimageaid = 0; $threadimage = array(); //print_r($message);exit(); if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) { foreach ($sortaids as $sortaid) { convertunusedattach($sortaid, $tid, $pid); } } if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) { updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']); if (!$threadimageaid) { $threadimage = DB::fetch_first("SELECT aid, attachment, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1"); $threadimageaid = $threadimage['aid']; } if ($_G['forum']['picstyle']) { setthreadcover($pid, 0, $threadimageaid); } } /*删除附件*/ if ($old_arr['forum_id']) { $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'"); while ($v = DB::fetch($query)) { $attach[] = $v; } dunlink($attach); DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE tid='{$old_arr['forum_id']}'"); DB::query("DELETE FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'"); DB::delete('forum_threadimage', "tid='{$old_arr['forum_id']}'"); //图片表 } $param = array('fid' => $arr['fid'], 'tid' => $tid, 'pid' => $pid); $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread'); include_once libfile('function/stat'); updatestat($isgroup ? 'groupthread' : $statarr[$special]); dsetcookie('clearUserdata', 'forum'); if ($specialextra) { $classname = 'threadplugin_' . $specialextra; if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'newthread_submit_end')) { $threadpluginclass->newthread_submit_end($_G['fid'], $tid); } } $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array()); if (!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) { $message = !$price ? $message : ''; if ($special == 0) { $feed['icon'] = 'thread'; $feed['title_template'] = 'feed_thread_title'; $feed['body_template'] = 'feed_thread_message'; $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150)); if (!empty($_G['forum_attachexist'])) { $firstaid = DB::result_first("SELECT aid FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1"); if ($firstaid) { $feed['images'] = array(getforumimg($firstaid)); $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}"); } } } } $feed['title_data']['hash_data'] = "tid{$tid}"; $feed['id'] = $tid; $feed['idtype'] = 'tid'; if ($feed['icon']) { postfeed($feed); } if ($displayorder != -4) { if ($digest) { updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']); } updatepostcredits('+', $_G['uid'], 'post', $_G['fid']); if ($isgroup) { DB::query("UPDATE " . DB::table('forum_groupuser') . " SET threads=threads+1, lastupdate='" . $arr['public_time'] . "' WHERE uid='{$_G['uid']}' AND fid='{$_G['fid']}'"); } $subject = str_replace("\t", ' ', $subject); $f_lastpost = "{$tid}\t{$subject}\t" . $arr['public_time'] . "\t{$author}"; if ($_G['forum']['type'] == 'sub') { DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}' WHERE fid='" . $_G['forum'][fup] . "'", 'UNBUFFERED'); } } $subject = str_replace("\t", ' ', $subject); $replys = $replys ? $replys : 1; //今日发帖 $todayposts = date("Yjn", $arr['public_time']) == date("Yjn", $v) ? 1 : 0; foreach ((array) $time_arr as $k => $v) { if (date("Yjn", $_G['timestamp']) == date("Yjn", $v)) { $todayposts++; } } DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}', threads=threads+1, posts=posts+{$replys}, todayposts=todayposts+{$todayposts} WHERE fid='{$arr['fid']}'", 'UNBUFFERED'); //更新今日发帖这些数据 if ($_G['forum']['status'] == 3) { require_once libfile('function/group'); updateactivity($_G['fid'], 0); require_once libfile('function/grouplog'); updategroupcreditlog($_G['fid'], $_G['uid']); } return $re; }