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

📄 forums.inc.php

📁 极限网络智能办公系统 Office Automation V3.0官方100%源代码.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php

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

	$RCSfile: forums.inc.php,v $
	$Revision: 1.95.2.5 $
	$Date: 2007/03/21 15:52:02 $
*/

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
        exit('Access Denied');
}

cpheader();

if($action == 'forumadd')  {

	if((!submitcheck('catsubmit') && !submitcheck('forumsubmit'))) {
		$addforumtype = '';
		$groupselect = $forumselect = "<select name=\"fup\">\n";
		$query = $db->query("SELECT fid, name, type, fup FROM {$tablepre}forums WHERE type<>'sub' ORDER BY displayorder");
		while($fup = $db->fetch_array($query)) {
			$fups[] = $fup;
		}
		if(is_array($fups)) {
			foreach($fups as $forum1) {
				if($forum1['type'] == 'group') {
					if(isset($fupid) && $fupid == $forum1['fid']) {
						$fupselected = 'selected';
						$addforumtype = $forum1['type'];
					} else {
						$fupselected = '';
					}

					$groupselect .= "<option value=\"$forum1[fid]\" $fupselected>$forum1[name]</option>\n";
					$forumselect .= "<optgroup label=\"$forum1[name]\">\n";
					foreach($fups as $forum2) {
						if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) {
							if(isset($fupid) && $fupid == $forum2['fid']) {
								$fupselected = 'selected';
								$addforumtype = $forum2['type'];
							} else {
								$fupselected = '';
							}

							$forumselect .= "<option value=\"$forum2[fid]\" $fupselected>&nbsp; &gt; $forum2[name]</option>\n";
						}
					}
				}
			}
			foreach($fups as $forum0) {
				if($forum0['type'] == 'forum' && $forum0['fup'] == 0) {
					if(isset($fupid) && $fupid == $forum0['fid']) {
						$fupselected = 'selected';
						$addforumtype = $forum0['type'];
					} else {
						$fupselected = '';
					}
					if($forum0['type'] == 'group') {
						$groupselect .= "<option value=\"$forum0[fid]\" $fupselected>$forum0[name]</option>\n";
					} else {
						$forumselect .= "<option value=\"$forum0[fid]\" $fupselected>$forum0[name]</option>\n";
					}
				}
			}
		}
		$groupselect .= '</select>';
		$forumselect .= '</select>';

		$projectselect = "<select name=\"projectid\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
		$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'");
		while($project = $db->fetch_array($query)) {
			$projectselect .= "<option value=\"$project[id]\">$project[name]</option>\n";
		}
		$projectselect .= '</select>';

		shownav('menu_forums_add');
		showtips('forums_add_tips');

		if(empty($addforumtype)) {

?>
<br><form method="post" action="admincp.php?action=forumadd&add=category">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td colspan="3"><?=$lang['forums_add_category']?></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['name']?>:</td>
<td class="altbg2" width="85%"><input type="text" name="newcat" value="<?=$lang['forums_add_category_name']?>" size="20"></td>
</table><br><center>
<input class="button" type="submit" name="catsubmit" value="<?=$lang['submit']?>"></center></form>
<?

		}

		if(empty($addforumtype) || $addforumtype == 'group') {

?>
<br><form method="post" action="admincp.php?action=forumadd&add=forum">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td colspan="2"><?=$lang['forums_add_forum']?></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['name']?>:</td>
<td class="altbg2" width="85%"><input type="text" name="newforum" value="<?=$lang['forums_add_forum_name']?>" size="20"></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['forums_add_parent_category']?>:</td>
<td class="altbg2" width="85%"><?=$groupselect?></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['forums_scheme']?></td>
<td class="altbg2" width="85%"><?=$projectselect?></td></tr></table><br>
<center><input class="button" type="submit" name="forumsubmit" value="<?=$lang['submit']?>"></center></form>
<?

		}

		if(empty($addforumtype) || $addforumtype == 'forum') {

?>
<br><form method="post" action="admincp.php?action=forumadd&add=forum">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td colspan="3"><?=$lang['forums_add_sub']?></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['name']?>:</td>
<td class="altbg2" width="28%"><input type="text" name="newforum" value="<?=$lang['forums_add_sub_name']?>" size="20"></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['forums_add_parent_forum']?>:</td>
<td class="altbg2" width="27%"><?=$forumselect?></td></tr>
<tr align="center"><td class="altbg1" width="15%"><?=$lang['forums_scheme']?></td>
<td class="altbg2" width="85%"><?=$projectselect?></td></tr></table><br>
<center><input class="button" type="submit" name="forumsubmit" value="<?=$lang['submit']?>"></center>
</form><br>
<?

		}

	} elseif(submitcheck('catsubmit')) {

		if(strlen($newcat) > 50) {
			cpmsg('forums_name_toolong');
		}

		$db->query("INSERT INTO {$tablepre}forums (type, name, status)
			VALUES ('group', '$newcat', '1')");
		$fid = $db->insert_id();

		$db->query("INSERT INTO {$tablepre}forumfields (fid)
			VALUES ('$fid')");

		updatecache('forums');
		cpmsg('forums_add_category_succeed', 'admincp.php?action=forumsedit');

	} elseif(submitcheck('forumsubmit')) {

		if(strlen($newforum) > 50) {
			cpmsg('forums_name_toolong');
		}

		if(!$fup) {
			cpmsg('forums_noparent');
		}

		$modarray = $forumfields = array();
		$table_forum_columns = array('fup', 'type', 'name', 'status', 'styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'allowpaytoauthor', 'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple');
		$table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm');

		$query = $db->query("SELECT * FROM {$tablepre}forums WHERE fid='$fup'");
		$forum = $db->fetch_array($query);
		if(!empty($projectid)) {
			$query = $db->query("SELECT value FROM {$tablepre}projects WHERE id='$projectid'");
			$project = unserialize($db->result($query, 0));

			foreach($table_forum_columns as $field) {
				$forumfields[$field] = $project[$field];
			}

			foreach($table_forumfield_columns as $field) {
				$forumfields[$field] = $project[$field];
			}

		} else {
			$forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = $forumfields['allowshare'] = 1;
			$forumfields['allowpostspecial'] = 15;
		}

		$forumfields['fup'] = $forum ? $fup : 0;
		$forumfields['type'] = $forum['type'] == 'forum' ? 'sub' : 'forum';
		$forumfields['name'] = $newforum;
		$forumfields['status'] = 1;

		$sql1 = $sql2 = $comma = '';
		foreach($table_forum_columns as $field) {
			if(isset($forumfields[$field])) {
				$sql1 .= "$comma$field";
				$sql2 .= "$comma'{$forumfields[$field]}'";
				$comma = ', ';
			}
		}

		$db->query("INSERT INTO {$tablepre}forums ($sql1) VALUES ($sql2)");
		$forumfields['fid'] = $fid = $db->insert_id();

		$sql1 = $sql2 = $comma = '';
		foreach($table_forumfield_columns as $field) {
			if(isset($forumfields[$field])) {
				$sql1 .= "$comma$field";
				$sql2 .= "$comma'{$forumfields[$field]}'";
				$comma = ', ';
			}
		}

		$db->query("INSERT INTO {$tablepre}forumfields ($sql1) VALUES ($sql2)");

		$query = $db->query("SELECT uid, inherited FROM {$tablepre}moderators WHERE fid='$fup'");
		while($mod = $db->fetch_array($query)) {
			if($mod['inherited'] || $forum['inheritedmod']) {
				$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited)
					VALUES ('$mod[uid]', '$fid', '1')");
			}
		}

		updatecache('forums');
		cpmsg('forums_add_forum_succeed', 'admincp.php?action=forumsedit');

	}

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

	if(!submitcheck('editsubmit')) {
		shownav('menu_forums_edit');
		showtips('forums_tips');

?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td><?=$lang['forums_edit']?></td></tr>
<tr><td class="altbg1"><br>
<form method="post" action="admincp.php?action=forumsedit">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<?

		$forums = $showedforums = array();
		$query = $db->query("SELECT f.fid, f.type, f.status, f.name, f.fup, f.displayorder, f.inheritedmod, ff.moderators
			FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid)
			ORDER BY f.type<>'group', f.displayorder");

		while($forum = $db->fetch_array($query)) {
			$forums[] = $forum;
		}
		for($i = 0; $i < count($forums); $i++) {
			if($forums[$i]['type'] == 'group') {
				echo '<ul>'.showforum($i, 'group');
				for($j = 0; $j < count($forums); $j++) {
					if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'forum') {
						echo '<ul>'.showforum($j);
						for($k = 0; $k < count($forums); $k++) {
							if($forums[$k]['fup'] == $forums[$j]['fid'] && $forums[$k]['type'] == 'sub') {
								echo '<ul>'.showforum($k, 'sub').'</ul>';
							}
						}

⌨️ 快捷键说明

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