📄 topicadmin.php
字号:
} elseif(($member['adminid'] == 1 && $adminid > 1) || ($member['adminid'] == 2 && $adminid > 2)) {
showmessage('admin_getip_nopermission', NULL, 'HALTED');
}
$member['iplocation'] = convertip($member['useip']);
include $inajax ? ajaxtemplate('topicadmin_getip') : template('topicadmin_getip');
} elseif($action == 'split') {
if(!submitcheck('splitsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$replies = $thread['replies'];
if($replies <= 0) {
showmessage('admin_split_invalid');
}
$postlist = array();
$query = $db->query("SELECT * FROM {$tablepre}posts WHERE tid='$tid' ORDER BY dateline");
while($post = $db->fetch_array($query)) {
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml']);
$postlist[] = $post;
}
include template('topicadmin_split');
} else {
if(!trim($subject)) {
showmessage('admin_split_subject_invalid');
} elseif(!$pids = implodeids($split)) {
showmessage('admin_split_new_invalid');
}
$modaction = 'SPL';
$db->query("INSERT INTO {$tablepre}threads (fid, subject) VALUES ('$fid', '".dhtmlspecialchars($subject)."')");
$newtid = $db->insert_id();
$db->query("UPDATE {$tablepre}posts SET tid='$newtid' WHERE pid IN ($pids)");
$db->query("UPDATE {$tablepre}attachments SET tid='$newtid' WHERE pid IN ($pids)");
$splitauthors = array();
$query = $db->query("SELECT pid, tid, authorid, subject, dateline FROM {$tablepre}posts WHERE tid='$newtid' AND invisible='0' GROUP BY authorid ORDER BY dateline");
while($splitauthor = $db->fetch_array($query)) {
$splitauthor['subject'] = $subject;
$splitauthors[] = $splitauthor;
}
$db->query("UPDATE {$tablepre}posts SET first='1', subject='$subject' WHERE pid='".$splitauthors[0]['pid']."'", 'UNBUFFERED');
$query = $db->query("SELECT pid, author, authorid, dateline FROM {$tablepre}posts WHERE tid='$tid' ORDER BY dateline LIMIT 1");
$fpost = $db->fetch_array($query);
$db->query("UPDATE {$tablepre}threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]', moderated='1' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}posts SET subject='".addslashes($thread['subject'])."' WHERE pid='$fpost[pid]'");
$query = $db->query("SELECT author, authorid, dateline, rate FROM {$tablepre}posts WHERE tid='$newtid' ORDER BY dateline ASC LIMIT 1");
$fpost = $db->fetch_array($query);
$db->query("UPDATE {$tablepre}threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]', rate='".intval(@($fpost['rate'] / abs($fpost['rate'])))."', moderated='1' WHERE tid='$newtid'");
updatethreadcount($tid);
updatethreadcount($newtid);
updateforumcount($fid);
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => $splitauthors, 'var' => 'thread', 'item' => 'reason_moderate') : array()),
'modtids' => $thread['tid'].','.$newtid,
'modlog' => array($thread, array('tid' => $newtid, 'subject' => $subject))
);
}
} elseif($action == 'merge') {
if(!submitcheck('mergesubmit')) {
include template('topicadmin_merge');
} else {
$modaction = 'MRG';
$query = $db->query("SELECT tid, fid, authorid, subject, views, replies, dateline, special FROM {$tablepre}threads WHERE tid='$othertid' AND displayorder>='0'");
if(!$other = $db->fetch_array($query)) {
showmessage('admin_merge_nonexistence');
} elseif($other['special']) {
showmessage('special_noaction');
}
if($othertid == $tid || ($adminid == 3 && $other['fid'] != $forum['fid'])) {
showmessage('admin_merge_invalid');
}
$other['views'] = intval($other['views']);
$other['replies']++;
$db->query("UPDATE {$tablepre}posts SET tid='$tid' WHERE tid='$othertid'");
$postsmerged = $db->affected_rows();
$db->query("UPDATE {$tablepre}attachments SET tid='$tid' WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}mythreads WHERE tid='$othertid'");
$db->query("DELETE FROM {$tablepre}myposts WHERE tid='$othertid'");
$query = $db->query("SELECT pid, fid, authorid, author, subject, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline LIMIT 1");
$firstpost = $db->fetch_array($query);
$db->query("UPDATE {$tablepre}posts SET first=(pid='$firstpost[pid]'), fid='$firstpost[fid]' WHERE tid='$tid'");
$db->query("UPDATE {$tablepre}threads SET authorid='$firstpost[authorid]', author='".addslashes($firstpost['author'])."', subject='".addslashes($firstpost['subject'])."', dateline='$firstpost[dateline]', views=views+$other[views], replies=replies+$other[replies], moderated='1' WHERE tid='$tid'");
if($fid == $other['fid']) {
$db->query("UPDATE {$tablepre}forums SET threads=threads-1 WHERE fid='$fid'");
} else {
$db->query("UPDATE {$tablepre}forums SET threads=threads-1, posts=posts-$postsmerged WHERE fid='$other[fid]'");
$db->query("UPDATE {$tablepre}forums SET posts=$posts+$postsmerged WHERE fid='$fid'");
}
$forum['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_merge') : array()),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
} elseif($action == 'copy' && $thread) {
if(!submitcheck('copysubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = forumselect();
include template('topicadmin_copy');
} else {
$query = $db->query("SELECT fid, name, modnewposts FROM {$tablepre}forums WHERE fid='$copyto' AND status>0 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');
}
}
$thread['tid'] = '';
$thread['fid'] = $copyto;
$thread['dateline'] = $thread['lastpost'] = $timestamp;
$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='$tid' AND first=1 LIMIT 1");
if($post = $db->fetch_array($query)) {
$post['pid'] = '';
$post['tid'] = $threadid;
$post['fid'] = $copyto;
$post['dateline'] = $timestamp;
$post['attachment'] = 0;
$post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
$db->query("INSERT INTO {$tablepre}posts VALUES ('".implode("', '", daddslashes($post, 1))."')");
}
$modaction = 'CPY';
updatepostcredits('+', $post['authorid'], '');
updateforumcount($copyto);
updateforumcount($fid);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forumdisplay.php?fid=$fid",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array()),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
} elseif($action == 'removereward') {
$modaction = 'RMR';
if(!is_array($thread) || $thread['special'] != '3' || $thread['price'] >= 0) {
showmessage('reward_end');
}
$query = $db->query("SELECT answererid FROM {$tablepre}rewardlog WHERE tid='$thread[tid]'");
$answererid = $db->result($query, 0);
$thread[price] = abs($thread[price]);
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+$thread[price] WHERE uid='$thread[authorid]'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans-$thread[price] WHERE uid='$answererid'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET special='0', price='0' WHERE tid='$thread[tid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$thread[tid]'", 'UNBUFFERED');
showmessage('admin_succeed', "viewthread.php?tid=$tid");
} 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']}) {
sendreasonpm($resultarray['reasonpm']['var'], $resultarray['reasonpm']['item']);
}
}
showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -