📄 topicadmin.php
字号:
foreach($threads as $thread) {
if($thread['digest'] != $level) {
$digestpostsadd = ($thread['digest'] > 0 && $level == 0) || ($thread['digest'] == 0 && $level > 0) ? 'digestposts=digestposts'.($level == 0 ? '-' : '+').'1' : '';
updatecredits($thread['authorid'], $digestcredits, $level - $thread['digest'], $digestpostsadd);
}
}
$modaction = $level ? ($expiration ? 'EDI' : 'DIG') : 'UDG';
$db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('DIG', 'UDI', 'EDI', 'UED')", 'UNBUTTERED');
}
} elseif($operation == 'close') {
$modaction = empty($close) ? ($expiration ? 'EOP' : 'OPN'): ($expiration ? 'ECL' : 'CLS');
$close = ($modaction == 'ECL' || $modaction == 'CLS') ? 1 : 0;
$db->query("UPDATE {$tablepre}threads SET closed='$close', moderated='1' WHERE tid IN ($moderatetids)");
$db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('CLS','OPN', 'ECL', 'UCL', 'EOP', 'UEO')", 'UNBUTTERED');
} elseif($operation == 'move') {
if($fid == $moveto) {
showmessage('admin_move_illegal');
}
if($adminid == 3) {
if($accessmasks) {
$accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowpostattach';
$accessadd2 = "LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid='$moveto'";
}
$query = $db->query("SELECT ff.postperm, m.uid AS istargetmod $accessadd1
FROM {$tablepre}forumfields ff
$accessadd2
LEFT JOIN {$tablepre}moderators m ON m.fid='$moveto' AND m.uid='$discuz_uid'
WHERE ff.fid='$moveto'");
$priv = $db->fetch_array($query);
if((($priv['postperm'] && !in_array($groupid, explode("\t", $priv['postperm']))) || ($accessmasks && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost'])) && !$priv['istargetmod']) {
showmessage('admin_copy_nopermission');
}
}
$query = $db->query("SELECT fid, name, modnewposts, allowpostspecial FROM {$tablepre}forums WHERE fid='$moveto' AND status='1' AND type<>'group'");
if(!$toforum = $db->fetch_array($query)) {
showmessage('admin_move_invalid');
} else {
$modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && $toforum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && $toforum['modnewposts'] ? 1 : 0;
if($modnewthreads || $modnewreplies) {
showmessage('admin_copy_hava_mod');
}
}
$query = $db->query("SELECT tid, special FROM {$tablepre}threads WHERE tid IN ($moderatetids)");
while($shave = $db->fetch_array($query)) {
if($shave['special'] && !substr(sprintf('%04b', $toforum['allowpostspecial']), -$shave['special'], 1)) {
foreach($moderate as $key => $value) {
if($shave['tid'] == $value) {
unset($moderate[$key]);
}
}
}
}
$moderatetids = implode(',', $moderate);
$stickmodify = 0;
foreach($threads as $thread) {
if(in_array($thread['displayorder'], array(2, 3))) {
$stickmodify = 1;
}
}
$displayorderadd = $adminid == 3 ? ', displayorder=\'0\'' : '';
if(empty($moderatetids)) {
showmessage('admin_moderate_invalid');
}
$db->query("UPDATE {$tablepre}threads SET fid='$moveto', moderated='1' $displayorderadd WHERE tid IN ($moderatetids)");
$db->query("UPDATE {$tablepre}posts SET fid='$moveto' WHERE tid IN ($moderatetids)");
if($type == 'redirect') {
foreach($threads as $thread) {
$db->query("INSERT INTO {$tablepre}threads (fid, readperm, iconid, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, digest, closed, special, attachment)
VALUES ('$thread[fid]', '$thread[readperm]', '$thread[iconid]', '".addslashes($thread['author'])."', '$thread[authorid]', '".addslashes($thread['subject'])."', '$thread[dateline]', '$thread[lastpost]', '$thread[lastposter]', '0', '0', '0', '0', '$thread[tid]', '0', '0')");
}
}
if($globalstick && $stickmodify) {
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('globalstick');
}
$modaction = 'MOV';
updateforumcount($moveto);
updateforumcount($fid);
} elseif($operation == 'copy') {
$query = $db->query("SELECT fid, name, modnewposts FROM {$tablepre}forums WHERE fid='$copyto' AND status='1' AND type<>'group'");
if(!$toforum = $db->fetch_array($query)) {
showmessage('admin_copy_invalid');
} else {
$modnewthreads = (!$allowdirectpost || $allowdirectpost == 1) && $toforum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$allowdirectpost || $allowdirectpost == 2) && $toforum['modnewposts'] ? 1 : 0;
if($modnewthreads || $modnewreplies) {
showmessage('admin_copy_hava_mod');
}
}
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ($moderatetids) LIMIT 1");
if($thread = $db->fetch_array($query)) {
$dateline = $timestamp;
$thread['tid'] = '';
$thread['fid'] = $copyto;
$thread['dateline'] = $thread['lastpost'] = $dateline;
$thread['lastposter'] = $thread['author'];
$thread['views'] = $thread['replies'] = 0;
$thread['digest'] = $thread['blog'] = $thread['rate'] = 0;
$thread['displayorder'] = 0;
$thread['attachment'] = 0;
$db->query("INSERT INTO {$tablepre}threads VALUES ('".implode("', '", daddslashes($thread, 1))."')");
$threadid = $db->insert_id();
$query = $db->query("SELECT * FROM {$tablepre}posts WHERE tid IN ($moderatetids) AND first=1 LIMIT 1");
if($post = $db->fetch_array($query)) {
$post['pid'] = '';
$post['tid'] = $threadid;
$post['fid'] = $copyto;
$post['dateline'] = $dateline;
$post['attachment'] = 0;
$post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
$db->query("INSERT INTO {$tablepre}posts VALUES ('".implode("', '", daddslashes($post, 1))."')");
}
}
$modaction = 'CPY';
updatepostcredits('+', $topic['authorid'], '');
updateforumcount($copyto);
updateforumcount($fid);
} elseif($operation == 'highlight') {
$stylebin = '';
for($i = 1; $i <= 3; $i++) {
$stylebin .= empty($highlight_style[$i]) ? '0' : '1';
}
$highlight_style = bindec($stylebin);
if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
showmessage('undefined_action', NULL, 'HALTED');
}
$db->query("UPDATE {$tablepre}threads SET highlight='$highlight_style$highlight_color', moderated='1' WHERE tid IN ($moderatetids)", 'UNBUFFERED');
$modaction = ($highlight_style + $highlight_color) ? ($expiration ? 'EHL' : 'HLT') : 'UHL';
$expiration = $modaction == 'UHL' ? 0 : $expiration;
$db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('HLT', 'UHL', 'EHL', 'UEH')", 'UNBUTTERED');
} elseif($operation == 'type') {
if(!isset($forum['threadtypes']['types'][$typeid]) && !($typeid == 0 && !$forum['threadtypes']['required'])) {
showmessage('admin_move_invalid');
}
$db->query("UPDATE {$tablepre}threads SET typeid='$typeid', moderated='1' WHERE tid IN ($moderatetids)");
$modaction = 'TYP';
} elseif($operation == 'supe_push') {
if(!$supe_status) {
showmessage('supe_pushsetting_noopen');
}
if(!$supe_allowpushthread) {
showmessage('admin_nopermission');
}
if($forum['supe_pushsetting']['status'] != '2') {
showmessage('supe_pushsetting_nohand');
}
$supe_pushstatus = in_array($supe_pushstatus, array('2', '-2')) ? $supe_pushstatus : '2';
$db->query("UPDATE {$tablepre}threads SET supe_pushstatus='$supe_pushstatus' WHERE tid IN ($moderatetids)");
$modaction = $supe_pushstatus == '2' ? 'PTS' : ($supe_pushstatus == '-2' ? 'RFS' : '');
} elseif($operation == 'removereward') {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+{$threads[0][price]} WHERE uid='{$threads[0][authorid]}'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($moderatetids)", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET special=0, price='0' WHERE tid IN ($moderatetids)", 'UNBUFFERED');
$modaction = 'RMR';
}
}
threadmodified($moderatetids, $modaction);
$resultarray = array(
'redirect' => (preg_match("/^topicadmin/", ($redirect = dreferer("forumdisplay.php?fid=$fid"))) ? "forumdisplay.php?fid=$fid" : $redirect),
'reasonpm' => ($sendreasonpm ? array('data' => $threads, 'var' => 'thread', 'item' => ($operation == 'move' ? 'reason_move' : 'reason_moderate')) : array()),
'modtids' => ($operation == 'delete' && !$forum['recyclebin']) ? 0 : $moderatetids,
'modlog' => $threads,
'expiration'=> $expiration
);
if(in_array($operation, array('stick', 'digest', 'highlight')) && !empty($next) && $next != $operation && in_array($next, array('stick', 'digest', 'highlight'))) {
if(count($moderate) == 1) {
$resultarray['redirect'] = "topicadmin.php?tid=$moderate[0]&fid=$fid&action=$next";
} else {
$resultarray['redirect'] = "topicadmin.php?action=moderate&fid=$fid&operation=$next";
if(is_array($moderate)) {
foreach($moderate as $modtid) {
$resultarray['redirect'] .= "&moderate[]=$modtid";
}
}
}
$resultarray['message'] = 'admin_succeed_next';
}
}
} elseif($action == 'delpost') {
if(!$allowdelpost || !$tid) {
showmessage('admin_nopermission', NULL, 'HALTED');
} elseif(!is_array($delete) && !count($delete)) {
showmessage('admin_delpost_invalid');
} else {
$deletepids = '\''.implode('\',\'', $delete).'\'';
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE pid IN ($deletepids) AND first='1'");
if($db->num_rows($query)) {
header("Location: {$boardurl}topicadmin.php?action=delete&tid=$thread[tid]");
dexit();
}
}
if(!submitcheck('delpostsubmit')) {
$deleteid = '';
foreach($delete as $id) {
$deleteid .= '<input type="hidden" name="delete[]" value="'.$id.'">';
}
include template('topicadmin_delpost');
} else {
checkreasonpm();
$pids = 0;
$posts = $uidarray = $puidarray = array();
$losslessdel = $losslessdel > 0 ? $timestamp - $losslessdel * 86400 : 0;
$query = $db->query("SELECT pid, authorid, dateline, message FROM {$tablepre}posts WHERE pid IN ($deletepids) AND tid='$tid'");
while($post = $db->fetch_array($query)) {
$posts[] = $post;
$pids .= ','.$post['pid'];
$comma = ',';
if($post['dateline'] < $losslessdel) {
$uidarray[] = $post['authorid'];
} else {
$puidarray[] = $post['authorid'];
}
$modpostsnum ++;
}
if($uidarray) {
updatepostcredits('-', $uidarray, array());
}
if($puidarray) {
updatepostcredits('-', $puidarray, $replycredits);
}
$query = $db->query("SELECT attachment FROM {$tablepre}attachments WHERE pid IN ($pids)");
while($attach = $db->fetch_array($query)) {
if($puidarray) {
updatepostcredits('-', $puidarray, $postattachcredits);
}
@unlink($attachdir.'/'.$attach['attachment']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pids)");
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pids)");
updatethreadcount($tid, 1);
updateforumcount($fid);
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modaction = 'DLP';
$resultarray = array(
'redirect' => "viewthread.php?tid=$tid&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post') : array()),
'modtids' => 0,
'modlog' => $thread
);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -