if ($_G['forum_auditstatuson']) { if ($audit == 1) { updatemoderate($isfirstpost ? 'tid' : 'pid', $isfirstpost ? $_G['tid'] : $pid, '2'); showmessage('auditstatuson_succeed', $redirecturl, $param); } else { updatemoderate($isfirstpost ? 'tid' : 'pid', $isfirstpost ? $_G['tid'] : $pid); showmessage('audit_edit_succeed', '', $param); } } else { if (!empty($_G['gp_delete']) && $isfirstpost) { my_thread_log('delete', array('tid' => $_G['tid'])); showmessage('post_edit_delete_succeed', "forum.php?mod=forumdisplay&fid={$_G['fid']}", $param); } elseif (!empty($_G['gp_delete'])) { my_post_log('delete', array('pid' => $pid)); showmessage('post_edit_delete_succeed', "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_G['gp_page']}&extra={$extra}" . ($vid && $isfirstpost ? "&vid={$vid}" : ''), $param); } else { if ($isfirstpost && $modnewthreads) { updatemoderate('tid', $_G['tid']); showmessage('edit_newthread_mod_succeed', $redirecturl, $param); } elseif (!$isfirstpost && $modnewreplies) { updatemoderate('pid', $pid); showmessage('edit_reply_mod_succeed', "forum.php?mod=forumdisplay&fid={$_G['fid']}", $param); } else { if ($pinvisible != -3) { my_post_log('update', array('pid' => $pid)); } showmessage('post_edit_succeed', $redirecturl, $param); } } } }
if (in_array($i, $nos)) { $pids[] = $post['pid']; } $i++; } if (!($pids = implode(',', $pids))) { showmessage('admin_split_new_invalid'); } $modaction = 'SPL'; $reason = checkreasonpm(); $subject = dhtmlspecialchars($_G['gp_subject']); DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, subject) VALUES ('{$_G['fid']}', '{$posttableid}', '{$subject}')"); $newtid = DB::insert_id(); my_thread_log('split', array('tid' => $_G['tid'])); foreach ((array) explode(',', $pids) as $pid) { my_post_log('split', array('pid' => $pid)); } DB::query("UPDATE " . DB::table($posttable) . " SET tid='{$newtid}' WHERE pid IN ({$pids})"); DB::query("UPDATE " . DB::table('forum_attachment') . " SET tid='{$newtid}' WHERE pid IN ({$pids})"); $splitauthors = array(); $query = DB::query("SELECT pid, tid, authorid, subject, dateline FROM " . DB::table($posttable) . " WHERE tid='{$newtid}' AND invisible='0' GROUP BY authorid ORDER BY dateline"); while ($splitauthor = DB::fetch($query)) { $splitauthor['subject'] = $subject; $splitauthors[] = $splitauthor; } DB::query("UPDATE " . DB::table($posttable) . " SET first='1', subject='{$subject}' WHERE pid='" . $splitauthors[0]['pid'] . "'", 'UNBUFFERED'); $fpost = DB::fetch_first("SELECT pid, author, authorid, dateline FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' ORDER BY dateline LIMIT 1"); DB::query("UPDATE " . DB::table('forum_thread') . " SET author='" . addslashes($fpost['author']) . "', authorid='{$fpost['authorid']}', dateline='{$fpost['dateline']}', moderated='1' WHERE tid='{$_G['tid']}'"); DB::query("UPDATE " . DB::table($posttable) . " SET subject='" . addslashes($thread['subject']) . "' WHERE pid='{$fpost['pid']}'"); $fpost = DB::fetch_first("SELECT author, authorid, dateline, rate FROM " . DB::table($posttable) . " WHERE tid='{$newtid}' ORDER BY dateline ASC LIMIT 1"); DB::query("UPDATE " . DB::table('forum_thread') . " SET author='" . addslashes($fpost['author']) . "', authorid='{$fpost['authorid']}', dateline='{$fpost['dateline']}', rate='" . intval(@($fpost['rate'] / abs($fpost['rate']))) . "', moderated='1' WHERE tid='{$newtid}'");
return; } $tidsdelete = $pidsdelete = '0'; $prune = array('forums' => array(), 'thread' => array()); if ($pids = dimplode($_G['gp_delete'])) { $tidsdelete = $pidsdelete = '0'; $postarray = getfieldsofposts('fid, tid, pid, first, authorid', "pid IN ({$pids}) {$fidadd}"); foreach ($postarray as $post) { $prune['forums'][] = $post['fid']; @$prune['thread'][$post['tid']]++; $pidsdelete .= ",{$post['pid']}"; $tidsdelete .= $post['first'] ? ",{$post['tid']}" : ''; if ($post['first']) { my_thread_log('delete', array('tid' => $post['tid'])); } else { my_post_log('delete', array('pid' => $post['pid'])); } } } if ($pidsdelete) { require_once libfile('function/post'); if (!getgpc('nocredit')) { $postsarray = $tuidarray = $ruidarray = array(); $postarray1 = getfieldsofposts('pid, first, authorid', "pid IN ({$pidsdelete})"); $postarray2 = getfieldsofposts('pid, first, authorid', "tid IN ({$tidsdelete})"); while ((list($tmpkey, $post) = each($postarray1)) || (list($tmpkey, $post) = each($postarray2))) { $postsarray[$post['pid']] = $post; } foreach ($postsarray as $post) { if ($post['first']) { $tuidarray[] = $post['authorid'];
updatemembercount($author['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{$author['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}"); } } } if (!empty($logs)) { writelog('ratelog', $logs); unset($logs); } DB::delete('common_credit_log', "operation='PRC' AND relatedid IN({$pids})"); DB::query("DELETE FROM " . DB::table('forum_ratelog') . " WHERE pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table('forum_postcomment') . " WHERE pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table($posttable) . " WHERE pid IN ({$pids})"); getstatus($thread['status'], 1) && DB::query("DELETE FROM " . DB::table('forum_postposition') . " WHERE pid IN ({$pids})"); $thread['stickreply'] && DB::query("DELETE FROM " . DB::table('forum_poststick') . " WHERE tid='{$thread['tid']}' AND pid IN ({$pids})"); foreach (explode(',', $pids) as $pid) { my_post_log('delete', array('pid' => $pid)); } if ($thread['special']) { DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE pid IN ({$pids})"); } 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={$page}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason)), 'modtids' => 0, 'modlog' => $thread); procreportlog('', $pids, TRUE); }
DB::query("INSERT INTO " . DB::table('forum_warning') . " (pid, operatorid, operator, authorid, author, dateline, reason) VALUES ('{$post['pid']}', '{$_G['uid']}', '{$_G['username']}', '{$post['authorid']}', '" . addslashes($post['author']) . "', '{$_G['timestamp']}', '{$reason}')", 'UNBUFFERED'); $authorwarnings = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_warning') . " WHERE authorid='{$post['authorid']}' AND dateline>={$_G['timestamp']}-" . $_G[setting][warningexpiration] * 86400); if ($authorwarnings >= $_G['setting']['warninglimit']) { $member = DB::fetch_first("SELECT adminid, groupid, extgroupids FROM " . DB::table('common_member') . " WHERE uid='{$post['authorid']}'"); $groupterms = unserialize(DB::result_first("SELECT groupterms FROM " . DB::table('common_member_field_forum') . " WHERE uid='{$post['authorid']}'")); if ($member && $member['groupid'] != 4) { $extgroupidsarray = array(); foreach (array_unique(array_merge($member['extgroupids'], array(4))) as $extgroupid) { if ($extgroupid) { $extgroupidsarray[] = $extgroupid; } } $extgroupidsnew = implode("\t", $extgroupidsarray); $banexpiry = TIMESTAMP + $_G['setting']['warningexpiration'] * 86400; $groupterms['ext'][4] = $banexpiry; DB::query("UPDATE " . DB::table('common_member') . " SET groupid='4', groupexpiry='" . groupexpiry($groupterms) . "' WHERE uid='{$post['authorid']}'"); DB::query("UPDATE " . DB::table('common_member_field_forum') . " SET groupterms='" . addslashes(serialize($groupterms)) . "' WHERE uid='{$post['authorid']}'"); } } $pids .= $comma . $post['pid']; $comma = ','; } elseif (!$warned && $post['status'] & 2) { my_post_log('unwarn', array('pid' => $post['pid'], 'uid' => $post['authorid'])); DB::query("UPDATE " . DB::table($posttable) . " SET status=status^2 WHERE pid='{$post['pid']}' AND status=status|2", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_warning') . " WHERE pid='{$post['pid']}'", 'UNBUFFERED'); $pids .= $comma . $post['pid']; $comma = ','; } } $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$page}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_warn_post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => stripslashes($reason), 'warningexpiration' => $_G['setting']['warningexpiration'], 'warninglimit' => $_G['setting']['warninglimit'], 'warningexpiration' => $_G['setting']['warningexpiration'], 'authorwarnings' => $authorwarnings), 'modtids' => 0, 'modlog' => $thread); }
function recyclebinpostundelete($undeletepids, $posttableid = false) { global $_G; $postsundel = 0; if (empty($undeletepids)) { return $postsundel; } foreach ($undeletepids as $pid) { my_post_log('restore', array('pid' => $pid)); } $undeletepids = dimplode($undeletepids); loadcache('posttableids'); $posttableids = !empty($_G['cache']['posttableids']) ? $posttableid !== false && in_array($posttableid, $_G['cache']['posttableids']) ? array($posttableid) : $_G['cache']['posttableids'] : array('0'); $postarray = $ruidarray = $fidarray = $tidarray = array(); foreach ($posttableids as $ptid) { $query = DB::query('SELECT fid, tid, first, authorid FROM ' . DB::table(getposttable($ptid)) . " WHERE pid IN ({$undeletepids})"); while ($post = DB::fetch($query)) { $postarray[] = $post; } } if (empty($postarray)) { return $postsundel; } foreach ($postarray as $key => $post) { if (!$post['first']) { $ruidarray[] = $post['authorid']; } $fidarray[$post['fid']] = $post['fid']; $tidarray[$post['tid']] = $post['tid']; } $postsundel = updatepost(array('invisible' => '0'), "pid IN ({$undeletepids})", true, $posttableid); include_once libfile('function/post'); if ($ruidarray) { updatepostcredits('+', $ruidarray, $creditspolicy['reply']); } foreach ($tidarray as $tid) { updatethreadcount($tid, 1); } foreach ($fidarray as $fid) { updateforumcount($fid); } return $postsundel; }
function deletethread($tids, $membercount = false, $credit = false, $ponly = false) { global $_G; if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { $_G['deletethreadtids'] =& $tids; $hookparam = func_get_args(); hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread'); } if (!$tids) { return 0; } require_once libfile('function/forum'); foreach ($tids as $tid) { my_post_log('delete', array('tid' => $tid)); } $count = count($tids); $tids = dimplode($tids); loadcache(array('threadtableids', 'posttableids')); $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array(); $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0'); if (!in_array(0, $threadtableids)) { $threadtableids = array_merge(array(0), $threadtableids); } DB::delete('common_moderate', "id IN ({$tids}) AND idtype='tid'"); $atids = $fids = $postids = $threadtables = array(); foreach ($threadtableids as $tableid) { $threadtable = !$tableid ? "forum_thread" : "forum_thread_{$tableid}"; $query = DB::query("SELECT cover, tid, fid, posttableid FROM " . DB::table($threadtable) . " WHERE tid IN ({$tids})"); while ($row = DB::fetch($query)) { $atids[] = $row['tid']; $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0'; $postids[$row['posttableid']][$row['tid']] = $row['tid']; if ($tableid) { $fids[$row['fid']][] = $tableid; } } if (!$tableid && !$ponly) { $threadtables[] = $threadtable; } } if ($credit || $membercount) { $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0; $postlist = $uidarray = $tuidarray = $ruidarray = array(); foreach ($postids as $posttableid => $posttabletids) { $query = DB::query('SELECT tid, first, authorid, dateline, replycredit, invisible FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($posttabletids) . ')'); while ($post = DB::fetch($query)) { if ($post['invisible'] != -1 && $post['invisible'] != -5) { $postlist[] = $post; } } } $query = DB::query("SELECT tid, extcreditstype FROM " . DB::table('forum_replycredit') . " WHERE tid IN ({$tids})"); while ($rule = DB::fetch($query)) { $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10]; $replycredit_rule[$rule['tid']] = $rule; } foreach ($postlist as $post) { if ($post['dateline'] < $losslessdel) { if ($membercount) { if ($post['first']) { updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false); } else { updatemembercount($post['authorid'], array('posts' => -1), false); } } } else { if ($credit) { if ($post['first']) { $tuidarray[] = $post['authorid']; } else { $ruidarray[] = $post['authorid']; } } } if ($credit || $membercount) { if ($post['authorid'] > 0 && $post['replycredit'] > 0) { if ($replycredit_rule[$post['tid']]['extcreditstype']) { updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit']))); } } } } if ($credit) { if ($tuidarray || $ruidarray) { require_once libfile('function/post'); } if ($tuidarray) { updatepostcredits('-', $tuidarray, 'post', $_G['forum']['fid']); } if ($ruidarray) { updatepostcredits('-', $ruidarray, 'reply', $_G['forum']['fid']); } $auidarray = $attachtables = array(); foreach ($atids as $tid) { $attachtables[getattachtablebytid($tid)][] = $tid; } foreach ($attachtables as $attachtable => $attachtids) { $query = DB::query("SELECT uid, dateline FROM " . DB::table($attachtable) . " WHERE tid IN (" . dimplode($attachtids) . ")"); while ($attach = DB::fetch($query)) { if ($attach['dateline'] > $losslessdel) { $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1; } } } if ($auidarray) { $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach']; updateattachcredits('-', $auidarray, $postattachcredits); } } } if ($ponly) { if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread'); } return $count; } DB::delete('forum_replycredit', "tid IN ({$tids})"); DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN ({$tids})"); deletethreadcover($tids); foreach ($threadtables as $threadtable) { DB::delete($threadtable, "tid IN ({$tids})"); } if ($atids) { foreach ($postids as $posttableid => $oneposttids) { deletepost($oneposttids, 'tid', false, $posttableid); } deleteattach($atids, 'tid'); } if ($fids) { foreach ($fids as $fid => $tableids) { $tableids = array_unique($tableids); foreach ($tableids as $tableid) { $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$fid}'"); while ($row = DB::fetch($query)) { DB::insert('forum_forum_threadtable', array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true); } } } } foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_poststick', 'forum_pollvoter', 'forum_threadimage') as $table) { DB::delete($table, "tid IN ({$tids})"); } DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$tids}) AND idtype='tid'", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('common_tagitem') . " WHERE idtype='tid' AND itemid IN ({$tids})", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_threadrush') . " WHERE tid IN ({$tids})", 'UNBUFFERED'); if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread'); } return $count; }
require_once libfile('function/delete'); deletepost($pids, 'pid', false, $posttableid); } updatemodworks('DLP', count($moderation['delete'])); updatemoderate('pid', $moderation['delete'], 2); } $repliesmod = 0; if ($validatepids = dimplode($moderation['validate'])) { $threads = $lastpost = $attachments = $pidarray = array(); $query = DB::query('SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous FROM ' . DB::table($posttable) . " p\r\n\t\t\t\t\tLEFT JOIN " . DB::table('forum_thread') . " t\r\n\t\t\t\t\tON t.tid=p.tid\r\n\t\t\t\t\tWHERE p.pid IN ({$validatepids}) AND p.invisible='{$pstat}' AND p.first='0' AND " . ($modfidsadd ? "p.{$modfidsadd}" : '1')); while ($post = DB::fetch($query)) { $repliesmod++; $pidarray[] = $post['pid']; updatepostcredits('+', $post['authorid'], 'reply', $post['fid']); my_post_log('validate', array('pid' => $post['pid'])); $threads[$post['tid']]['posts']++; $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : ''; $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : ''; $pm = 'pm_' . $post['pid']; if ($_G['gp_reason'] != '' && $post['authorid'] && $post['authorid'] != $_G['uid']) { $pmlist[] = array('act' => 'modreplies_validate', 'notevar' => array('reason' => dhtmlspecialchars($_G['gp_reason']), 'pid' => $post['pid'], 'tid' => $post['tid'], 'post' => messagecutstr($post['message'], 30)), 'authorid' => $post['authorid']); } } foreach ($threads as $tid => $thread) { DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+{$thread['posts']} {$thread['lastpostadd']} {$thread['attachadd']} WHERE tid='{$tid}'", 'UNBUFFERED'); } if ($_G['fid']) { updateforumcount($_G['fid']); } else { $fids = array_keys($modforums['list']);
} elseif ($_G['gp_action'] == 'pubsave') { $thread = DB::fetch_first("SELECT tid,fid,replies FROM " . DB::table('forum_thread') . " WHERE tid='{$_G['tid']}' AND displayorder='-4' AND authorid='{$_G['uid']}'"); if (!$thread) { showmessage('thread_nonexistence'); } $posttable = getposttablebytid($_G['tid']); DB::query("UPDATE " . DB::table($posttable) . " SET dateline='{$_G['timestamp']}', invisible='0' WHERE tid='{$_G['tid']}'"); DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='0', dateline='{$_G['timestamp']}', lastpost='{$_G['timestamp']}' WHERE tid='{$_G['tid']}'"); $posts = $thread['replies'] + 1; if ($thread['replies']) { $dateline = $_G['timestamp']; $query = DB::query("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND first='0'"); while ($post = DB::fetch($query)) { $dateline++; DB::query("UPDATE " . DB::table($posttable) . " SET dateline='{$dateline}' WHERE pid='{$post['pid']}'"); my_post_log('update', array('pid' => $post['pid'])); } } my_thread_log('update', array('tid' => $thread['tid'])); DB::query("UPDATE " . DB::table('forum_forum') . " SET threads=threads+1, posts=posts+'" . $posts . "', todayposts=todayposts+'" . $posts . "' WHERE fid='{$thread['fid']}'", 'UNBUFFERED'); dheader('location: ' . dreferer()); } elseif ($_G['gp_action'] == 'loadsave') { $message = ' '; $savepost = DB::fetch_first("SELECT message FROM " . DB::table('forum_post') . " WHERE pid='{$_G['gp_pid']}'"); if ($savepost) { $message = $savepost['message']; if ($_G['gp_type']) { require_once libfile('function/discuzcode'); $message = discuzcode($message, $savepost['smileyoff'], $savepost['bbcodeoff'], $savepost['htmlon']); } $message = $message ? $message : ' ';