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

📄 topicadmin.php

📁 极限网络智能办公系统 - Office Automation 2.8 100% 源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

/*
	[Discuz!] (C)2001-2006 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$RCSfile: topicadmin.php,v $
	$Revision: 1.11 $
	$Date: 2006/02/23 13:44:02 $
*/


require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/post.func.php';
require_once DISCUZ_ROOT.'./include/misc.func.php';

$discuz_action = 201;
$modpostsnum = 0;
$resultarray = array();

if(!$discuz_uid || !$forum['ismoderator']) {
	showmessage('admin_nopermission', NULL, 'HALTED');
}

if($forum['type'] == 'forum') {
	$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a>";
	$navtitle = ' - '.strip_tags($forum['name']);
} else {
	$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
	$fup = $db->fetch_array($query);
	$navigation = "&raquo; <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> &raquo; <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> ";
	$navtitle = ' - '.strip_tags($fup['name']).' - '.strip_tags($forum['name']);
}

if(!empty($tid)) {
	$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND fid='$fid' AND displayorder>='0'");
	if($thread = $db->fetch_array($query)) {
		$navigation .= " &raquo; <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
		$navtitle .= ' - '.$thread['subject'];
	} else {
		showmessage('thread_nonexistence');
	}
} elseif(!in_array($action, array('moderate', 'delpost', 'getip'))) {
	showmessage('undefined_action', NULL, 'HALTED');
}

// Reason P.M. Preprocess Start
$reasonpmcheck = $reasonpm == 2 || $reasonpm == 3 ? 'checked disabled' : '';
if(($reasonpm == 2 || $reasonpm == 3) || !empty($sendreasonpm)) {
	$forumname = strip_tags($forum['name']);
	$sendreasonpm = 1;
} else {
	$sendreasonpm = 0;
}
// End

$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];

if(($action == 'moderate' && $fid) || in_array($action, array('delete', 'move', 'highlight', 'close', 'stick', 'digest'))) {

	if($action != 'moderate' ) {
		$operation = $action;
		$action = 'moderate';
		$moderate = array($tid);
	}

	if(empty($moderate) || !is_array($moderate) || !in_array($operation, array('delete', 'move', 'highlight', 'type', 'close', 'stick', 'digest')) || (!$allowdelpost && $operation == 'delete') || (!$allowstickthread && $operation == 'stick')) {
		showmessage('admin_moderate_invalid');
	}

	$single = count($moderate) == 1 ? true : false;
	$referer = $single ? "forumdisplay.php?fid=$fid" : dreferer();

	$tids = is_array($moderate) ? '\''.implode('\',\'', $moderate).'\'' : '';

	if(!submitcheck('modsubmit')) {

		if($operation == 'move') {
			require_once DISCUZ_ROOT.'./include/forum.func.php';
			$forumselect = forumselect();
		} elseif($operation == 'highlight') {
			$stylecheck = array();
			$colorcheck = array(0 => 'checked');
			if($single) {
				$string = sprintf('%02d', $thread['highlight']);
				$stylestr = sprintf('%03b', $string[0]);
				for($i = 1; $i <= 3; $i++) {
					$stylecheck[$i] = $stylestr[$i - 1] ? 'checked' : '';
				}
				$colorcheck = array($string[1] => 'checked');
			}
		} elseif($operation == 'type') {
			$typeselect = typeselect();
		}

		$threadlist = $loglist = array();
		$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ($tids) AND fid='$fid' AND displayorder>='0' LIMIT $tpp");
		while($thread = $db->fetch_array($query)) {
			$thread['lastposterenc'] = rawurlencode($thread['lastposter']);
			$thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
			$threadlist[] = $thread;
		}

		if(empty($threadlist)) {
			showmessage('admin_moderate_invalid');
		}

		if(in_array($operation, array('stick', 'digest', 'highlight', 'close'))) {

			$expirationmin = gmdate($dateformat, $timestamp + 86400 + $timeoffset * 3600);
			$expirationmax = gmdate($dateformat, $timestamp + 86400 * 180 + $timeoffset * 3600);

			$expirationdefault = '';
			$stickcheck  = $digestcheck = $closecheck = array();

			if($single) {

				empty($threadlist['0']['displayorder']) ? $stickcheck[1] ='checked' : $stickcheck[$threadlist['0']['displayorder']] = 'checked';
				empty($threadlist['0']['digest']) ? $digestcheck[1] = 'checked' : $digestcheck[$threadlist['0']['digest']] = 'checked';
				empty($threadlist['0']['closed']) ? $closecheck[0] = 'checked' : $closecheck[1] = 'checked';

				if($threadlist['0']['moderated']) {
					switch($operation) {
						case 'stick': $actionarray = array('EST'); break;
						case 'digest': $actionarray = array('EDI'); break;
						case 'highlight': $actionarray = array('EHL'); break;
						case 'close': $actionarray = array('ECL', 'EOP'); break;
					}
					$query = $db->query("SELECT * FROM {$tablepre}threadsmod WHERE tid='{$threadlist[0][tid]}' ORDER BY dateline DESC");
					while($log = $db->fetch_array($query)) {
						$log['dateline'] = gmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
						$log['expiration'] = !empty($log['expiration']) ? gmdate("$dateformat", $log['expiration'] + $timeoffset * 3600) : '';
						if($log['status'] && in_array($log['action'], $actionarray)) { 
							$expirationdefault = $log['expiration'];
						}
						$log['status'] = empty($log['status']) ? 'style="text-decoration: line-through" disabled' : '';
						$loglist[] = $log;
					}
					if(!empty($loglist)) {
						include_once language('modactions');
					}
				}
			}
		}

		include template('topicadmin_moderate');

	} else {

		$moderatetids = '0';
		$threads = array();
		$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid IN ($tids) AND fid='$fid' AND displayorder>='0' LIMIT $tpp");
		while($thread = $db->fetch_array($query)) {
			$threads[] = $thread;
			$moderatetids .= ','.$thread['tid'];
			$modpostsnum ++;
		}

		checkreasonpm();

		if($operation == 'delete') {

			$stickmodify = 0;
			foreach($threads as $thread) {
				if($thread['digest']) {
					updatecredits($thread['authorid'], $creditspolicy['digest'], -$thread['digest'], 'digestposts=digestposts-1');
				}
				if(in_array($thread['displayorder'], array(2, 3))) {
					$stickmodify = 1;
				}
			}

			$losslessdel = $losslessdel > 0 ? $timestamp - $losslessdel * 86400 : 0;

			//Update members' credits and post counter
			$uidarray = $tuidarray = $ruidarray = array();
			$query = $db->query("SELECT first, authorid, dateline FROM {$tablepre}posts WHERE tid IN ($moderatetids)");
			while($post = $db->fetch_array($query)) {
				if($post['dateline'] < $losslessdel) {
					$uidarray[] = $post['authorid'];
				} else {
					if($post['first']) {
						$tuidarray[] = $post['authorid'];
					} else {
						$ruidarray[] = $post['authorid'];
					}
				}
			}

			if($uidarray) {
				updatepostcredits('-', $uidarray, array());
			}
			if($tuidarray) {
				updatepostcredits('-', $tuidarray, $postcredits);
			}
			if($ruidarray) {
				updatepostcredits('-', $ruidarray, $replycredits);
			}
			$modaction = 'DEL';

			if($forum['recyclebin']) {

				$db->query("UPDATE {$tablepre}threads SET displayorder='-1', digest='0', moderated='1' WHERE tid IN ($moderatetids)");
				$db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ($moderatetids)");

			} else {

				$query = $db->query("SELECT attachment FROM {$tablepre}attachments WHERE tid IN ($moderatetids)");
				while($attach = $db->fetch_array($query)) {
					@unlink($attachdir.'/'.$attach['attachment']);
				}

				$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($moderatetids)", 'UNBUFFERED');
				$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($moderatetids)", 'UNBUFFERED');
				$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($moderatetids)");
				$db->query("DELETE FROM {$tablepre}relatedthreads WHERE tid IN ($moderatetids)");				
				$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($moderatetids)");
				$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($moderatetids)");

			}

			if($globalstick && $stickmodify) {
				require_once DISCUZ_ROOT.'./include/cache.func.php';
				updatecache('globalstick');
			}

			updateforumcount($fid);

		 } else {

		 	if(isset($expiration) && !empty($expiration) && in_array($operation, array('stick', 'digest', 'highlight', 'close'))) {
		 		$expiration = strtotime($expiration) - $timeoffset * 3600 + date('Z');
				if(gmdate('Ymd', $expiration + $timeoffset * 3600) <= gmdate('Ymd', $timestamp + $timeoffset * 3600) || ($expiration > $timestamp + 86400 * 180)) {
		 			showmessage('admin_expiration_invalid');
		 		}
		 	} else {
		 		$expiration = 0;
		 	}

		 	if($operation == 'stick' || $operation == 'digest') {

				$level = intval($level);
				if($level < 0 || $level > 3 || ( $operation == 'stick' && $level > $allowstickthread)){
					showmessage('undefined_action');
				}

				$expiration = $level ? $expiration : 0;

				if($operation == 'stick') {

					$db->query("UPDATE {$tablepre}threads SET displayorder='$level', moderated='1' WHERE tid IN ($moderatetids)");

					$stickmodify = 0;
					foreach($threads as $thread) {
						$stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($level, array(2, 3))) && $level != $thread['displayorder'] ? 1 : $stickmodify;
					}

					if($globalstick && $stickmodify) {
						require_once DISCUZ_ROOT.'./include/cache.func.php';
						updatecache('globalstick');
					}

					$modaction = $level ? ($expiration ? 'EST' : 'STK') : 'UST';
					$db->query("UPDATE {$tablepre}threadsmod SET status='0' WHERE tid IN ($moderatetids) AND action IN ('STK', 'UST', 'EST', 'UES')", 'UNBUTTERED');

				} elseif($operation == 'digest') {

					$db->query("UPDATE {$tablepre}threads SET digest='$level', moderated='1' WHERE tid IN ($moderatetids)");

					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'], $creditspolicy['digest'], $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');
				}
				
				$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$moveto' AND status='1' AND type<>'group'");
				if(!$toforum = $db->fetch_array($query)) {
					showmessage('admin_move_invalid');
				}

				$stickmodify = 0;
				foreach($threads as $thread) {
					if(in_array($thread['displayorder'], array(2, 3))) {
						$stickmodify = 1;
					}
				}

				$displayorderadd = $adminid == 3 ? ', displayorder=\'0\'' : '';

				$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, poll, 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 == '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';

			}

		}
		
		$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,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -