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

📄 forums.inc.php

📁 论坛软件系统亦称电子公告板(BBS)系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:

		} else {

			$extensionarray = array();
			foreach(explode(',', $attachextensionsnew) as $extension) {
				if($extension = trim($extension)) {
					$extensionarray[] = $extension;
				}
			}
			$attachextensionsnew = implode(', ', $extensionarray);

			foreach($perms as $perm) {
				${$perm.'new'} = is_array($$perm) && !empty($$perm) ? "\t".implode("\t", $$perm)."\t" : '';
			}

			$fupadd = '';
			if($fupnew != $forum['fup']) {
				$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fup='$fid'");
				if($db->num_rows($query)) {
					cpmsg('forums_edit_sub_notnull');
				}

				$query = $db->query("SELECT fid, type, inheritedmod FROM {$tablepre}forums WHERE fid='$fupnew'");
				$fup = $db->fetch_array($query);

				$fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'";

				$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='1'");
				$query = $db->query("SELECT * FROM {$tablepre}moderators WHERE fid='$fupnew' ".($fup['inheritedmod'] ? '' : "AND inherited='1'"));
				while($mod = $db->fetch_array($query)) {
					$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
						VALUES ('$mod[uid]', '$fid', '0', '1')");
				}

				$moderators = $tab = '';
				$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
				while($mod = $db->fetch_array($query)) {
					$moderators .= $tab.addslashes($mod['username']);
					$tab = "\t";
				}
				$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
			}

			$supe_pushsettingadd = $supe_status ? ", supe_pushsetting='".serialize($supe_pushsetting)."'" : '';

			if(!$allowsharenew && (bool)$allowsharenew != (bool)$forum['allowshare']) {
				$db->query("UPDATE {$tablepre}threads SET blog='0' WHERE fid='$fid'");
			}

			$allowpostspecialnew = bindec(intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
			$forumcolumnsnew = intval($forumcolumnsnew);
			$threadcachesnew = max(0, min(100, intval($threadcachesnew)));
			$db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', styleid='$styleidnew', allowshare='$allowsharenew',
				allowpostspecial='$allowpostspecialnew', allowpaytoauthor='$allowpaytoauthornew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew', allowimgcode='$allowimgcodenew',
				allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew', modnewposts='$modnewpostsnew',
				recyclebin='$recyclebinnew', jammer='$jammernew', allowanonymous='$allowanonymousnew', forumcolumns='$forumcolumnsnew', threadcaches='$threadcachesnew',
				disablewatermark='$disablewatermarknew', autoclose='".intval($autoclosenew * $autoclosetimenew)."' $fupadd
				WHERE fid='$fid'");

			$query = $db->query("SELECT fid FROM {$tablepre}forumfields WHERE fid='$fid'");
			if(!($db->num_rows($query))) {
				$db->query("INSERT INTO {$tablepre}forumfields (fid)
					VALUES ('$fid')");
			}

			$postcreditsarray = $replycreditsarray = array();

			if($postcreditsstatus) {
				for($i = 1; $i <= 8; $i++) {
					if(isset($extcredits[$i]) && isset($postcreditsnew[$i])) {
						$postcreditsnew[$i]  = $postcreditsnew[$i] < -99 ? -99 : $postcreditsnew[$i];
						$postcreditsnew[$i]  = $postcreditsnew[$i] > 99 ? 99 : $postcreditsnew[$i];
						$postcreditsarray[$i] = intval($postcreditsnew[$i]);
					}
				}
			}
			if($replycreditsstatus) {
				for($i = 1; $i <= 8; $i++) {
					if(isset($extcredits[$i]) && isset($replycreditsnew[$i])) {
						$replycreditsnew[$i]  = $replycreditsnew[$i] < -99 ? -99 : $replycreditsnew[$i];
						$replycreditsnew[$i]  = $replycreditsnew[$i] > 99 ? 99 : $replycreditsnew[$i];
						$replycreditsarray[$i] = intval($replycreditsnew[$i]);
					}
				}
			}
			if($digestcreditsstatus) {
				for($i = 1; $i <= 8; $i++) {
					if(isset($extcredits[$i]) && isset($digestcreditsnew[$i])) {
						$digestcreditsnew[$i]  = $digestcreditsnew[$i] < -99 ? -99 : $digestcreditsnew[$i];
						$digestcreditsnew[$i]  = $digestcreditsnew[$i] > 99 ? 99 : $digestcreditsnew[$i];
						$digestcreditsarray[$i] = intval($digestcreditsnew[$i]);
					}
				}
			}
			if($postattachcreditsstatus) {
				for($i = 1; $i <= 8; $i++) {
					if(isset($extcredits[$i]) && isset($postattachcreditsnew[$i])) {
						$postattachcreditsnew[$i]  = $postattachcreditsnew[$i] < -99 ? -99 : $postattachcreditsnew[$i];
						$postattachcreditsnew[$i]  = $postattachcreditsnew[$i] > 99 ? 99 : $postattachcreditsnew[$i];
						$postattachcreditsarray[$i] = intval($postattachcreditsnew[$i]);
					}
				}
			}
			if($getattachcreditsstatus) {
				for($i = 1; $i <= 8; $i++) {
					if(isset($extcredits[$i]) && isset($getattachcreditsnew[$i])) {
						$getattachcreditsnew[$i]  = $getattachcreditsnew[$i] < -99 ? -99 : $getattachcreditsnew[$i];
						$getattachcreditsnew[$i]  = $getattachcreditsnew[$i] > 99 ? 99 : $getattachcreditsnew[$i];
						$getattachcreditsarray[$i] = intval($getattachcreditsnew[$i]);
					}
				}
			}
			$postcreditsnew = $postcreditsarray ? addslashes(serialize($postcreditsarray)) : '';
			$replycreditsnew = $replycreditsarray ? addslashes(serialize($replycreditsarray)) : '';
			$digestcreditsnew = $digestcreditsarray ? addslashes(serialize($digestcreditsarray)) : '';
			$postattachcreditsnew = $postattachcreditsarray ? addslashes(serialize($postattachcreditsarray)) : '';
			$getattachcreditsnew = $getattachcreditsarray ? addslashes(serialize($getattachcreditsarray)) : '';

			$threadtypesnew['types'] = $threadtypesnew['flat'] = $threadtypes['selectbox'] = array();

			if(is_array($newname) && $newname) {
				$newname = array_unique($newname);
				if($newname) {
					foreach($newname AS $key => $val) {
						$val = dhtmlspecialchars(trim($val));
						if($val) {
							$query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$val'");
							$newtypeid = $db->result($query, 0);
							if(!$newtypeid) {
								$db->query("INSERT INTO	{$tablepre}threadtypes (name, description) VALUES
									('$val', '".dhtmlspecialchars(trim($newdescription[$key]))."')");
								$newtypeid = $db->insert_id();
							}
							if($newoptions[$key] == 1) {
								$threadtypesnew['types'][$newtypeid] = $threadtypesnew['flat'][$newtypeid] = $val;
							} elseif($newoptions[$key] == 2) {
								$threadtypesnew['types'][$newtypeid] = $threadtypesnew['selectbox'][$newtypeid] = $val;
							}
						}
					}
				}
				$threadtypesnew['status'] = 1;
			} else {
				$newname = array();
			}
			if($threadtypesnew['status']) {
				if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {

					$typeids = '0';
					foreach($threadtypesnew['options'] as $key => $val) {
						$typeids .= $val ? ', '.intval($key) : '';
					}

					$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($typeids) ORDER BY displayorder");
					while($type = $db->fetch_array($query)) {
						if($threadtypesnew['options'][$type['typeid']] == 1) {
							$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['flat'][$type['typeid']] = $type['name'];
						} elseif($threadtypesnew['options'][$type['typeid']] == 2) {
							$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['selectbox'][$type['typeid']] = $type['name'];
						}
					}
				}
				$threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array
					(
					'required' => (bool)$threadtypesnew['required'],
					'listable' => (bool)$threadtypesnew['listable'],
					'prefix' => (bool)$threadtypesnew['prefix'],
					'types' => $threadtypesnew['types'],
					'selectbox' => $threadtypesnew['selectbox'],
					'flat' => $threadtypesnew['flat'],
					))) : '';
			} else {
				$threadtypesnew = '';
			}

			$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
				attachextensions='$attachextensionsnew', threadtypes='$threadtypesnew', postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
				postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew',
				getattachperm='$getattachpermnew', postattachperm='$postattachpermnew'$supe_pushsettingadd WHERE fid='$fid'");

			if($statusnew == 0) {
				$db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED');
			}

			updatecache('forums');

			cpmsg('forums_edit_succeed', 'admincp.php?action=forumsedit');
		}

	}

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

	$query = $db->query("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$fid'");
	if($db->result($query, 0)) {
		cpmsg('forums_delete_sub_notnull');
	}

	if(!$confirmed) {
		cpmsg('forums_delete_confirm', "admincp.php?action=forumdelete&fid=$fid", 'form');
	} else {
		require_once DISCUZ_ROOT.'./include/post.func.php';

		$tids = 0;
		$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE attachment>'0' AND fid='$fid'");
		while($thread = $db->fetch_array($query)) {
			$tids .= ','.$thread['tid'];
		}

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

		$db->query("DELETE FROM {$tablepre}threads WHERE fid='$fid'");
		$db->query("DELETE FROM {$tablepre}posts WHERE fid='$fid'");
		$db->query("DELETE FROM {$tablepre}forums WHERE fid='$fid'");
		$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$fid'");
		$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid'");
		$db->query("DELETE FROM {$tablepre}access WHERE fid='$fid'");

		updatecache('forums');

		cpmsg('forums_delete_succeed', 'admincp.php?action=forumsedit');
	}

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

	if(!submitcheck('typesubmit')) {

		$forumsarray = $fidsarray = array();
		$query = $db->query("SELECT f.fid, f.name, ff.threadtypes FROM {$tablepre}forums f , {$tablepre}forumfields ff WHERE ff.threadtypes<>'' AND f.fid=ff.fid");
		while($forum = $db->fetch_array($query)) {
			$forum['threadtypes'] = unserialize($forum['threadtypes']);
			if(is_array($forum['threadtypes']['types'])) {
				foreach($forum['threadtypes']['types'] as $typeid => $name) {
					$forumsarray[$typeid][] = '<a href="forumdisplay.php?fid='.$forum['fid'].'" target="_blank">'.$forum['name'].'</a> [<a href="admincp.php?action=forumdetail&fid='.$forum['fid'].'">'.$lang['edit'].'</a>]';
					$fidsarray[$typeid][] = $forum['fid'];
				}
			}
		}

		$threadtypes = '';
		$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
		while($type = $db->fetch_array($query)) {
			$threadtypes .= "<tr align=\"center\"><td class=\"altbg1\"><input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\"></td>\n".
				"<td class=\"altbg2\"><input type=\"text\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\"></td>\n".
				"<td class=\"altbg1\"><input type=\"text\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\"></td>\n".
				"<td class=\"altbg2\"><input type=\"text\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\"></td>\n".
				"<td class=\"altbg1\">".(is_array($forumsarray[$type['typeid']]) ? implode(', ', $forumsarray[$type['typeid']])."<input type=\"hidden\" name=\"fids[$type[typeid]]\" value=\"".implode(', ', $fidsarray[$type['typeid']])."\">" : '')."</td></tr>\n";
		}
		shownav('menu_forums_threadtypes');
		showtips('forums_threadtypes_tips');

?>
<form method="post" action="admincp.php?action=threadtypes">
<input type="hidden" name="formhash" value="<?=FORMHASH?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder">
<tr class="header"><td colspan="5"><?=$lang['forums_threadtypes']?></td></tr>
<tr align="center" class="category"><td><input class="checkbox" type="checkbox" name="chkall" class="category" onclick="checkall(this.form)"><?=$lang['del']?></td><td><?=$lang['forums_threadtypes']?></td><td><?=$lang['display_order']?></td><td><?=$lang['description']?></td><td><?=$lang['forums_threadtypes_forums']?></td></tr>
<?=$threadtypes?>
<tr align="center" class="altbg1"><td><?=$lang['add_new']?></td><td><input type='text' name="newname" size="15"></td><td><input type="text" name="newdisplayorder" size="2" value="0"></td><td><input type="text" name="newdescription" size="30" value=""></td><td>&nbsp;</td></tr>
</table><br>
<center><input class="button" type="submit" name="typesubmit" value="<?=$lang['submit']?>"></center>

⌨️ 快捷键说明

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