PageRenderTime 37ms CodeModel.GetById 4ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 2ms

/source/admincp/admincp_forums.php

https://github.com/kuaileshike/upload
PHP | 2132 lines | 2037 code | 89 blank | 6 comment | 188 complexity | e6434f688b192061a19a56355c706540 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2
   3/**
   4 *      [Discuz!] (C)2001-2099 Comsenz Inc.
   5 *      This is NOT a freeware, use is subject to license terms
   6 *
   7 *      $Id: admincp_forums.php 31327 2012-08-13 07:01:41Z liulanbo $
   8 */
   9
  10if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  11	exit('Access Denied');
  12}
  13
  14cpheader();
  15
  16$operation = empty($operation) ? 'admin' : $operation;
  17$fid = getgpc('fid');
  18
  19if($operation == 'admin') {
  20
  21	if(!submitcheck('editsubmit')) {
  22		shownav('forum', 'forums_admin');
  23		showsubmenu('forums_admin');
  24		showtips('forums_admin_tips');
  25
  26		require_once libfile('function/forumlist');
  27		$forums = str_replace("'", "\'", forumselect(false, 0, 0, 1));
  28
  29?>
  30<script type="text/JavaScript">
  31var forumselect = '<?php echo $forums;?>';
  32var rowtypedata = [
  33	[[1, ''], [1,'<input type="text" class="txt" name="newcatorder[]" value="0" />', 'td25'], [5, '<div><input name="newcat[]" value="<?php cplang('forums_admin_add_category_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a></div>']],
  34	[[1, ''], [1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [5, '<div class="board"><input name="newforum[{1}][]" value="<?php cplang('forums_admin_add_forum_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a><select name="newinherited[{1}][]"><option value=""><?php cplang('forums_edit_newinherited', null, true);?></option>' + forumselect + '</select></div>']],
  35	[[1, ''], [1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [5, '<div class="childboard"><input name="newforum[{1}][]" value="<?php cplang('forums_admin_add_forum_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a>&nbsp;<label><input name="inherited[{1}][]" type="checkbox" class="checkbox" value="1">&nbsp;<?php cplang('forums_edit_inherited', null, true);?></label></div>']],
  36];
  37</script>
  38<?php
  39		showformheader('forums');
  40		echo '<div style="height:30px;line-height:30px;"><a href="javascript:;" onclick="show_all()">'.cplang('show_all').'</a> | <a href="javascript:;" onclick="hide_all()">'.cplang('hide_all').'</a> <input type="text" id="srchforumipt" class="txt" /> <input type="submit" class="btn" value="'.cplang('search').'" onclick="return srchforum()" /></div>';
  41		showtableheader('');
  42		showsubtitle(array('', 'display_order', 'forums_admin_name', '', 'forums_moderators', '<a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>'));
  43
  44		$forumcount = C::t('forum_forum')->fetch_forum_num();
  45
  46		$query = C::t('forum_forum')->fetch_all_forum_for_sub_order();
  47		$groups = $forums = $subs = $fids = $showed = array();
  48		foreach($query as $forum) {
  49			if($forum['type'] == 'group') {
  50				$groups[$forum['fid']] = $forum;
  51			} elseif($forum['type'] == 'sub') {
  52				$subs[$forum['fup']][] = $forum;
  53			} else {
  54				$forums[$forum['fup']][] = $forum;
  55			}
  56			$fids[] = $forum['fid'];
  57		}
  58
  59		foreach ($groups as $id => $gforum) {
  60			$toggle = $forumcount > 50 && count($forums[$id]) > 2;
  61			$showed[] = showforum($gforum, 'group', '', $toggle);
  62			if(!empty($forums[$id])) {
  63				foreach ($forums[$id] as $forum) {
  64					$showed[] = showforum($forum);
  65					$lastfid = 0;
  66					if(!empty($subs[$forum['fid']])) {
  67						foreach ($subs[$forum['fid']] as $sub) {
  68							$showed[] = showforum($sub, 'sub');
  69							$lastfid = $sub['fid'];
  70						}
  71					}
  72					showforum($forum, $lastfid, 'lastchildboard');
  73				}
  74			}
  75			showforum($gforum, '', 'lastboard');
  76		}
  77
  78		if(count($fids) != count($showed)) {
  79			foreach($fids as $fid) {
  80				if(!in_array($fid, $showed)) {
  81					C::t('forum_forum')->update($fid, array('fup' => '0', 'type' => 'forum'));
  82				}
  83			}
  84		}
  85
  86		showforum($gforum, '', 'last');
  87
  88		showsubmit('editsubmit');
  89		showtablefooter();
  90		showformfooter();
  91
  92	} else {
  93		$usergroups = array();
  94		$query = C::t('common_usergroup')->range();
  95		foreach($query as $group) {
  96			$usergroups[$group['groupid']] = $group;
  97		}
  98
  99		if(is_array($_GET['order'])) {
 100			foreach($_GET['order'] as $fid => $value) {
 101				C::t('forum_forum')->update($fid, array('name' => $_GET['name'][$fid], 'displayorder' => $_GET['order'][$fid]));
 102			}
 103		}
 104
 105		if(is_array($_GET['newcat'])) {
 106			foreach($_GET['newcat'] as $key => $forumname) {
 107				if(empty($forumname)) {
 108					continue;
 109				}
 110				$fid = C::t('forum_forum')->insert(array('type' => 'group', 'name' => $forumname, 'status' => 1, 'displayorder' => $_GET['newcatorder'][$key]), 1);
 111				C::t('forum_forumfield')->insert(array('fid' => $fid));
 112			}
 113		}
 114
 115		$table_forum_columns = array('fup', 'type', 'name', 'status', 'displayorder', 'styleid', 'allowsmilies',
 116			'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowpostspecial', 'alloweditrules',
 117			'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'disablethumb',
 118			'autoclose', 'simple', 'allowside', 'allowfeed');
 119		$table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'viewperm', 'postperm', 'replyperm',
 120			'getattachperm', 'postattachperm', 'postimageperm');
 121
 122		if(is_array($_GET['newforum'])) {
 123
 124			foreach($_GET['newforum'] as $fup => $forums) {
 125
 126				$fupforum = C::t('forum_forum')->get_forum_by_fid($fup);
 127				if(empty($fupforum)) continue;
 128
 129				if($fupforum['fup']) {
 130					$groupforum = C::t('forum_forum')->get_forum_by_fid($fupforum['fup']);
 131				} else {
 132					$groupforum = $fupforum;
 133				}
 134
 135				foreach($forums as $key => $forumname) {
 136
 137					if(empty($forumname) || strlen($forumname) > 50) continue;
 138
 139					$forum = $forumfields = array();
 140					$inheritedid = !empty($_GET['inherited'][$fup]) ? $fup : (!empty($_GET['newinherited'][$fup][$key]) ? $_GET['newinherited'][$fup][$key] : '');
 141
 142					if(!empty($inheritedid)) {
 143
 144						$forum = C::t('forum_forum')->get_forum_by_fid($inheritedid);
 145						$forumfield =  C::t('forum_forum')->get_forum_by_fid($inheritedid, null, 'forumfield');
 146
 147						foreach($table_forum_columns as $field) {
 148							$forumfields[$field] = $forum[$field];
 149						}
 150
 151						foreach($table_forumfield_columns as $field) {
 152							$forumfields[$field] = $forumfield[$field];
 153						}
 154
 155					} else {
 156						$forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = 1;
 157						$forumfields['allowpostspecial'] = 1;
 158						$forumfields['allowside'] = 0;
 159						$forumfields['allowfeed'] = 0;
 160						$forumfields['recyclebin'] = 1;
 161					}
 162
 163					$forumfields['fup'] = $fup ? $fup : 0;
 164					$forumfields['type'] = $fupforum['type'] == 'forum' ? 'sub' : 'forum';
 165					$forumfields['styleid'] = $groupforum['styleid'];
 166					$forumfields['name'] = $forumname;
 167					$forumfields['status'] = 1;
 168					$forumfields['displayorder'] = $_GET['neworder'][$fup][$key];
 169
 170					$data = array();
 171					foreach($table_forum_columns as $field) {
 172						if(isset($forumfields[$field])) {
 173							$data[$field] = $forumfields[$field];
 174						}
 175					}
 176
 177					$forumfields['fid'] = $fid = C::t('forum_forum')->insert($data, 1);
 178
 179					$data = array();
 180					$forumfields['threadtypes'] = copy_threadclasses($forumfields['threadtypes'], $fid);
 181					foreach($table_forumfield_columns as $field) {
 182						if(isset($forumfields[$field])) {
 183							$data[$field] = $forumfields[$field];
 184						}
 185					}
 186
 187					C::t('forum_forumfield')->insert($data);
 188
 189					foreach(C::t('forum_moderator')->fetch_all_by_fid($fup, false) as $mod) {
 190						if($mod['inherited'] || $fupforum['inheritedmod']) {
 191							C::t('forum_moderator')->insert(array('uid' => $mod['uid'], 'fid' => $fid, 'inherited' => 1), false, true);
 192						}
 193					}
 194				}
 195			}
 196		}
 197
 198
 199		updatecache('forums');
 200
 201		cpmsg('forums_update_succeed', 'action=forums', 'succeed');
 202	}
 203
 204} elseif($operation == 'moderators' && $fid) {
 205
 206	if(!submitcheck('modsubmit')) {
 207
 208		$forum = C::t('forum_forum')->fetch($fid);
 209		shownav('forum', 'forums_moderators_edit');
 210		showsubmenu(cplang('forums_moderators_edit').' - '.$forum['name']);
 211		showtips('forums_moderators_tips');
 212		showformheader("forums&operation=moderators&fid=$fid&");
 213		showtableheader('', 'fixpadding');
 214		showsubtitle(array('', 'display_order', 'username', 'usergroups', 'forums_moderators_inherited'));
 215
 216		$modgroups = C::t('common_admingroup')->fetch_all_merge_usergroup(array_keys(C::t('common_usergroup')->fetch_all_by_radminid(0)));
 217		$groupselect = '<select name="newgroup">';
 218		foreach($modgroups as $modgroup) {
 219			if($modgroup['radminid'] == 3) {
 220				$groupselect .= '<option value="'.$modgroup['admingid'].'">'.$modgroup['grouptitle'].'</option>';
 221			}
 222			$modgroups[$modgroup['admingid']] = $modgroup['grouptitle'];
 223		}
 224		$groupselect .= '</select>';
 225
 226		$moderators = C::t('forum_moderator')->fetch_all_by_fid($fid);
 227		$uids = array_keys($moderators);
 228		if($uids) {
 229			$users = C::t('common_member')->fetch_all($uids);
 230		}
 231
 232		foreach($moderators as $mod) {
 233			showtablerow('', array('class="td25"', 'class="td28"'), array(
 234				'<input type="checkbox" class="checkbox" name="delete[]" value="'.$mod[uid].'"'.($mod['inherited'] ? ' disabled' : '').' />',
 235				'<input type="text" class="txt" name="displayordernew['.$mod[uid].']" value="'.$mod[displayorder].'" size="2" />',
 236				"<a href=\"".ADMINSCRIPT."?mod=forum&action=members&operation=group&uid=$mod[uid]\" target=\"_blank\">{$users[$mod['uid']]['username']}</a>",
 237				$modgroups[$users[$mod['uid']]['groupid']],
 238				cplang($mod['inherited'] ? 'yes' : 'no'),
 239			));
 240		}
 241
 242		if($forum['type'] == 'group' || $forum['type'] == 'sub') {
 243			$checked = $forum['type'] == 'group' ? 'checked' : '';
 244			$disabled = 'disabled';
 245		} else {
 246			$checked = $forum['inheritedmod'] ? 'checked' : '';
 247			$disabled = '';
 248		}
 249
 250		showtablerow('', array('class="td25"', 'class="td28"'), array(
 251			cplang('add_new'),
 252			'<input type="text" class="txt" name="newdisplayorder" value="0" size="2" />',
 253			'<input type="text" class="txt" name="newmoderator" value="" size="20" />',
 254			$groupselect,
 255			''
 256		));
 257
 258		showsubmit('modsubmit', 'submit', 'del', '<input class="checkbox" type="checkbox" name="inheritedmodnew" value="1" '.$checked.' '.$disabled.' id="inheritedmodnew" /><label for="inheritedmodnew">'.cplang('forums_moderators_inherit').'</label>');
 259		showtablefooter();
 260		showformfooter();
 261
 262	} else {
 263		$forum = C::t('forum_forum')->fetch($fid);
 264		$inheritedmodnew = $_GET['inheritedmodnew'];
 265		if($forum['type'] == 'group') {
 266			$inheritedmodnew = 1;
 267		} elseif($forum['type'] == 'sub') {
 268			$inheritedmodnew = 0;
 269		}
 270
 271		if(!empty($_GET['delete']) || $_GET['newmoderator'] || (bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
 272
 273			$fidarray = $newmodarray = $origmodarray = array();
 274
 275			if($forum['type'] == 'group') {
 276				$query = C::t('forum_forum')->fetch_all_fids(1, 'forum', $fid);
 277				foreach($query as $sub) {
 278					$fidarray[] = $sub['fid'];
 279				}
 280				$query = C::t('forum_forum')->fetch_all_fids(1, 'sub', $fidarray);
 281				foreach($query as $sub) {
 282					$fidarray[] = $sub['fid'];
 283				}
 284			} elseif($forum['type'] == 'forum') {
 285				$query = C::t('forum_forum')->fetch_all_fids(1, 'sub', $fid);
 286				foreach($query as $sub) {
 287					$fidarray[] = $sub['fid'];
 288				}
 289			}
 290
 291			if(is_array($_GET['delete'])) {
 292				foreach($_GET['delete'] as $uid) {
 293					C::t('forum_moderator')->delete_by_uid_fid_inherited($uid, $fid, $fidarray);
 294				}
 295
 296				$excludeuids = array();
 297				$deleteuids = '\''.implode('\',\'', $_GET['delete']).'\'';
 298				foreach(C::t('forum_moderator')->fetch_all_by_uid($_GET['delete']) as $mod) {
 299					$excludeuids[] = $mod['uid'];
 300				}
 301
 302				$usergroups = array();
 303				$query = C::t('common_usergroup')->range();
 304				foreach($query as $group) {
 305					$usergroups[$group['groupid']] = $group;
 306				}
 307
 308				$members = C::t('common_member')->fetch_all($_GET['delete'], false, 0);
 309				foreach($members as $uid => $member) {
 310					if(!in_array($uid, $excludeuids) && !in_array($member['adminid'], array(1,2))) {
 311						if($usergroups[$member['groupid']]['type'] == 'special' && $usergroups[$member['groupid']]['radminid'] != 3) {
 312							$adminidnew = -1;
 313							$groupidnew = $member['groupid'];
 314						} else {
 315							$adminidnew = 0;
 316							foreach($usergroups as $group) {
 317								if($group['type'] == 'member' && $member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) {
 318									$groupidnew = $group['groupid'];
 319									break;
 320								}
 321							}
 322						}
 323						C::t('common_member')->update($member['uid'], array('adminid'=>$adminidnew, 'groupid'=>$groupidnew));
 324					}
 325				}
 326			}
 327
 328			if($_GET['newmoderator']) {
 329				$member = C::t('common_member')->fetch_by_username($_GET['newmoderator']);
 330				if(!$member) {
 331					cpmsg_error('members_edit_nonexistence');
 332				} else {
 333					$newmodarray[] = $member['uid'];
 334					$membersetarr = array();
 335					if(!in_array($member['adminid'],array(1,2,3,4,5,6,7,8,-1))) {
 336						$membersetarr['groupid'] = $_GET['newgroup'];
 337					}
 338					if(!in_array($member['adminid'],array(1,2))) {
 339						$membersetarr['adminid'] = '3';
 340					}
 341					if(!empty($membersetarr)) {
 342						C::t('common_member')->update($member['uid'], $membersetarr);
 343					}
 344
 345					C::t('forum_moderator')->insert(array(
 346						'uid' => $member['uid'],
 347						'fid' => $fid,
 348						'displayorder' => $_GET['newdisplayorder'],
 349						'inherited' => '0',
 350					), false, true);
 351				}
 352			}
 353
 354			if((bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
 355				foreach(C::t('forum_moderator')->fetch_all_by_fid_inherited($fid) as $mod) {
 356					$origmodarray[] = $mod['uid'];
 357					if(!$forum['inheritedmod'] && $inheritedmodnew) {
 358						$newmodarray[] = $mod['uid'];
 359					}
 360				}
 361				if($forum['inheritedmod'] && !$inheritedmodnew) {
 362					C::t('forum_moderator')->delete_by_uid_fid($origmodarray, $fidarray);
 363				}
 364			}
 365
 366			foreach($newmodarray as $uid) {
 367				C::t('forum_moderator')->insert(array(
 368					'uid' => $uid,
 369					'fid' => $fid,
 370					'displayorder' => $_GET['newdisplayorder'],
 371					'inherited' => '0',
 372				), false, true);
 373
 374				if($inheritedmodnew) {
 375					foreach($fidarray as $ifid) {
 376						C::t('forum_moderator')->insert(array(
 377							'uid' => $uid,
 378							'fid' => $ifid,
 379							'inherited' => '1',
 380						), false, true);
 381					}
 382				}
 383			}
 384
 385			if($forum['type'] == 'group') {
 386				$inheritedmodnew = 1;
 387			} elseif($forum['type'] == 'sub') {
 388				$inheritedmodnew = 0;
 389			}
 390			C::t('forum_forum')->update($fid, array('inheritedmod' => $inheritedmodnew));
 391		}
 392
 393		if(is_array($_GET['displayordernew'])) {
 394			foreach($_GET['displayordernew'] as $uid => $order) {
 395				C::t('forum_moderator')->update_by_fid_uid($fid, $uid, array(
 396					'displayorder' => $order,
 397				));
 398			}
 399		}
 400
 401		$fidarray[] = $fid;
 402		foreach($fidarray as $fid) {
 403			$moderators = $tab = '';
 404			$modorder = array();
 405			$modmemberarray = C::t('forum_moderator')->fetch_all_no_inherited_by_fid($fid);
 406			foreach($modmemberarray as $moduid => $modmember) {
 407				$modorder[] = $moduid;
 408			}
 409			$members = C::t('common_member')->fetch_all_username_by_uid($modorder);
 410			foreach($modorder as $mod) {
 411				if(!$members[$mod]) {
 412					continue;
 413				}
 414				$moderators .= $tab.addslashes($members[$mod]);
 415				$tab = "\t";
 416			}
 417
 418			C::t('forum_forumfield')->update($fid, array('moderators' => $moderators));
 419		}
 420		cpmsg('forums_moderators_update_succeed', "mod=forum&action=forums&operation=moderators&fid=$fid", 'succeed');
 421
 422	}
 423
 424} elseif($operation == 'merge') {
 425	$source = $_GET['source'];
 426	$target = $_GET['target'];
 427	if(!submitcheck('mergesubmit') || $source == $target) {
 428
 429		require_once libfile('function/forumlist');
 430		loadcache('forums');
 431		$forumselect = "<select name=\"%s\">\n<option value=\"\">&nbsp;&nbsp;> ".cplang('select')."</option><option value=\"\">&nbsp;</option>".str_replace('%', '%%', forumselect(FALSE, 0, 0, TRUE)).'</select>';
 432		shownav('forum', 'forums_merge');
 433		showsubmenu('forums_merge');
 434		showformheader('forums&operation=merge');
 435		showtableheader();
 436		showsetting('forums_merge_source', '', '', sprintf($forumselect, 'source'));
 437		showsetting('forums_merge_target', '', '', sprintf($forumselect, 'target'));
 438		showsubmit('mergesubmit');
 439		showtablefooter();
 440		showformfooter();
 441
 442	} else {
 443		if(C::t('forum_forum')->check_forum_exists(array($source,$target)) != 2) {
 444			cpmsg_error('forums_nonexistence');
 445		}
 446		if(C::t('forum_forum')->fetch_forum_num('', $source)) {
 447			cpmsg_error('forums_merge_source_sub_notnull');
 448		}
 449
 450		C::t('forum_thread')->update_by_fid($source, array('fid' => $target));
 451		loadcache('posttableids');
 452		$posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
 453		foreach($posttableids as $id) {
 454			C::t('forum_post')->update_fid_by_fid($id, $source, $target);
 455		}
 456
 457		$sourceforum = C::t('forum_forum')->fetch_info_by_fid($source);
 458		$targetforum = C::t('forum_forum')->fetch_info_by_fid($target);
 459		$sourcethreadtypes = (array)dunserialize($sourceforum['threadtypes']);
 460		$targethreadtypes = (array)dunserialize($targetforum['threadtypes']);
 461		$targethreadtypes['types'] = array_merge((array)$targethreadtypes['types'], (array)$sourcethreadtypes['types']);
 462		$targethreadtypes['icons'] = array_merge((array)$targethreadtypes['icons'], (array)$sourcethreadtypes['icons']);
 463		C::t('forum_forum')->update($target, array('threads' => $targetforum['threads'] + $sourceforum['threads'], 'posts' => $targetforum['posts'] + $sourceforum['posts']));
 464		C::t('forum_forumfield')->update($target, array('threadtypes' => serialize($targethreadtypes)));
 465		C::t('forum_threadclass')->update_by_fid($source, array('fid' => $target));
 466		C::t('forum_forum')->delete_by_fid($source);
 467		C::t('home_favorite')->delete_by_id_idtype($source, 'fid');
 468		C::t('forum_moderator')->delete_by_fid($source);
 469
 470		$log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
 471		$log_handler->myThreadLog('mergeforum', array('fid' => $source, 'otherid' => $target));
 472
 473		$query = C::t('forum_access')->fetch_all_by_fid_uid($source);
 474		foreach($query as $access) {
 475			C::t('forum_access')->insert(array('uid' => $access['uid'], 'fid' => $target, 'allowview' => $access['allowview'], 'allowpost' => $access['allowpost'], 'allowreply' => $access['allowreply'], 'allowgetattach' => $access['allowgetattach']));
 476		}
 477		C::t('forum_access')->delete_by_fid($source);
 478		C::t('forum_thread')->clear_cache(array($source,$target), 'forumdisplay_');
 479		updatecache('forums');
 480
 481		cpmsg('forums_merge_succeed', 'action=forums', 'succeed');
 482	}
 483
 484} elseif($operation == 'edit') {
 485
 486	require_once libfile('function/forumlist');
 487	require_once libfile('function/domain');
 488	$highlight = getgpc('highlight');
 489	$anchor = getgpc('anchor');
 490
 491	list($pluginsetting, $pluginvalue) = get_pluginsetting('forums');
 492
 493	$multiset = 0;
 494	if(empty($_GET['multi'])) {
 495		$fids = $fid;
 496	} else {
 497		$multiset = 1;
 498		if(is_array($_GET['multi'])) {
 499			$fids = $_GET['multi'];
 500		} else {
 501			$_GET['multi'] = explode(',', $_GET['multi']);
 502			$fids = &$_GET['multi'];
 503		}
 504	}
 505	if(count($_GET['multi']) == 1) {
 506		$fids = $_GET['multi'][0];
 507		$multiset = 0;
 508	}
 509	if(empty($fids)) {
 510		cpmsg('forums_edit_nonexistence', 'action=forums&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($anchor) ? "&anchor=$anchor" : ''), 'form', array(), '<select name="fid">'.forumselect(FALSE, 0, 0, TRUE).'</select>');
 511	}
 512	$mforum = array();
 513	$perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm', 'postimageperm');
 514
 515	$query = C::t('forum_forum')->fetch_all_info_by_fids($fids);
 516	if(empty($query)) {
 517		cpmsg('forums_nonexistence', '', 'error');
 518	} else {
 519		foreach($query as $forum) {
 520			if(isset($pluginvalue[$forum['fid']])) {
 521				$forum['plugin'] = $pluginvalue[$forum['fid']];
 522			}
 523			$mforum[] = $forum;
 524		}
 525	}
 526
 527	$dactionarray = array();
 528	$allowthreadtypes = !in_array('threadtypes', $dactionarray);
 529
 530
 531	$forumkeys = C::t('common_setting')->fetch('forumkeys', true);
 532
 533	$rules = array();
 534	foreach(C::t('common_credit_rule')->fetch_all_by_action(array('reply', 'post', 'digest', 'postattach', 'getattach')) as $value) {
 535		$rules[$value['rid']] = $value;
 536	}
 537
 538	if(!submitcheck('detailsubmit')) {
 539		$anchor = in_array($_GET['anchor'], array('basic', 'extend', 'posts', 'attachtype', 'credits', 'threadtypes', 'threadsorts', 'perm', 'plugin')) ? $_GET['anchor'] : 'basic';
 540		shownav('forum', 'forums_edit');
 541
 542		loadcache('forums');
 543		$forumselect = '';
 544		$sgid = 0;
 545		foreach($_G['cache']['forums'] as $forums) {
 546			$checked = $fid == $forums['fid'] || in_array($forums['fid'], $_GET['multi']);
 547			if($forums['type'] == 'group') {
 548				$sgid = $forums['fid'];
 549				$forumselect .= '</div><em class="cl">'.
 550					'<span class="right"><input name="checkall_'.$forums['fid'].'" onclick="checkAll(\'value\', this.form, '.$forums['fid'].', \'checkall_'.$forums['fid'].'\')" type="checkbox" class="vmiddle checkbox" /></span>'.
 551					'<span class="pointer" onclick="sdisplay(\'g_'.$forums['fid'].'\', this)"><img src="static/image/admincp/desc.gif" class="vmiddle" /></span> <span class="pointer" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].'\'">'.$forums['name'].'</span></em><div id="g_'.$forums['fid'].'" style="display:">';
 552			} elseif($forums['type'] == 'forum') {
 553				$forumselect .= '<input class="left checkbox ck" chkvalue="'.$sgid.'" name="multi[]" value="'.$forums['fid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/><a class="f'.($checked ? ' current"' : '').'" href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($mforum[0]['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+scrollTopBody()">'.$forums['name'].'</a>';
 554			} elseif($forums['type'] == 'sub') {
 555				$forumselect .= '<input class="left checkbox ck" chkvalue="'.$sgid.'" name="multi[]" value="'.$forums['fid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/><a class="s'.($checked ? ' current"' : '').'" href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($mforum[0]['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+scrollTopBody()">'.$forums['name'].'</a>';
 556			}
 557		}
 558		$forumselect = '<span id="fselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'fselect_menu\').style.top=(parseInt($(\'fselect_menu\').style.top)-scrollTopBody())+\'px\';$(\'fselect_menu\').style.left=(parseInt($(\'fselect_menu\').style.left)-document.documentElement.scrollLeft-20)+\'px\'">'.cplang('forums_edit_switch').'<em>&nbsp;&nbsp;</em></span>'.
 559			'<div id="fselect_menu" class="popupmenu_popup" style="display:none"><div class="fsel"><div>'.$forumselect.'</div></div><div class="cl"><input type="button" class="btn right" onclick="$(\'menuform\').submit()" value="'.cplang('forums_multiedit').'" /></div></div>';
 560
 561		showformheader('', '', 'menuform', 'get');
 562		showhiddenfields(array('action' => 'forums', 'operation' => 'edit'));
 563		if(count($mforum) == 1 && $mforum[0]['type'] == 'group') {
 564			showsubmenu(cplang('forums_cat_detail').(count($mforum) == 1 ? ' - '.$mforum[0]['name'].'(gid:'.$mforum[0]['fid'].')' : ''), array(), $forumselect);
 565		} else {
 566			if($multiset && !in_array($anchor, array('basic', 'extend', 'posts', 'perm', 'plugin'))) {
 567				$anchor = 'basic';
 568			}
 569			showsubmenuanchors(cplang('forums_edit').(count($mforum) == 1 ? ' - '.$mforum[0]['name'].'(fid:'.$mforum[0]['fid'].')' : ''), array(
 570				array('forums_edit_basic', 'basic', $anchor == 'basic'),
 571				array('forums_edit_extend', 'extend', $anchor == 'extend'),
 572				array('forums_edit_posts', 'posts', $anchor == 'posts'),
 573				array('forums_edit_perm', 'perm', $anchor == 'perm'),
 574				!$multiset ? array('forums_edit_credits', 'credits', $anchor == 'credits') : array(),
 575				!$multiset ? array(array('menu' => 'usergroups_edit_other', 'submenu' => array(
 576					array('forums_edit_threadtypes', 'threadtypes', $anchor == 'threadtypes'),
 577					array('forums_edit_threadsorts', 'threadsorts', $anchor == 'threadsorts'),
 578					!$multiset ? array('forums_edit_attachtype', 'attachtype', $anchor == 'attachtype') : array(),
 579					!$pluginsetting ? array() : array('forums_edit_plugin', 'plugin', $anchor == 'plugin'),
 580				))) : array(),
 581				$multiset && $pluginsetting ? array('forums_edit_plugin', 'plugin', $anchor == 'plugin') : array(),
 582			), $forumselect);
 583		}
 584		showformfooter();
 585
 586		$groups = array();
 587		$query = C::t('common_usergroup')->range_orderby_credit();
 588		foreach($query as $group) {
 589			$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
 590			$groups[$group['type']][] = $group;
 591		}
 592
 593		$styleselect = "<select name=\"styleidnew\"><option value=\"0\">$lang[use_default]</option>";
 594		foreach(C::t('common_style')->fetch_all_data(false, false) as $style) {
 595			$styleselect .= "<option value=\"$style[styleid]\" ".
 596				($style['styleid'] == $mforum[0]['styleid'] ? 'selected="selected"' : NULL).
 597				">$style[name]</option>\n";
 598		}
 599		$styleselect .= '</select>';
 600
 601		if(!$multiset) {
 602			$attachtypes = '';
 603			foreach(C::t('forum_attachtype')->fetch_all_by_fid($fid) as $type) {
 604				$type['maxsize'] = round($type['maxsize'] / 1024);
 605				$attachtypes .= showtablerow('', array('class="td25"', 'class="td24"'), array(
 606					"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[id]\" />",
 607					"<input type=\"text\" class=\"txt\" size=\"10\" name=\"extension[$type[id]]\" value=\"$type[extension]\" />",
 608					"<input type=\"text\" class=\"txt\" size=\"15\" name=\"maxsize[$type[id]]\" value=\"$type[maxsize]\" />"
 609				), TRUE);
 610			}
 611		} else {
 612			showtips('setting_multi_tips');
 613		}
 614		showformheader("forums&operation=edit&fid=$fid&", 'enctype');
 615		showhiddenfields(array('type' => $mforum[0]['type']));
 616
 617		if(count($mforum) == 1 && $mforum[0]['type'] == 'group') {
 618			$mforum[0]['extra'] = dunserialize($mforum[0]['extra']);
 619			showtableheader();
 620			showsetting('forums_edit_basic_cat_name', 'namenew', $mforum[0]['name'], 'text');
 621			showsetting('forums_edit_basic_cat_name_color', 'extranew[namecolor]', $mforum[0]['extra']['namecolor'], 'color');
 622			showsetting('forums_edit_basic_cat_style', '', '', $styleselect);
 623			showsetting('forums_edit_extend_forum_horizontal', 'forumcolumnsnew', $mforum[0]['forumcolumns'], 'text');
 624			showsetting('forums_edit_extend_cat_sub_horizontal', 'catforumcolumnsnew', $mforum[0]['catforumcolumns'], 'text');
 625			if(!empty($_G['setting']['domain']['root']['forum'])) {
 626				showsetting('forums_edit_extend_domain', '', '', 'http://<input type="text" name="domainnew" class="txt" value="'.$mforum[0]['domain'].'" style="width:100px; margin-right:0px;" >.'.$_G['setting']['domain']['root']['forum']);
 627			} else {
 628				showsetting('forums_edit_extend_domain', 'domainnew', '', 'text', 'disabled');
 629			}
 630			showsetting('forums_cat_display', 'statusnew', $mforum[0]['status'], 'radio');
 631			showtablefooter();
 632			showtips('setting_seo_forum_tips', 'seo_tips', true, 'setseotips');
 633			showtableheader();
 634			showsetting('forums_edit_basic_seotitle', 'seotitlenew', dhtmlspecialchars($mforum[0]['seotitle']), 'text');
 635			showsetting('forums_edit_basic_keyword', 'keywordsnew', dhtmlspecialchars($mforum[0]['keywords']), 'text');
 636			showsetting('forums_edit_basic_seodescription', 'seodescriptionnew', dhtmlspecialchars($mforum[0]['seodescription']), 'textarea');
 637			showsubmit('detailsubmit');
 638			showtablefooter();
 639
 640		} else {
 641
 642			require_once libfile('function/editor');
 643
 644			if($multiset) {
 645				$_G['showsetting_multi'] = 0;
 646				$_G['showsetting_multicount'] = count($mforum);
 647				foreach($mforum as $forum) {
 648					$_G['showtableheader_multi'][] = '<a href="javascript:;" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'&anchor=\'+$(\'cpform\').anchor.value;return false">'.$forum['name'].'(fid:'.$forum['fid'].')</a>';
 649				}
 650			}
 651			$mfids = array();
 652			foreach($mforum as $forum) {
 653				$fid = $forum['fid'];
 654				$mfids[] = $fid;
 655				if(!$multiset) {
 656					$fupselect = "<select name=\"fupnew\">\n";
 657					$query = C::t('forum_forum')->fetch_all_info_by_ignore_fid($fid);
 658					foreach($query as $fup) {
 659						$fups[] = $fup;
 660					}
 661					if(is_array($fups)) {
 662						foreach($fups as $forum1) {
 663							if($forum1['type'] == 'group') {
 664								$selected = $forum1['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
 665								$fupselect .= "<option value=\"$forum1[fid]\" $selected>$forum1[name]</option>\n";
 666								foreach($fups as $forum2) {
 667									if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) {
 668										$selected = $forum2['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
 669										$fupselect .= "<option value=\"$forum2[fid]\" $selected>&nbsp; &gt; $forum2[name]</option>\n";
 670									}
 671								}
 672							}
 673						}
 674						foreach($fups as $forum0) {
 675							if($forum0['type'] == 'forum' && $forum0['fup'] == 0) {
 676								$selected = $forum0['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
 677								$fupselect .= "<option value=\"$forum0[fid]\" $selected>$forum0[name]</option>\n";
 678							}
 679						}
 680					}
 681					$fupselect .= '</select>';
 682
 683					if($forum['threadtypes']) {
 684						$forum['threadtypes'] = dunserialize($forum['threadtypes']);
 685						$forum['threadtypes']['status'] = 1;
 686					} else {
 687						$forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
 688					}
 689
 690					if($forum['threadsorts']) {
 691						$forum['threadsorts'] = dunserialize($forum['threadsorts']);
 692						$forum['threadsorts']['status'] = 1;
 693					} else {
 694						$forum['threadsorts'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
 695					}
 696
 697					$typeselect = $sortselect = '';
 698
 699					$query = C::t('forum_threadtype')->fetch_all_for_order();
 700					$typeselect = getthreadclasses_html($fid);
 701					foreach($query as $type) {
 702						$typeselected = array();
 703						$enablechecked = '';
 704
 705						$keysort = $type['special'] ? 'threadsorts' : 'threadtypes';
 706						if(isset($forum[$keysort]['types'][$type['typeid']])) {
 707							$enablechecked = ' checked="checked"';
 708						}
 709
 710						$showtype = TRUE;
 711
 712						loadcache('threadsort_option_'.$type['typeid']);
 713						if($type['special'] && !$_G['cache']['threadsort_option_'.$type['typeid']]) {
 714							$showtype = FALSE;
 715						}
 716						if($type['special']) {
 717							$typeselected[3] = $forum['threadsorts']['show'][$type['typeid']] ? ' checked="checked"' : '';
 718							$sortselect .= $showtype ? showtablerow('', array('class="td25"'), array(
 719								'<input type="checkbox" name="threadsortsnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
 720								$type['name'],
 721								$type['description'],
 722								"<input class=\"checkbox\" type=\"checkbox\" name=\"threadsortsnew[options][show][{$type[typeid]}]\" value=\"3\" $typeselected[3] />",
 723								"<input class=\"radio\" type=\"radio\" name=\"threadsortsnew[defaultshow]\" value=\"$type[typeid]\" ".($forum['threadsorts']['defaultshow'] == $type['typeid'] ? 'checked' : '')." />"
 724							), TRUE) : '';
 725						}
 726					}
 727					$forum['creditspolicy'] = $forum['creditspolicy'] ? dunserialize($forum['creditspolicy']) : array();
 728				}
 729
 730				if($forum['autoclose']) {
 731					$forum['autoclosetime'] = abs($forum['autoclose']);
 732					$forum['autoclose'] = $forum['autoclose'] / abs($forum['autoclose']);
 733				}
 734
 735				if($forum['threadplugin']) {
 736					$forum['threadplugin'] = dunserialize($forum['threadplugin']);
 737				}
 738
 739				$simplebin = sprintf('%08b', $forum['simple']);
 740				$forum['defaultorderfield'] = bindec(substr($simplebin, 0, 2));
 741				$forum['defaultorder'] = ($forum['simple'] & 32) ? 1 : 0;
 742				$forum['subforumsindex'] = bindec(substr($simplebin, 3, 2));
 743				$forum['subforumsindex'] = $forum['subforumsindex'] == 0 ? -1 : ($forum['subforumsindex'] == 2 ? 0 : 1);
 744				$forum['simple'] = $forum['simple'] & 1;
 745				$forum['modrecommend'] = $forum['modrecommend'] ? dunserialize($forum['modrecommend']) : '';
 746				$forum['formulaperm'] = dunserialize($forum['formulaperm']);
 747				$forum['medal'] = $forum['formulaperm']['medal'];
 748				$forum['formulapermmessage'] = $forum['formulaperm']['message'];
 749				$forum['formulapermusers'] = $forum['formulaperm']['users'];
 750				$forum['formulaperm'] = $forum['formulaperm'][0];
 751				$forum['extra'] = dunserialize($forum['extra']);
 752				$forum['threadsorts']['default'] = $forum['threadsorts']['defaultshow'] ? 1 : 0;
 753
 754				$_G['multisetting'] = $multiset ? 1 : 0;
 755				showmultititle();
 756				showtagheader('div', 'basic', $anchor == 'basic');
 757				if(!$multiset) {
 758					showtips('forums_edit_tips');
 759				}
 760				showtableheader('forums_edit_basic', 'nobottom');
 761				showsetting('forums_edit_basic_name', 'namenew', $forum['name'], 'text');
 762				showsetting('forums_edit_base_name_color', 'extranew[namecolor]', $forum['extra']['namecolor'], 'color');
 763				if(!$multiset) {
 764					if($forum['icon']) {
 765						$valueparse = parse_url($forum['icon']);
 766						if(isset($valueparse['host'])) {
 767							$forumicon = $forum['icon'];
 768						} else {
 769							$forumicon = $_G['setting']['attachurl'].'common/'.$forum['icon'].'?'.random(6);
 770						}
 771						$forumiconhtml = '<label><input type="checkbox" class="checkbox" name="deleteicon" value="yes" /> '.$lang['delete'].'</label><br /><img src="'.$forumicon.'" /><br />';
 772					}
 773					showsetting('forums_edit_basic_icon', 'iconnew', $forum['icon'], 'filetext', '', 0, $forumiconhtml);
 774					showsetting('forums_edit_basic_icon_width', 'extranew[iconwidth]', $forum['extra']['iconwidth'], 'text');
 775					if($forum['banner']) {
 776						$valueparse = parse_url($forum['banner']);
 777						if(isset($valueparse['host'])) {
 778							$forumbanner = $forum['banner'];
 779						} else {
 780							$forumbanner = $_G['setting']['attachurl'].'common/'.$forum['banner'].'?'.random(6);
 781						}
 782						$forumbannerhtml = '<label><input type="checkbox" class="checkbox" name="deletebanner" value="yes" /> '.$lang['delete'].'</label><br /><img src="'.$forumbanner.'" /><br />';
 783					}
 784					showsetting('forums_edit_basic_banner', 'bannernew', $forum['banner'], 'filetext', '', 0, $forumbannerhtml);
 785				}
 786				showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');
 787				if(!$multiset) {
 788					showsetting('forums_edit_basic_up', '', '', $fupselect);
 789				}
 790				showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text');
 791				showsetting('forums_edit_basic_description', 'descriptionnew', str_replace('&amp;', '&', html2bbcode($forum['description'])), 'textarea');
 792				showsetting('forums_edit_basic_rules', 'rulesnew', str_replace('&amp;', '&', html2bbcode($forum['rules'])), 'textarea');
 793				showsetting('forums_edit_basic_keys', 'keysnew', $forumkeys[$fid], 'text');
 794				if(!empty($_G['setting']['domain']['root']['forum'])) {
 795					$iname = $multiset ? "multinew[{$_G[showsetting_multi]}][domainnew]" : 'domainnew';
 796					showsetting('forums_edit_extend_domain', '', '', 'http://<input type="text" name="'.$iname.'" class="txt" value="'.$forum['domain'].'" style="width:100px; margin-right:0px;" >.'.$_G['setting']['domain']['root']['forum']);
 797				} elseif(!$multiset) {
 798					showsetting('forums_edit_extend_domain', 'domainnew', '', 'text', 'disabled');
 799				}
 800				showtablefooter();
 801				if(!$multiset) {
 802					showtips('setting_seo_forum_tips', 'seo_tips', true, 'setseotips');
 803				}
 804				showtableheader();
 805				showsetting('forums_edit_basic_seotitle', 'seotitlenew', dhtmlspecialchars($forum['seotitle']), 'text');
 806				showsetting('forums_edit_basic_keyword', 'keywordsnew', dhtmlspecialchars($forum['keywords']), 'text');
 807				showsetting('forums_edit_basic_seodescription', 'seodescriptionnew', dhtmlspecialchars($forum['seodescription']), 'textarea');
 808				showtablefooter();
 809				showtagfooter('div');
 810
 811				showtagheader('div', 'extend', $anchor == 'extend');
 812				if(!$multiset) {
 813					showtips('forums_edit_tips');
 814				}
 815				showtableheader('forums_edit_extend', 'nobottom');
 816				showsetting('forums_edit_extend_style', '', '', $styleselect);
 817				if($forum['type'] != 'sub') {
 818					showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
 819					showsetting('forums_edit_extend_subforumsindex', array('subforumsindexnew', array(
 820						array(-1, cplang('default')),
 821						array(1, cplang('yes')),
 822						array(0, cplang('no'))
 823					), 1), $forum['subforumsindex'], 'mradio');
 824					showsetting('forums_edit_extend_simple', 'simplenew', $forum['simple'], 'radio');
 825				} else {
 826					if($_GET['multi']) {
 827						showsetting('forums_edit_extend_sub_horizontal', '', '', cplang('forums_edit_sub_multi_tips'));
 828						showsetting('forums_edit_extend_subforumsindex', '', '', cplang('forums_edit_sub_multi_tips'));
 829						showsetting('forums_edit_extend_simple', '', '', cplang('forums_edit_sub_multi_tips'));
 830					}
 831				}
 832				showsetting('forums_edit_extend_widthauto', array('widthautonew', array(
 833					array(0, cplang('default')),
 834					array(-1, cplang('forums_edit_extend_widthauto_-1')),
 835					array(1, cplang('forums_edit_extend_widthauto_1')),
 836				), 1), $forum['widthauto'], 'mradio');
 837				showsetting('forums_edit_extend_picstyle', 'picstylenew', $forum['picstyle'], 'radio');
 838				showsetting('forums_edit_extend_allowside', 'allowsidenew', $forum['allowside'], 'radio');
 839				showsetting('forums_edit_extend_recommend_top', 'allowglobalsticknew', $forum['allowglobalstick'], 'radio');
 840				showsetting('forums_edit_extend_defaultorderfield', array('defaultorderfieldnew', array(
 841					array(0, cplang('forums_edit_extend_order_lastpost')),
 842					array(1, cplang('forums_edit_extend_order_starttime')),
 843					array(2, cplang('forums_edit_extend_order_replies')),
 844					array(3, cplang('forums_edit_extend_order_views'))
 845				)), $forum['defaultorderfield'], 'mradio');
 846				showsetting('forums_edit_extend_defaultorder', array('defaultordernew', array(
 847					array(0, cplang('forums_edit_extend_order_desc')),
 848					array(1, cplang('forums_edit_extend_order_asc'))
 849				)), $forum['defaultorder'], 'mradio');
 850				showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text');
 851				showsetting('forums_edit_extend_relatedgroup', 'relatedgroupnew', $forum['relatedgroup'], 'text');
 852				showsetting('forums_edit_extend_edit_rules', 'alloweditrulesnew', $forum['alloweditrules'], 'radio');
 853				showsetting('forums_edit_extend_disablecollect', 'disablecollectnew', $forum['disablecollect'], 'radio');
 854				showsetting('forums_edit_extend_recommend', 'modrecommendnew[open]', $forum['modrecommend']['open'], 'radio', '', 1);
 855				showsetting('forums_edit_extend_recommend_sort', array('modrecommendnew[sort]', array(
 856					array(1, cplang('forums_edit_extend_recommend_sort_auto')),
 857					array(0, cplang('forums_edit_extend_recommend_sort_manual')),
 858					array(2, cplang('forums_edit_extend_recommend_sort_mix')))), $forum['modrecommend']['sort'], 'mradio');
 859				showsetting('forums_edit_extend_recommend_orderby', array('modrecommendnew[orderby]', array(
 860					array(0, cplang('forums_edit_extend_recommend_orderby_dateline')),
 861					array(1, cplang('forums_edit_extend_recommend_orderby_lastpost')),
 862					array(2, cplang('forums_edit_extend_recommend_orderby_views')),
 863					array(3, cplang('forums_edit_extend_recommend_orderby_replies')),
 864					array(4, cplang('forums_edit_extend_recommend_orderby_digest')),
 865					array(5, cplang('forums_edit_extend_recommend_orderby_recommend')),
 866					array(6, cplang('forums_edit_extend_recommend_orderby_heats')),
 867					)), $forum['modrecommend']['orderby'], 'mradio');
 868				showsetting('forums_edit_extend_recommend_num', 'modrecommendnew[num]', $forum['modrecommend']['num'], 'text');
 869				showsetting('forums_edit_extend_recommend_imagenum', 'modrecommendnew[imagenum]', $forum['modrecommend']['imagenum'], 'text');
 870				showsetting('forums_edit_extend_recommend_imagesize', array('modrecommendnew[imagewidth]', 'modrecommendnew[imageheight]'), array(intval($forum['modrecommend']['imagewidth']), intval($forum['modrecommend']['imageheight'])), 'multiply');
 871				showsetting('forums_edit_extend_recommend_maxlength', 'modrecommendnew[maxlength]', $forum['modrecommend']['maxlength'], 'text');
 872				showsetting('forums_edit_extend_recommend_cachelife', 'modrecommendnew[cachelife]', $forum['modrecommend']['cachelife'], 'text');
 873				showsetting('forums_edit_extend_recommend_dateline', 'modrecommendnew[dateline]', $forum['modrecommend']['dateline'], 'text');
 874				showtablefooter();
 875				showtagfooter('div');
 876
 877				showtagheader('div', 'posts', $anchor == 'posts');
 878				if(!$multiset) {
 879					showtips('forums_edit_tips');
 880				}
 881				showtableheader('forums_edit_posts', 'nobottom');
 882				showsetting('forums_edit_posts_modposts', array('modnewpostsnew', array(
 883					array(0, cplang('none')),
 884					array(1, cplang('forums_edit_posts_modposts_threads')),
 885					array(2, cplang('forums_edit_posts_modposts_posts'))
 886				)), $forum['modnewposts'], 'mradio');
 887				showsetting('forums_edit_posts_alloweditpost', 'alloweditpostnew', $forum['alloweditpost'], 'radio');
 888				showsetting('forums_edit_posts_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio');
 889				showsetting('forums_edit_posts_html', 'allowhtmlnew', $forum['allowhtml'], 'radio');
 890				showsetting('forums_edit_posts_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio');
 891				showsetting('forums_edit_posts_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio');
 892				showsetting('forums_edit_posts_mediacode', 'allowmediacodenew', $forum['allowmediacode'], 'radio');
 893				showsetting('forums_edit_posts_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio');
 894				showsetting('forums_edit_posts_jammer', 'jammernew', $forum['jammer'], 'radio');
 895				showsetting('forums_edit_posts_anonymous', 'allowanonymousnew', $forum['allowanonymous'], 'radio');
 896				showsetting('forums_edit_posts_disablethumb', 'disablethumbnew', $forum['disablethumb'], 'radio');
 897				showsetting('forums_edit_posts_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio');
 898
 899				showsetting('forums_edit_posts_allowpostspecial', array('allowpostspecialnew', array(
 900					cplang('thread_poll'),
 901					cplang('thread_trade'),
 902					cplang('thread_reward'),
 903					cplang('thread_activity'),
 904					cplang('thread_debate')
 905				)), $forum['allowpostspecial'], 'binmcheckbox');
 906				$threadpluginarray = '';
 907				if(is_array($_G['setting']['threadplugins'])) foreach($_G['setting']['threadplugins'] as $tpid => $data) {
 908					$threadpluginarray[] = array($tpid, $data['name']);
 909				}
 910				if($threadpluginarray) {
 911					showsetting('forums_edit_posts_threadplugin', array('threadpluginnew', $threadpluginarray), $forum['threadplugin'], 'mcheckbox');
 912				}
 913				showsetting('forums_edit_posts_allowspecialonly', 'allowspecialonlynew', $forum['allowspecialonly'], 'radio');
 914				showsetting('forums_edit_posts_autoclose', array('autoclosenew', array(
 915					array(0, cplang('forums_edit_posts_autoclose_none'), array('autoclose_time' => 'none')),
 916					array(1, cplang('forums_edit_posts_autoclose_dateline'), array('autoclose_time' => '')),
 917					array(-1, cplang('forums_edit_posts_autoclose_lastpost'), array('autoclose_time' => ''))
 918				)), $forum['autoclose'], 'mradio');
 919				showtagheader('tbody', 'autoclose_time', $forum['autoclose'], 'sub');
 920				showsetting('forums_edit_posts_autoclose_time', 'autoclosetimenew', $forum['autoclosetime'], 'text');
 921				showtagfooter('tbody');
 922				showsetting('forums_edit_posts_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text');
 923				showsetting('forums_edit_posts_allowfeed', 'allowfeednew', $forum['allowfeed'], 'radio');
 924				showsetting('forums_edit_posts_commentitem', 'commentitemnew', $forum['commentitem'], 'textarea');
 925
 926				showtablefooter();
 927				showtagfooter('div');
 928
 929				if(!$multiset) {
 930					showtagheader('div', 'attachtype', $anchor == 'attachtype');
 931					showtips('forums_edit_attachtype_tips');
 932					showtableheader();
 933					showtablerow('class="partition"', array('class="td25"', 'class="td24"'), array(cplang('del'), cplang('misc_attachtype_ext'), cplang('misc_attachtype_maxsize')));
 934					echo $attachtypes;
 935					echo '<tr><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 1)" class="addtr">'.$lang['misc_attachtype_add'].'</a></div></tr>';
 936					showtablefooter();
 937					showtagfooter('div');
 938
 939					showtagheader('div', 'credits', $anchor == 'credits');
 940					if(!$multiset) {
 941						showtips('forums_edit_tips');
 942					}
 943					showtableheader('forums_edit_credits_policy', 'fixpadding');
 944					echo '<tr class="header"><th>'.cplang('credits_id').'</th><th>'.cplang('setting_credits_policy_cycletype').'</th><th>'.cplang('setting_credits_policy_rewardnum').'</th><th class="td25">'.cplang('custom').'</th>';
 945					foreach($_G['setting']['extcredits'] as $i => $extcredit) {
 946						echo '<th>'.$extcredit['title'].'</th>';
 947					}
 948					echo '<th>&nbsp;</th></tr>';
 949
 950					if(is_array($_G['setting']['extcredits'])) {
 951						foreach($rules as $rid => $rule) {
 952							$globalrule = $rule;
 953							$readonly = $checked = '';
 954							if(isset($forum['creditspolicy'][$rule['action']])) {
 955								$rule = $forum['creditspolicy'][$rule['action']];
 956								$checked = ' checked="checked"';
 957							} else {
 958								for($i = 1; $i <= 8; $i++) {
 959									$rule['extcredits'.$i] = '';
 960								}
 961								$readonly = ' readonly="readonly" style="display:none;"';
 962							}
 963							$usecustom = '<input type="checkbox" name="usecustom['.$rule['rid'].']" onclick="modifystate(this);" value="1" class="checkbox" '.$checked.' />';
 964							$tdarr = array($rule['rulename'], $rule['rid'] ? cplang('setting_credits_policy_cycletype_'.$rule['cycletype']) : 'N/A', $rule['rid'] && $rule['cycletype'] ? $rule['rewardnum'] : 'N/A', $usecustom);
 965
 966							for($i = 1; $i <= 8; $i++) {
 967								if($_G['setting']['extcredits'][$i]) {
 968									array_push($tdarr, '<input type="text" name="creditnew['.$rule['rid'].']['.$i.']" class="txt smtxt" value="'.$rule['extcredits'.$i].'" '.$readonly.' /><span class="sml">('.($globalrule['extcredits'.$i]).')</span>');
 969								}
 970							}
 971							$opstr = '<a href="'.ADMINSCRIPT.'?action=credits&operation=edit&rid='.$rule['rid'].'&fid='.$fid.'" title="" class="act">'.cplang('edit').'</a>';
 972							array_push($tdarr, $opstr);
 973							showtablerow('', array_fill(4, count($_G['setting']['extcredits']) + 4, 'width="70"'), $tdarr);
 974						}
 975
 976					}
 977					showtablerow('', 'class="lineheight" colspan="13"', cplang('forums_edit_credits_comment', array('fid' => $fid)));
 978
 979					showtablefooter();
 980					print <<<EOF
 981					<script type="text/javascript">
 982						function modifystate(custom) {
 983							var trObj = custom.parentNode.parentNode;
 984							var inputsObj = trObj.getElementsByTagName('input');
 985							for(key in inputsObj) {
 986								var obj = inputsObj[key];
 987								if(typeof obj == 'object' && obj.type != 'checkbox') {
 988									obj.value = '';
 989									obj.readOnly = custom.checked ? false : true;
 990									obj.style.display = obj.readOnly ? 'none' : '';
 991								}
 992							}
 993						}
 994					</script>
 995EOF;
 996					showtagfooter('div');
 997				}
 998
 999				if($allowthreadtypes && !$multiset) {
1000					$lang_forums_edit_threadtypes_use_cols = cplang('forums_edit_threadtypes_use_cols');
1001					$lang_forums_edit_threadtypes_use_choice = cplang('forums_edit_threadtypes_use_choice');
1002					echo <<<EOT
1003	<script type="text/JavaScript">
1004		var rowtypedata = [
1005			[
1006				[1,'', 'td25'],
1007				[1,'<input type="text" size="2" name="newdisplayorder[]" value="0" />'],
1008				[1,'<input type="text" name="newname[]" />'],
1009				[1,'<input type="text" name="newicon[]" />'],
1010				[1,'<input type="hidden" name="newenable[]" value="1"><input type="checkbox" class="checkbox" checked="checked" disabled/>'],
1011				[1,'<input type="checkbox" class="checkbox" name="newmoderators[]" value="1" />'],
1012				[1,'']
1013			],
1014			[
1015				[1,'', 'td25'],
1016				[1,'<input name="newextension[]" type="text" class="txt" size="10">', 'td24'],
1017				[1,'<input name="newmaxsize[]" type="text" class="txt" size="15">']
1018			]
1019		];
1020	</script>
1021EOT;
1022					showtagheader('div', 'threadtypes', $anchor == 'threadtypes');
1023					if(!$multiset) {
1024						showtips('forums_edit_tips');
1025					}
1026					showtableheader('forums_edit_threadtypes_config', 'nobottom');
1027					showsetting('forums_edit_threadtypes_status', array('threadtypesnew[status]', array(
1028						array(1, cplang('yes'), array('threadtypes_config' => '', 'threadtypes_manage' => '')),
1029						array(0, cplang('no'), array('threadtypes_config' => 'none', 'threadtypes_manage' => 'none'))
1030					), TRUE), $forum['threadtypes']['status'], 'mradio');
1031					showtagheader('tbody', 'threadtypes_config', $forum['threadtypes']['status']);
1032					showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio');
1033					showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio');
1034					showsetting('forums_edit_threadtypes_prefix',
1035						array(
1036							'threadtypesnew[prefix]',
1037							array(
1038								array(0, cplang('forums_edit_threadtypes_noprefix')),
1039								array(1, cplang('forums_edit_threadtypes_textonly')),
1040								array(2, cplang('forums_edit_threadtypes_icononly')),
1041							),
1042						),
1043						$forum['threadtypes']['prefix'], 'mradio'
1044					);
1045					showtagfooter('tbody');
1046					showtablefooter();
1047
1048					showtagheader('div', 'threadtypes_manage', $forum['threadtypes']['status']);
1049					showtableheader('forums_edit_threadtypes', 'noborder fixpadding');
1050					showsubtitle(array('delete', 'display_order', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_icon', 'enable', 'forums_edit_threadtypes_moderators'));
1051					echo $typeselect;
1052					echo '<tr><td colspan="7"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.cplang('threadtype_infotypes_add').'</a></div></td></tr>';
1053					showtablefooter();
1054					showtagfoo…

Large files files are truncated, but you can click here to view the full file