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

📄 forums.inc.php

📁 Discuz! 论坛软件系统 Discuz_TC_UTF8.rar
💻 PHP
📖 第 1 页 / 共 4 页
字号:
			$checktrade = array();
			$forum['allowtrade'] = sprintf('%02b', $forum['allowtrade']);
			for($i = 1; $i <= 2; $i++) {
				$checktrade[$i] = $forum['allowtrade'][2 - $i] ? 'checked' : '';
			}

			$checkmod = array($forum['modnewposts'] => 'checked');
			$checkrules = array($forum['alloweditrules'] => 'checked');

			foreach($perms as $perm) {
				$num = -1;
				$$perm = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\" align=\"center\"><tr>";
				foreach($groups as $group) {
					$num++;
					if($num && $num % 4 == 0) {
						$$perm .= "</tr><tr>";
					}
					$checked = strstr($forum[$perm], "\t$group[groupid]\t") ? 'checked' : NULL;
					$$perm .= "<td><input type=\"checkbox\" name=\"{$perm}[]\" value=\"$group[groupid]\" $checked> $group[grouptitle]</td>\n";
				}
				$$perm .= '</tr></table>';
			}

			$viewaccess = $postaccess = $replyaccess = $getattachaccess = $postattachaccess = '';

			$query = $db->query("SELECT m.username, a.* FROM {$tablepre}access a LEFT JOIN {$tablepre}members m USING (uid) WHERE fid='$fid'");
			while($access = $db->fetch_array($query)) {
				$member = ", <a href=\"admincp.php?action=access&uid=$access[uid]\" target=\"_blank\">$access[username]</a>";
				$viewaccess .= $access['allowview'] ? $member : NULL;
				$postaccess .= $access['allowpost'] ? $member : NULL;
				$replyaccess .= $access['allowreply'] ? $member : NULL;
				$getattachaccess .= $access['allowgetattach'] ? $member : NULL;
				$postattachaccess .= $access['allowpostattach'] ? $member : NULL;
			}
			unset($member);

			/* old
			$forum['description'] = str_replace('&lt;', '<', $forum['description']);
			$forum['description'] = str_replace('&gt;', '>', $forum['description']);
			*/

			if($forum['threadtypes']) {
				$forum['threadtypes'] = unserialize($forum['threadtypes']);
				$forum['threadtypes']['status'] = 1;
			} else {
				$forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
			}

			$typeselect = '';
			$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
			while($type = $db->fetch_array($query)) {
				$typeselect .= '<input type="checkbox" name="threadtypesnew[options][]" value="'.$type['typeid'].'" '.(isset($forum['threadtypes']['types'][$type['typeid']]) ? 'checked' : '').'> '.$type['name'].($type['description'] ? ' ('.$type['description'].')' : '').'<br>';
			}
			$typeselect = $typeselect ? $typeselect : $lang['forums_edit_threadtypes_options_null'];

			$forum['postcredits'] = $forum['postcredits']? unserialize($forum['postcredits']) : array();
			$forum['replycredits'] = $forum['replycredits']? unserialize($forum['replycredits']) : array();

			showtype("$lang[forums_detail] - $forum[name]", 'top');
			showsetting('forums_edit_display', 'statusnew', $forum['status'], 'radio');
			showsetting('forums_edit_up', '', '', $fupselect);
			showsetting('forums_edit_style', '', '', $styleselect);
			showsetting('forums_edit_redirect', 'redirectnew', $forum['redirect'], 'text');
			showsetting('forums_edit_name', 'namenew', $forum['name'], 'text');
			showsetting('forums_edit_icon', 'iconnew', $forum['icon'], 'text');
			showsetting('forums_edit_description', 'descriptionnew', $forum['description'], 'textarea');
			showsetting('forums_edit_rules', 'rulesnew', $forum['rules'], 'textarea');
			showsetting('forums_edit_edit_rules', '', '', '<input type="radio" name="alloweditrulesnew" value="0" '.$checkrules[0].'> '.$lang['forums_edit_edit_rules_html_none'].'<br><input type="radio" name="alloweditrulesnew" value="1" '.$checkrules[1].'> '.$lang['forums_edit_edit_rules_html_no'].'<br><input type="radio" name="alloweditrulesnew" value="2" '.$checkrules[2].'> '.$lang['forums_edit_edit_rules_html_yes']);

			showtype('forums_edit_options');
			showsetting('forums_edit_modposts', '', '', '<input type="radio" name="modnewpostsnew" value="0" '.$checkmod[0].'> '.$lang['none'].'<br><input type="radio" name="modnewpostsnew" value="1" '.$checkmod[1].'> '.$lang['forums_edit_modposts_threads'].'<br><input type="radio" name="modnewpostsnew" value="2" '.$checkmod[2].'> '.$lang['forums_edit_modposts_posts']);
			showsetting('forums_edit_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio');
			showsetting('forums_edit_blog', 'allowblognew', $forum['allowblog'], 'radio');
			showsetting('forums_edit_html', 'allowhtmlnew', $forum['allowhtml'], 'radio');
			showsetting('forums_edit_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio');
			showsetting('forums_edit_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio');
			showsetting('forums_edit_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio');
			showsetting('forums_edit_jammer', 'jammernew', $forum['jammer'], 'radio');
			showsetting('forums_edit_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio');
			showsetting('forums_edit_trade', '', '', '<input type="checkbox" name="allowtradenew[1]" value="1" '.$checktrade[1].'> '.$lang['forums_edit_trade_thread'].'<br><input type="checkbox" name="allowtradenew[2]" value="1" '.$checktrade[2].'> '.$lang['forums_edit_trade_payto']);
			showsetting('forums_edit_autoclose', '', '', '<input type="radio" name="autoclosenew" value="0" '.$checkac[0].' onclick="this.form.autoclosetimenew.disabled=true;"> '.$lang['forums_edit_autoclose_none'].'<br><input type="radio" name="autoclosenew" value="1" '.$checkac[1].' onclick="this.form.autoclosetimenew.disabled=false;"> '.$lang['forums_edit_autoclose_dateline'].'<br><input type="radio" name="autoclosenew" value="-1" '.$checkac[-1].' onclick="this.form.autoclosetimenew.disabled=false;"> '.$lang['forums_edit_autoclose_lastpost']);
			showsetting('forums_edit_autoclose_time', '', '', '<input type="text" size="30" value="'.$forum['autoclose'].'" name="autoclosetimenew" '.($acoption ? '' : 'disabled').'>');
			showsetting('forums_edit_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text');

			showtype('forums_edit_credits');
			showsetting('forums_edit_postcredits', 'postcreditsstatus', $forum['postcredits'], 'radio');
			showsetting('forums_edit_replycredits', 'replycreditsstatus', $forum['replycredits'], 'radio');
			echo '<tr><td colspan="2" bgcolor="'.ALTBG1.'"><table cellspacing="'.INNERBORDERWIDTH.'" cellpadding="'.TABLESPACE.'" width="100%" align="center" class="tableborder">'.
				'<tr align="center" class="header"><td>'.$lang['credits_id'].'</td><td>'.$lang['credits_title'].'</td><td>'.$lang['forums_edit_postcredits_add'].'</td><td>'.$lang['forums_edit_replycredits_add'].'</td></tr>';
			for($i = 1; $i <= 8; $i++) {
				echo "<tr align=\"center\" ".(isset($extcredits[$i]) ? '' : 'disabled')."><td bgcolor=\"".ALTBG1."\">extcredits$i</td>".
					"<td bgcolor=\"".ALTBG2."\">{$extcredits[$i]['title']}</td>".
					"<td bgcolor=\"".ALTBG1."\"><input type=\"text\" size=\"2\" name=\"postcreditsnew[$i]\" value=\"".(isset($forum['postcredits'][$i]) ? $forum['postcredits'][$i] : 0)."\"></td>".
					"<td bgcolor=\"".ALTBG2."\"><input type=\"text\" size=\"2\" name=\"replycreditsnew[$i]\" value=\"".(isset($forum['replycredits'][$i]) ? $forum['replycredits'][$i] : 0)."\"></td></tr>";
			}
			echo '</table></td></tr>';

			showtype('forums_edit_threadtypes');
			showsetting('forums_edit_threadtypes_status', 'threadtypesnew[status]', $forum['threadtypes']['status'], 'radio');
			showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio');
			showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio');
			showsetting('forums_edit_threadtypes_prefix', 'threadtypesnew[prefix]', $forum['threadtypes']['prefix'], 'radio');
			showsetting('forums_edit_threadtypes_options', '', '', $typeselect);

			showtype('forums_edit_perm');
			showsetting('forums_edit_perm_passwd', 'passwordnew', $forum['password'], 'text', '15%');
			echo '<tr><td colspan="2" class="singleborder">&nbsp;</td></tr>';

			showsetting('forums_edit_perm_view', '', '', str_replace('cdb_groupname', 'viewperm', $viewperm), '15%');
			echo '<td width="15%" bgcolor="'.ALTBG1.'">'.$lang['forums_edit_access_mask'].'</td><td bgcolor="'.ALTBG2.'">'.substr($viewaccess, 2).'</td></tr>';
			echo '<tr><td colspan="2" class="singleborder">&nbsp;</td></tr>';

			showsetting('forums_edit_perm_post', '', '', str_replace('cdb_groupname', 'postperm', $postperm), '15%');
			echo '<td width="15%" bgcolor="'.ALTBG1.'">'.$lang['forums_edit_access_mask'].'</td><td bgcolor="'.ALTBG2.'">'.substr($postaccess, 2).'</td></tr>';
			echo '<tr><td colspan="2" class="singleborder">&nbsp;</td></tr>';

			showsetting('forums_edit_perm_reply', '', '', str_replace('cdb_groupname', 'replyperm', $replyperm), '15%');
			echo '<td width="15%" bgcolor="'.ALTBG1.'">'.$lang['forums_edit_access_mask'].'</td><td bgcolor="'.ALTBG2.'">'.substr($replyaccess, 2).'</td></tr>';
			echo '<tr><td colspan="2" class="singleborder">&nbsp;</td></tr>';

			showsetting('forums_edit_perm_get_attach', '', '', str_replace('cdb_groupname', 'getattachperm', $getattachperm), '15%');
			echo '<td width="15%" bgcolor="'.ALTBG1.'">'.$lang['forums_edit_access_mask'].'</td><td bgcolor="'.ALTBG2.'">'.substr($getattachaccess, 2).'</td></tr>';
			echo '<tr><td colspan="2" class="singleborder">&nbsp;</td></tr>';

			showsetting('forums_edit_perm_post_attach', '', '', str_replace('cdb_groupname', 'postattachperm', $postattachperm), '15%');
			echo '<td width="15%" bgcolor="'.ALTBG1.'">'.$lang['forums_edit_access_mask'].'</td><td bgcolor="'.ALTBG2.'">'.substr($postattachaccess, 2).'</td></tr>';

			showtype('', 'bottom');

		}

		echo "<br><br><center><input type=\"submit\" name=\"detailsubmit\" value=\"$lang[submit]\"></form>";

	} else {

		if($type == 'group') {

			if($namenew) {
				$db->query("UPDATE {$tablepre}forums SET name='$namenew' WHERE fid='$fid'");
				updatecache('forums');

				cpmsg('forums_edit_succeed');
			} else {
				cpmsg('forums_edit_name_invalid');
			}
			
		} 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'");
			}

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

			$allowtradenew = bindec(intval($allowtradenew[2]).intval($allowtradenew[1]));

			$db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', styleid='$styleidnew',
				allowblog='$allowblognew', allowtrade='$allowtradenew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew',
				allowimgcode='$allowimgcodenew', allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew',
				modnewposts='$modnewpostsnew', recyclebin='$recyclebinnew', jammer='$jammernew',
				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]);
					}
				}
			}
			$postcreditsnew = $postcreditsarray ? addslashes(serialize($postcreditsarray)) : '';
			$replycreditsnew = $replycreditsarray ? addslashes(serialize($replycreditsarray)) : '';

			if($threadtypesnew['status']) {
				if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
					$threadtypesnew['types'] = array();
					$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ('".implode('\',\'', $threadtypesnew['options'])."') ORDER BY displayorder");
					while($type = $db->fetch_array($query)) {
						$threadtypesnew['types'][$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']
						))) : '';
				}

⌨️ 快捷键说明

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