⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 topicadmin.php

📁 Discuz功能源码(开源)
💻 PHP
📖 第 1 页 / 共 2 页
字号:

		$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('modsubmit')) {

		include template('topicadmin_action');

	} else {

		$modaction = 'MRG';

		checkreasonpm();

		$other = $db->fetch_first("SELECT tid, fid, authorid, subject, views, replies, dateline, special FROM {$tablepre}threads WHERE tid='$othertid' AND displayorder>='0'");
		if(!$other) {
			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']++;

		$firstpost = $db->fetch_first("SELECT pid, fid, authorid, author, subject, dateline FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' ORDER BY dateline LIMIT 1");

		$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'");

		$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('modsubmit')) {
		require_once DISCUZ_ROOT.'./include/forum.func.php';
		$forumselect = forumselect();
		include template('topicadmin_action');

	} else {

		$modaction = 'CPY';
		checkreasonpm();

		$toforum = $db->fetch_first("SELECT fid, name, modnewposts FROM {$tablepre}forums WHERE fid='$copyto' AND status>0 AND type<>'group'");
		if(!$toforum) {
			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'] = $thread['highlight'] = $thread['digest'] = 0;
		$thread['rate'] = $thread['displayorder'] = $thread['attachment'] = 0;

		$db->query("INSERT INTO {$tablepre}threads VALUES ('".implode("', '", daddslashes($thread, 1))."')");
		$threadid = $db->insert_id();

		if($post = $db->fetch_first("SELECT * FROM {$tablepre}posts WHERE tid='$tid' AND first=1 LIMIT 1")) {
			$post['pid'] = '';
			$post['tid'] = $threadid;
			$post['fid'] = $copyto;
			$post['dateline'] = $timestamp;
			$post['attachment'] = 0;
			$post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
			$db->query("INSERT INTO {$tablepre}posts VALUES  ('".implode("', '", daddslashes($post, 1))."')");
		}

		updatepostcredits('+', $post['authorid'], '');

		updateforumcount($copyto);
		updateforumcount($fid);

		$modpostsnum ++;
		$resultarray = array(
		'redirect'	=> "forumdisplay.php?fid=$fid",
		'reasonpm'	=> ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy') : array()),
		'modtids'	=> $thread['tid'],
		'modlog'	=> array($thread, $other)
		);
	}

} elseif($action == 'removereward') {

	$modaction = 'RMR';

	if(!is_array($thread) || $thread['special'] != '3') {
		showmessage('reward_end');
	}

	$answererid = $db->result_first("SELECT answererid FROM {$tablepre}rewardlog WHERE tid='$thread[tid]'");
	$rewardprice = abs($thread['price']);

	if($thread['price'] < 0) {
		$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]-'$rewardprice' WHERE uid='$answererid'", 'UNBUFFERED');
	}

	$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]+'$rewardprice' WHERE uid='$thread[authorid]'", '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');

} elseif($action == 'banpost') {

	$modpostsnum = count($topiclist);
	if(!($banpids = implodeids($topiclist))) {
		showmessage('admin_banpost_invalid');
	} elseif(!$allowbanpost || !$tid) {
		showmessage('admin_nopermission', NULL, 'HALTED');
	}

	$posts = array();$banstatus = 0;
	$query = $db->query("SELECT pid, first, authorid, status FROM {$tablepre}posts WHERE pid IN ($banpids) AND tid='$tid'");
	while($post = $db->fetch_array($query)) {
		if($post['first'] && $thread['digest'] == '-1') {
			showmessage('special_noaction');
		}
		$banstatus = ($post['status'] & 1) || $banstatus;
		$posts[] = $post;
	}

	if(!submitcheck('modsubmit')) {

		$banid = $checkunban = $checkban = '';
		foreach($topiclist as $id) {
			$banid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
		}

		$banstatus ? $checkunban = 'checked="checked"' : $checkban = 'checked="checked"';

		include template('topicadmin_action');

	} else {

		$banned = intval($banned);
		$modaction = $banned ? 'BNP' : 'UBN';

		checkreasonpm();

		$pids = $comma = '';
		foreach($posts as $k => $post) {
			if($banned) {
				$db->query("UPDATE {$tablepre}posts SET status=status|1 WHERE pid='$post[pid]'", 'UNBUFFERED');
			} else {
				$db->query("UPDATE {$tablepre}posts SET status=status^1 WHERE pid='$post[pid]' AND status=status|1", 'UNBUFFERED');
			}
			$pids .= $comma.$post['pid'];
			$comma = ',';
		}

		$resultarray = array(
		'redirect'	=> "viewthread.php?tid=$tid&amp;page=$page",
		'reasonpm'	=> ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post') : array()),
		'modtids'	=> 0,
		'modlog'	=> $thread
		);

		procreportlog('', $pids);

	}

} elseif($action == 'warn') {

	if(!($warnpids = implodeids($topiclist))) {
		showmessage('admin_warn_invalid');
	} elseif(!$allowbanpost || !$tid) {
		showmessage('admin_nopermission', NULL, 'HALTED');
	}

	$posts = $authors = array();
	$authorwarnings = $warningauthor = $warnstatus = '';
	$query = $db->query("SELECT p.pid, p.authorid, p.author, p.status, m.adminid FROM {$tablepre}posts p LEFT JOIN {$tablepre}members m ON p.authorid=m.uid WHERE pid IN ($warnpids) AND p.tid='$tid'");
	while($post = $db->fetch_array($query)) {
		if($post['adminid'] == 0) {
			$warnstatus = ($post['status'] & 2) || $warnstatus;
			$authors[$post['authorid']] = 1;
			$posts[] = $post;
		}
	}

	if(!$posts) {
		showmessage('admin_warn_nopermission', NULL, 'HALTED');
	}
	$authorcount = count(array_keys($authors));
	$modpostsnum = count($posts);

	if($modpostsnum == 1 || $authorcount == 1) {
		$authorwarnings = $db->result_first("SELECT COUNT(*) FROM {$tablepre}warnings WHERE authorid='{$posts[0][authorid]}'");
		$warningauthor = $posts[0]['author'];
	}

	if(!submitcheck('modsubmit')) {

		$warnpid = $checkunwarn = $checkwarn = '';
		foreach($topiclist as $id) {
			$warnpid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
		}

		$warnstatus ? $checkunwarn = 'checked="checked"' : $checkwarn = 'checked="checked"';

		include template('topicadmin_action');

	} else {

		$warned = intval($warned);
		$modaction = $warned ? 'WRN' : 'UWN';

		checkreasonpm();

		$pids = $comma = '';
		foreach($posts as $k => $post) {
			if($post['adminid'] == 0) {
				if($warned && !($post['status'] & 2)) {
					$db->query("UPDATE {$tablepre}posts SET status=status|2 WHERE pid='$post[pid]'", 'UNBUFFERED');
					$reason = cutstr(dhtmlspecialchars($reason), 40);
					$db->query("INSERT INTO {$tablepre}warnings (pid, operatorid, operator, authorid, author, dateline, reason) VALUES ('$post[pid]', '$discuz_uid', '$discuz_user', '$post[authorid]', '".addslashes($post['author'])."', '$timestamp', '$reason')", 'UNBUFFERED');
					$authorwarnings = $db->result_first("SELECT COUNT(*) FROM {$tablepre}warnings WHERE authorid='$post[authorid]'");
					if($authorwarnings >= $warninglimit) {
						$member = $db->fetch_first("SELECT adminid, groupid FROM {$tablepre}members WHERE uid='$post[authorid]'");
						if($member && $member['groupid'] != 4) {
							$banexpiry = $timestamp + $warningexpiration * 86400;
							$groupterms = array();
							$groupterms['main'] = array('time' => $banexpiry, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
							$groupterms['ext'][4] = $banexpiry;
					  		$db->query("UPDATE {$tablepre}members SET groupid='4', groupexpiry='".groupexpiry($groupterms)."' WHERE uid='$post[authorid]'");
					  		$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$post[authorid]'");
					  	}
					}
					$pids .= $comma.$post['pid'];
					$comma = ',';
				} elseif(!$warned && ($post['status'] & 2)) {
					$db->query("UPDATE {$tablepre}posts SET status=status^2 WHERE pid='$post[pid]' AND status=status|2", 'UNBUFFERED');
					$db->query("DELETE FROM {$tablepre}warnings WHERE pid='$post[pid]'", 'UNBUFFERED');
					$pids .= $comma.$post['pid'];
					$comma = ',';
				}
			}
		}

		$resultarray = array(
		'redirect'	=> "viewthread.php?tid=$tid&amp;page=$page",
		'reasonpm'	=> ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_warn_post') : array()),
		'modtids'	=> 0,
		'modlog'	=> $thread
		);

		procreportlog('', $pids);

	}

} 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 + -