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

📄 threadtypes.inc.php

📁 论坛代码网增加免费空间业务
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php

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

	$Id: threadtypes.inc.php 13444 2008-04-16 03:12:04Z liuqiang $
*/

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

cpheader();

if(!$operation) {

	if($special) {
		$special = 1;
		$navlang = 'threadtype_infotypes';
		$operation = 'type';
	} else {
		$special = 0;
		$navlang = 'forums_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="admincp.php?action=forums&operation=edit&fid='.$forum['fid'].'&anchor=threadtypes">'.$forum['name'].'</a>';
					$fidsarray[$typeid][] = $forum['fid'];
				}
			}
		}

		if($special) {
			$typemodelopt = '';
			$query = $db->query("SELECT id, name FROM {$tablepre}typemodels ORDER BY displayorder");
			while($typemodel = $db->fetch_array($query)) {
				$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['special'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
			}
		}

		$threadtypes = '';
		$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE ".($special ? "special!='0'" : "special='0'")." ORDER BY displayorder");
		while($type = $db->fetch_array($query)) {
			$threadtypes .= showtablerow('', array('class="td25"', 'class="td28"', '', 'class="td29"', 'title="'.lang('forums_threadtypes_forums_comment').'"', 'class="td25"'), array(
				"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\">",
				"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\">",
				"<input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\">",
				"<input type=\"text\" class=\"txt\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\">",
				is_array($forumsarray[$type['typeid']]) ? '<ul class="nowrap lineheight"><li>'.implode(',</li><li> ', $forumsarray[$type['typeid']])."</li></ul><input type=\"hidden\" name=\"fids[$type[typeid]]\" value=\"".implode(', ', $fidsarray[$type['typeid']])."\">" : '',
				$special ? "<a href=\"admincp.php?action=threadtypes&operation=typedetail&typeid=$type[typeid]\" class=\"act nowrap\">$lang[detail]</a>" : ''
			), TRUE);
		}

?>
<script type="text/JavaScript">
var rowtypedata = [
	[
		[1, '', 'td25'],
		[1, '<input type="text" class="txt" name="newdisplayorder[]" size="2" value="">', 'td28'],
		[1, '<input type="text" class="txt" name="newname[]" size="15">'],
		[1, '<input type="text" class="txt" name="newdescription[]" size="30" value="">', 'td29'],
		[2, '']
	],
];
</script>
<?

		shownav('forum', $navlang);
		showsubmenu($navlang);
		!$special ? showtips('forums_threadtypes_tips') : '';

		showformheader("threadtypes&");
		showhiddenfields(array('special' => $special));
		showtableheader('');
		showsubtitle(array('', 'display_order', 'name', 'description', 'forums_threadtypes_forums', ''));
		echo $threadtypes;

?>
<tr>
<td class="td25"></td>
<td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr"><?=$lang['threadtype_infotypes_add']?></a></div></td>
<?

echo $special ? '<td>&nbsp;</td>' : '<td></td>';

?>
</tr>
<?
		showsubmit('typesubmit', 'submit', 'del');
		showformfooter();

	} else {

		$updatefids = $modifiedtypes = array();

		if(is_array($delete)) {

			$deleteids = implodeids($delete);
			$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE typeid IN ($deleteids)");
			$db->query("DELETE FROM {$tablepre}tradeoptionvars WHERE typeid IN ($deleteids)");
			$db->query("DELETE FROM {$tablepre}typevars WHERE typeid IN ($deleteids)");
			$db->query("DELETE FROM {$tablepre}threadtypes WHERE typeid IN ($deleteids) AND special='$special'");

			if($db->affected_rows()) {
				$db->query("UPDATE {$tablepre}threads SET typeid='0' WHERE typeid IN ($deleteids)");
				foreach($delete as $id) {
					if(is_array($namenew) && isset($namenew[$id])) {
						unset($namenew[$id]);
					}
					if(!empty($fids[$id])) {
						foreach(explode(',', $fids[$id]) as $fid) {
							if($fid = intval($fid)) {
								$updatefids[$fid]['deletedids'][] = intval($id);
							}
						}
					}
				}
			}
		}

		if(is_array($namenew) && $namenew) {
			foreach($namenew as $typeid => $val) {
				$db->query("UPDATE {$tablepre}threadtypes SET name='".trim($namenew[$typeid])."', description='".dhtmlspecialchars(trim($descriptionnew[$typeid]))."', displayorder='$displayordernew[$typeid]', special='$special' WHERE typeid='$typeid'");
				if($db->affected_rows()) {
					$modifiedtypes[] = $typeid;
				}
			}

			if($modifiedtypes = array_unique($modifiedtypes)) {
				foreach($modifiedtypes as $id) {
					if(!empty($fids[$id])) {
						foreach(explode(',', $fids[$id]) as $fid) {
							if($fid = intval($fid)) {
								$updatefids[$fid]['modifiedids'][] = $id;
							}
						}
					}
				}
			}
		}

		if($updatefids) {
			$query = $db->query("SELECT fid, threadtypes FROM {$tablepre}forumfields WHERE fid IN (".implodeids(array_keys($updatefids)).") AND threadtypes<>''");
			while($forum = $db->fetch_array($query)) {
				$fid = $forum['fid'];
				$forum['threadtypes'] = unserialize($forum['threadtypes']);
				if($updatefids[$fid]['deletedids']) {
					foreach($updatefids[$fid]['deletedids'] as $id) {
						unset($forum['threadtypes']['types'][$id], $forum['threadtypes']['flat'][$id], $forum['threadtypes']['selectbox'][$id]);
					}
				}
				if($updatefids[$fid]['modifiedids']) {
					foreach($updatefids[$fid]['modifiedids'] as $id) {
						if(isset($forum['threadtypes']['types'][$id])) {
							$namenew[$id] = trim($namenew[$id]);
							$forum['threadtypes']['types'][$id] = $namenew[$id];
							if(isset($forum['threadtypes']['selectbox'][$id])) {
								$forum['threadtypes']['selectbox'][$id] = $namenew[$id];
							} else {
								$forum['threadtypes']['flat'][$id] = $namenew[$id];
							}
						}
					}
				}
				$db->query("UPDATE {$tablepre}forumfields SET threadtypes='".addslashes(serialize($forum['threadtypes']))."' WHERE fid='$fid'");
			}
		}

		if(is_array($newname)) {
			foreach($newname as $key => $value) {
				if($newname1 = trim($value)) {
					$query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$newname1'");
					if($db->num_rows($query)) {
						cpmsg('forums_threadtypes_duplicate', '', 'error');
					}
					$db->query("INSERT INTO	{$tablepre}threadtypes (name, description, displayorder, special) VALUES
							('$newname1', '".dhtmlspecialchars(trim($newdescription[$key]))."', '$newdisplayorder[$key]', '$special')");
				}
			}
		}

		cpmsg('forums_threadtypes_succeed', 'admincp.php?action=threadtypes&special='.$special, 'succeed');

	}

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

	if(!submitcheck('typeoptionsubmit')) {

		$classid = $classid ? intval($classid) : $db->result_first("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder LIMIT 1");
		$classoptions = array();
		$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder");
		while($option = $db->fetch_array($query)) {
			$classoptions[] = array($option[title], "threadtypes&operation=typeoption&classid=$option[optionid]", $classid == $option[optionid]);
		}

		if($classid) {
			if(!$typetitle = $db->result_first("SELECT title FROM {$tablepre}typeoptions WHERE optionid='$classid'")) {
				cpmsg('threadtype_infotypes_noexist', 'admincp.php?action=threadtypes', 'error');
			}

			$typeoptions = '';
			$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
			while($option = $db->fetch_array($query)) {
				$option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
				$typeoptions .= showtablerow('', array('class="td25"', 'class="td28"'), array(
					"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\">",
					"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
					"<input type=\"text\" class=\"txt\" size=\"15\" name=\"title[$option[optionid]]\" value=\"".dhtmlspecialchars($option['title'])."\">",
					"$option[identifier]<input type=\"hidden\" name=\"identifier[$option[optionid]]\" value=\"$option[identifier]\">",
					$option['type'],
					"<a href=\"admincp.php?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">$lang[detail]</a>"
				), TRUE);
			}
		}

		echo <<<EOT
<script type="text/JavaScript">
	var rowtypedata = [
		[
			[1, '', 'td25'],
			[1, '<input type="text" class="txt" size="2" name="newdisplayorder[]" value="0">', 'td28'],
			[1, '<input type="text" class="txt" size="15" name="newtitle[]">'],
			[1, '<input type="text" class="txt" size="15" name="newidentifier[]">'],
			[1, '<select name="newtype[]"><option value="number">$lang[threadtype_edit_vars_type_number]</option><option value="text" selected>$lang[threadtype_edit_vars_type_text]</option><option value="textarea">$lang[threadtype_edit_vars_type_textarea]</option><option value="radio">$lang[threadtype_edit_vars_type_radio]</option><option value="checkbox">$lang[threadtype_edit_vars_type_checkbox]</option><option value="select">$lang[threadtype_edit_vars_type_select]</option><option value="calendar">$lang[threadtype_edit_vars_type_calendar]</option><option value="email">$lang[threadtype_edit_vars_type_email]</option><option value="image">$lang[threadtype_edit_vars_type_image]</option><option value="url">$lang[threadtype_edit_vars_type_url]</option></select>'],
			[1, '']
		],
	];
</script>
EOT;
		shownav('forum', 'threadtype_infotypes_option');
		showsubmenu('threadtype_cat_manage', $classoptions);
		showformheader("threadtypes&operation=typeoption&typeid=$typeid");
		showhiddenfields(array('classid' => $classid));
		showtableheader();

		showsubtitle(array('', 'display_order', 'name', 'threadtype_variable', 'threadtype_type', ''));
		echo $typeoptions;
		echo '<tr><td></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['threadtype_infotypes_add_option'].'</a></div></td></tr>';
		showsubmit('typeoptionsubmit', 'submit', 'del');

		showtablefooter();
		showformfooter();

	} else {

		if($ids = implodeids($delete)) {
			$db->query("DELETE FROM {$tablepre}typeoptions WHERE optionid IN ($ids)");
		}

		if(is_array($title)) {
			foreach($title as $id => $val) {
				$db->query("UPDATE {$tablepre}typeoptions SET displayorder='$displayorder[$id]', title='$title[$id]', identifier='$identifier[$id]' WHERE optionid='$id'");
			}
		}

		if(is_array($newtitle)) {
			foreach($newtitle as $key => $value) {
				$newtitle1 = dhtmlspecialchars(trim($value));
				$newidentifier1 = trim($newidentifier[$key]);
				if($newtitle1 && $newidentifier1) {
					$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$newidentifier1' LIMIT 1");
					if($db->num_rows($query) || strlen($newidentifier1) > 40  || !ispluginkey($newidentifier1)) {
						cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
					}
					$db->query("INSERT INTO {$tablepre}typeoptions (classid, displayorder, title, identifier, type)
						VALUES ('$classid', '$newdisplayorder[$key]', '$newtitle1', '$newidentifier1', '$newtype[$key]')");
				} elseif($newtitle1 && !$newidentifier1) {
					cpmsg('threadtype_infotypes_option_invalid', 'admincp.php?action=threadtypes&operation=typeoption&classid='.$classid, 'error');
				}

⌨️ 快捷键说明

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