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

📄 forums.inc.php

📁 论坛代码网增加免费空间业务
💻 PHP
📖 第 1 页 / 共 5 页
字号:
			} else {
				$threadtypesadd = $threadtypemodeladd = '';
			}

			if(!empty($tradetypes) && is_array($tradetypes) && $allowpostspecialtrade) {
				if(count($tradetypes) == count($tradetypesnew)) {
					$tradetypesnew = '';
				} else {
					$tradetypesnew = addslashes(serialize($tradetypesnew));
				}
			} else {
				$tradetypesnew = '';
			}

			$modrecommendnew['num'] = $modrecommendnew['num'] ? intval($modrecommendnew['num']) : 10;
			$modrecommendnew['cachelife'] = $modrecommendnew['cachelife'] ? intval($modrecommendnew['cachelife']) : 900;
			$modrecommendnew['maxlength'] = $modrecommendnew['maxlength'] ? intval($modrecommendnew['maxlength']) : 0;
			$modrecommendnew['dateline'] = $modrecommendnew['dateline'] ? intval($modrecommendnew['dateline']) : 0;
			$modrecommendnew = $modrecommendnew && is_array($modrecommendnew) ? addslashes(serialize($modrecommendnew)) : '';
			$descriptionnew = addslashes(discuzcode(stripslashes($descriptionnew), 1, 0, 0, 0, 1, 1, 0, 0, 1));
			$rulesnew = addslashes(discuzcode(stripslashes($rulesnew), 1, 0, 0, 0, 1, 1, 0, 0, 1));
			$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
				attachextensions='$attachextensionsnew', $threadtypesadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
				postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew', tradetypes='$tradetypesnew', typemodels='$threadtypemodeladd',
				getattachperm='$getattachpermnew', postattachperm='$postattachpermnew', formulaperm='$formulapermnew', modrecommend='$modrecommendnew', keywords='$keywordsnew' WHERE fid='$fid'");

			if($modrecommendnew && !$modrecommendnew['sort']) {
				require_once DISCUZ_ROOT.'./include/forum.func.php';
				recommendupdate($fid, $modrecommendnew, '1');
			}

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

			updatecache('forums');

			if($foruminfosidestatus) {
				$infosidestatusnew = $infosidestatus;
				unset($infosidestatusnew['f'.$fid]);
				$foruminfosidestatus[0] != $infosidestatus[0] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
				$foruminfosidestatus[1] != $infosidestatus[1] && $foruminfosidestatus[1] != '' && $infosidestatusnew['f'.$fid][1] = $foruminfosidestatus[1];
				$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
				if($infosidestatus != $infosidestatusnew) {
					$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
					updatecache('settings');
				}
			}

			if(submitcheck('saveconfigsubmit') && $type != 'group') {
				$projectid = intval($projectid);
				dheader("Location: {$boardurl}admincp.php?action=project&operation=add&id=$fid&type=forum&projectid=$projectid");
			} else {
				cpmsg('forums_edit_succeed', "admincp.php?action=forums&operation=edit&fid=$fid".($anchor ? "&anchor=$anchor" : ''), 'succeed');
			}
		}

	}

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

	if($ajax) {
		ob_end_clean();
		require_once DISCUZ_ROOT.'./include/post.func.php';
		$tids = 0;

		$total = intval($total);
		$pp = intval($pp);
		$currow = intval($currow);

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

		if($tids) {
			$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
			while($attach = $db->fetch_array($query)) {
				dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
			}

			foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'videos', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend') as $value) {
				$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
			}
		}

		if($currow + $pp > $total) {
			$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'");
			echo 'TRUE';
			exit;
		}

		echo 'GO';
		exit;

	} else {

		if($finished) {
			updatecache('forums');
			cpmsg('forums_delete_succeed', 'admincp.php?action=forums', 'succeed');

		}

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

		if(!$confirmed) {

			cpmsg('forums_delete_confirm', "admincp.php?action=forums&operation=delete&fid=$fid", 'form');

		} else {

			$threads = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid'");

			cpmsg('forums_delete_alarm', "admincp.php?action=forums&operation=delete&fid=$fid&confirmed=1", 'loadingform', '<div id="percent">0%</div>', FALSE);

			echo "
			<div id=\"statusid\" style=\"display:none\"></div>
			<script type=\"text/JavaScript\">
				var xml_http_building_link = '".$lang['xml_http_building_link']."';
				var xml_http_sending = '".$lang['xml_http_sending']."';
				var xml_http_loading = '".$lang['xml_http_loading']."';
				var xml_http_load_failed = '".$lang['xml_http_load_failed']."';
				var xml_http_data_in_processed = '".$lang['xml_http_data_in_processed']."';
				function forumsdelete(url, total, pp, currow) {

					var x = new Ajax('HTML', 'statusid');
					x.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {
						if(s != 'GO') {
							location.href = 'admincp.php?action=forums&operation=delete&finished=1';
						}

						currow += pp;
						var percent = ((currow / total) * 100).toFixed(0);
						percent = percent > 100 ? 100 : percent;
						document.getElementById('percent').innerHTML = percent+'%';
						document.getElementById('percent').style.backgroundPosition = '-'+percent+'%';

						if(currow < total) {
							forumsdelete(url, total, pp, currow);
						}
					});
				}
				forumsdelete('admincp.php?action=forums&operation=delete&fid=$fid&confirmed=1', $threads, 2000, 0);
			</script>
			";
		}
	}

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

	require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';

	$source = intval($source);
	$sourceforum = $_DCACHE['forums'][$source];

	if(empty($sourceforum) || $sourceforum['type'] == 'group') {
		cpmsg('forums_copy_source_invalid', '', 'error');
	}

	$optgroups = array
		(
		'normal'	=> array('modnewposts', 'recyclebin', 'allowshare', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowmediacode', 'allowsmilies', 'jammer', 'allowanonymous', 'disablewatermark', 'allowpostspecial'),
		'credits'	=> array('postcredits', 'replycredits'),
		'access'	=> array('password', 'viewperm', 'postperm', 'replyperm', 'getattachperm' ,'postattachperm', 'formulaperm'),
		'misc'		=> array('threadtypes', 'attachextensions', 'modrecommend', 'tradetypes')
		);

	if(!submitcheck('copysubmit')) {

		require_once DISCUZ_ROOT.'./include/forum.func.php';

		$forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect().'</select>';
		$optselect = '<select name="options[]" size="10" multiple="multiple">';

		foreach($optgroups as $optgroup => $options) {
			$optselect .= '<optgroup label="'.$lang['forums_copy_optgroups_'.$optgroup]."\">\n";
			foreach($options as $option) {
				$optselect .= "<option value=\"$option\">".$lang['forums_copy_options_'.$option]."</option>\n";
			}
		}
		$optselect .= '</select>';
		shownav('forum', 'forums_copy');
		showsubmenu('forums_copy');
		showtips('forums_copy_tips');
		showformheader('forums&operation=copy');
		showhiddenfields(array('source' => $source));
		showtableheader();
		showtitle($lang['forums_copy']);
		showsetting(lang('forums_copy_source').':','','', $sourceforum['name']);
		showsetting('forums_copy_target', '', '', $forumselect);
		showsetting('forums_copy_options', '', '', $optselect);
		showsubmit('copysubmit');
		showtablefooter();
		showformfooter();

	} else {

		$fids = $comma = '';
		if(is_array($target) && count($target)) {
			foreach($target as $fid) {
				if(($fid = intval($fid)) && $fid != $source ) {
					$fids .= $comma.$fid;
					$comma = ',';
				}
			}
		}
		if(empty($fids)) {
			cpmsg('forums_copy_target_invalid', '', 'error');
		}

		$forumoptions = array();
		if(is_array($options) && !empty($options)) {
			foreach($options as $option) {
				if($option = trim($option)) {
					if(in_array($option, $optgroups['normal'])) {
						$forumoptions['forums'][] = $option;
					} elseif(in_array($option, $optgroups['misc']) || in_array($option, $optgroups['credits']) || in_array($option, $optgroups['access'])) {
						$forumoptions['forumfields'][] = $option;
					}
				}
			}
		}

		if(empty($forumoptions)) {
			cpmsg('forums_copy_options_invalid', '', 'error');
		}

		foreach(array('forums', 'forumfields') as $table) {
			if(is_array($forumoptions[$table]) && !empty($forumoptions[$table])) {
				$sourceforum = $db->fetch_first("SELECT ".implode($forumoptions[$table],',')." FROM {$tablepre}$table WHERE fid='$source'");
				if(!$sourceforum) {
					cpmsg('forums_copy_source_invalid', '', 'error');
				}

				$updatequery = 'fid=fid';
				foreach($sourceforum as $key => $val) {
					$updatequery .= ", $key='".addslashes($val)."'";
				}
				$db->query("UPDATE {$tablepre}$table SET $updatequery WHERE fid IN ($fids)");
			}
		}

		updatecache('forums');
		cpmsg('forums_copy_succeed', 'admincp.php?action=forums', 'succeed');

	}

}

function showforum($key, $type = '', $last = '') {
	global $forums, $showedforums, $lang, $indexname;

	$forum = $forums[$key];
	$showedforums[] = $key;

	if($last == '') {
		$return = '<tr><td class="td25"><input type="text" class="txt" name="order['.$forum['fid'].']" value="'.$forum['displayorder'].'" /></td><td>';
		if($type == 'group') {
			$return .= '<div class="parentboard">';
		} elseif($type == '') {
			$return .= '<div class="board">';
		} elseif($type == 'sub') {
			$return .= '<div id="cb_'.$forum['fid'].'" class="childboard">';
		}
		$return .= '<input type="text" name="name['.$forum['fid'].']" value="'.htmlspecialchars($f

⌨️ 快捷键说明

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