punbb/admin_forums.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
equal deleted inserted replaced
1:8f6143115bf5 2:a8a21e1c7afa
    24 
    24 
    25 
    25 
    26 // Tell header.php to use the admin template
    26 // Tell header.php to use the admin template
    27 define('PUN_ADMIN_CONSOLE', 1);
    27 define('PUN_ADMIN_CONSOLE', 1);
    28 
    28 
    29 define('PUN_ROOT', './');
    29 //define('PUN_ROOT', './');
    30 require PUN_ROOT.'include/common.php';
    30 //require PUN_ROOT.'include/common.php';
       
    31 
       
    32 global $pun_db, $pun_user, $pun_config, $lang_common;
       
    33 
    31 require PUN_ROOT.'include/common_admin.php';
    34 require PUN_ROOT.'include/common_admin.php';
    32 
    35 
    33 
    36 
    34 if ($pun_user['g_id'] > PUN_ADMIN)
    37 if ($pun_user['g_id'] < PUN_ADMIN)
    35 	message($lang_common['No permission']);
    38 	message($lang_common['No permission']);
    36 
    39 
    37 
    40 
    38 // Add a "default" forum
    41 // Add a "default" forum
    39 if (isset($_POST['add_forum']))
    42 if (isset($_POST['add_forum']))
    42 
    45 
    43 	$add_to_cat = intval($_POST['add_to_cat']);
    46 	$add_to_cat = intval($_POST['add_to_cat']);
    44 	if ($add_to_cat < 1)
    47 	if ($add_to_cat < 1)
    45 		message($lang_common['Bad request']);
    48 		message($lang_common['Bad request']);
    46 
    49 
    47 	$db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());
    50 	$pun_db->query('INSERT INTO '.$pun_db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $pun_db->error());
    48 
    51 
    49 	// Regenerate the quickjump cache
    52 	// Regenerate the quickjump cache
    50 	require_once PUN_ROOT.'include/cache.php';
    53 	require_once PUN_ROOT.'include/cache.php';
    51 	generate_quickjump_cache();
    54 	generate_quickjump_cache();
    52 
    55 
    53 	redirect('admin_forums.php', 'Forum added. Redirecting &hellip;');
    56 	pun_redirect('admin_forums.php', 'Forum added. Redirecting &hellip;');
    54 }
    57 }
    55 
    58 
    56 
    59 
    57 // Delete a forum
    60 // Delete a forum
    58 else if (isset($_GET['del_forum']))
    61 else if (isset($_GET['del_forum']))
    69 
    72 
    70 		// Prune all posts and topics
    73 		// Prune all posts and topics
    71 		prune($forum_id, 1, -1);
    74 		prune($forum_id, 1, -1);
    72 
    75 
    73 		// Locate any "orphaned redirect topics" and delete them
    76 		// Locate any "orphaned redirect topics" and delete them
    74 		$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
    77 		$result = $pun_db->query('SELECT t1.id FROM '.$pun_db->prefix.'topics AS t1 LEFT JOIN '.$pun_db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $pun_db->error());
    75 		$num_orphans = $db->num_rows($result);
    78 		$num_orphans = $pun_db->num_rows($result);
    76 
    79 
    77 		if ($num_orphans)
    80 		if ($num_orphans)
    78 		{
    81 		{
    79 			for ($i = 0; $i < $num_orphans; ++$i)
    82 			for ($i = 0; $i < $num_orphans; ++$i)
    80 				$orphans[] = $db->result($result, $i);
    83 				$orphans[] = $pun_db->result($result, $i);
    81 
    84 
    82 			$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
    85 			$pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $pun_db->error());
    83 		}
    86 		}
    84 
    87 
    85 		// Delete the forum and any forum specific group permissions
    88 		// Delete the forum and any forum specific group permissions
    86 		$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
    89 		$pun_db->query('DELETE FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $pun_db->error());
    87 		$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
    90 		$pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error());
    88 
    91 
    89 		// Regenerate the quickjump cache
    92 		// Regenerate the quickjump cache
    90 		require_once PUN_ROOT.'include/cache.php';
    93 		require_once PUN_ROOT.'include/cache.php';
    91 		generate_quickjump_cache();
    94 		generate_quickjump_cache();
    92 
    95 
    93 		redirect('admin_forums.php', 'Forum deleted. Redirecting &hellip;');
    96 		pun_redirect('admin_forums.php', 'Forum deleted. Redirecting &hellip;');
    94 	}
    97 	}
    95 	else	// If the user hasn't confirmed the delete
    98 	else	// If the user hasn't confirmed the delete
    96 	{
    99 	{
    97 		$result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
   100 		$result = $pun_db->query('SELECT forum_name FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error());
    98 		$forum_name = pun_htmlspecialchars($db->result($result));
   101 		$forum_name = pun_htmlspecialchars($pun_db->result($result));
    99 
   102 
   100 
   103 
   101 		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
   104 		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
   102 		require PUN_ROOT.'header.php';
   105 		require PUN_ROOT.'header.php';
   103 
   106 
   138 	while (list($forum_id, $disp_position) = @each($_POST['position']))
   141 	while (list($forum_id, $disp_position) = @each($_POST['position']))
   139 	{
   142 	{
   140 		if (!@preg_match('#^\d+$#', $disp_position))
   143 		if (!@preg_match('#^\d+$#', $disp_position))
   141 			message('Position must be a positive integer value.');
   144 			message('Position must be a positive integer value.');
   142 
   145 
   143 		$db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
   146 		$pun_db->query('UPDATE '.$pun_db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $pun_db->error());
   144 	}
   147 	}
   145 
   148 
   146 	// Regenerate the quickjump cache
   149 	// Regenerate the quickjump cache
   147 	require_once PUN_ROOT.'include/cache.php';
   150 	require_once PUN_ROOT.'include/cache.php';
   148 	generate_quickjump_cache();
   151 	generate_quickjump_cache();
   149 
   152 
   150 	redirect('admin_forums.php', 'Forums updated. Redirecting &hellip;');
   153 	pun_redirect('admin_forums.php', 'Forums updated. Redirecting &hellip;');
   151 }
   154 }
   152 
   155 
   153 
   156 
   154 else if (isset($_GET['edit_forum']))
   157 else if (isset($_GET['edit_forum']))
   155 {
   158 {
   173 			message('You must enter a forum name.');
   176 			message('You must enter a forum name.');
   174 
   177 
   175 		if ($cat_id < 1)
   178 		if ($cat_id < 1)
   176 			message($lang_common['Bad request']);
   179 			message($lang_common['Bad request']);
   177 
   180 
   178 		$forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL';
   181 		$forum_desc = ($forum_desc != '') ? '\''.$pun_db->escape($forum_desc).'\'' : 'NULL';
   179 		$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL';
   182 		$redirect_url = ($redirect_url != '') ? '\''.$pun_db->escape($redirect_url).'\'' : 'NULL';
   180 
   183 
   181 		$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
   184 		$pun_db->query('UPDATE '.$pun_db->prefix.'forums SET forum_name=\''.$pun_db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $pun_db->error());
   182 
   185 
   183 		// Now let's deal with the permissions
   186 		// Now let's deal with the permissions
   184 		if (isset($_POST['read_forum_old']))
   187 		if (isset($_POST['read_forum_old']))
   185 		{
   188 		{
   186 			$result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
   189 			$result = $pun_db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$pun_db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error());
   187 			while ($cur_group = $db->fetch_assoc($result))
   190 			while ($cur_group = $pun_db->fetch_assoc($result))
   188 			{
   191 			{
   189 				$read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]);
   192 				$read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]);
   190 				$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
   193 				$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
   191 				$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
   194 				$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
   192 
   195 
   193 				// Check if the new settings differ from the old
   196 				// Check if the new settings differ from the old
   194 				if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']])
   197 				if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']])
   195 				{
   198 				{
   196 					// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
   199 					// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
   197 					if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
   200 					if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
   198 						$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
   201 						$pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error());
   199 					else
   202 					else
   200 					{
   203 					{
   201 						// Run an UPDATE and see if it affected a row, if not, INSERT
   204 						// Run an UPDATE and see if it affected a row, if not, INSERT
   202 						$db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
   205 						$pun_db->query('UPDATE '.$pun_db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $pun_db->error());
   203 						if (!$db->affected_rows())
   206 						if (!$pun_db->affected_rows())
   204 							$db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
   207 							$pun_db->query('INSERT INTO '.$pun_db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $pun_db->error());
   205 					}
   208 					}
   206 				}
   209 				}
   207 			}
   210 			}
   208 		}
   211 		}
   209 
   212 
   210 		// Regenerate the quickjump cache
   213 		// Regenerate the quickjump cache
   211 		require_once PUN_ROOT.'include/cache.php';
   214 		require_once PUN_ROOT.'include/cache.php';
   212 		generate_quickjump_cache();
   215 		generate_quickjump_cache();
   213 
   216 
   214 		redirect('admin_forums.php', 'Forum updated. Redirecting &hellip;');
   217 		pun_redirect('admin_forums.php', 'Forum updated. Redirecting &hellip;');
   215 	}
   218 	}
   216 	else if (isset($_POST['revert_perms']))
   219 	else if (isset($_POST['revert_perms']))
   217 	{
   220 	{
   218 		confirm_referrer('admin_forums.php');
   221 		confirm_referrer('admin_forums.php');
   219 
   222 
   220 		$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
   223 		$pun_db->query('DELETE FROM '.$pun_db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $pun_db->error());
   221 
   224 
   222 		// Regenerate the quickjump cache
   225 		// Regenerate the quickjump cache
   223 		require_once PUN_ROOT.'include/cache.php';
   226 		require_once PUN_ROOT.'include/cache.php';
   224 		generate_quickjump_cache();
   227 		generate_quickjump_cache();
   225 
   228 
   226 		redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting &hellip;');
   229 		pun_redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting &hellip;');
   227 	}
   230 	}
   228 
   231 
   229 
   232 
   230 	// Fetch forum info
   233 	// Fetch forum info
   231 	$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
   234 	$result = $pun_db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$pun_db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error());
   232 	if (!$db->num_rows($result))
   235 	if (!$pun_db->num_rows($result))
   233 		message($lang_common['Bad request']);
   236 		message($lang_common['Bad request']);
   234 
   237 
   235 	$cur_forum = $db->fetch_assoc($result);
   238 	$cur_forum = $pun_db->fetch_assoc($result);
   236 
   239 
   237 
   240 
   238 	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
   241 	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
   239 	require PUN_ROOT.'header.php';
   242 	require PUN_ROOT.'header.php';
   240 
   243 
   263 									<th scope="row">Category</th>
   266 									<th scope="row">Category</th>
   264 									<td>
   267 									<td>
   265 										<select name="cat_id" tabindex="3">
   268 										<select name="cat_id" tabindex="3">
   266 <?php
   269 <?php
   267 
   270 
   268 	$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
   271 	$result = $pun_db->query('SELECT id, cat_name FROM '.$pun_db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $pun_db->error());
   269 	while ($cur_cat = $db->fetch_assoc($result))
   272 	while ($cur_cat = $pun_db->fetch_assoc($result))
   270 	{
   273 	{
   271 		$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
   274 		$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
   272 		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
   275 		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
   273 	}
   276 	}
   274 
   277 
   308 								</tr>
   311 								</tr>
   309 							</thead>
   312 							</thead>
   310 							<tbody>
   313 							<tbody>
   311 <?php
   314 <?php
   312 
   315 
   313 	$result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
   316 	$result = $pun_db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$pun_db->prefix.'groups AS g LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $pun_db->error());
   314 
   317 
   315 	while ($cur_perm = $db->fetch_assoc($result))
   318 	while ($cur_perm = $pun_db->fetch_assoc($result))
   316 	{
   319 	{
   317 		$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
   320 		$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
   318 		$post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false;
   321 		$post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false;
   319 		$post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false;
   322 		$post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false;
   320 
   323 
   382 									<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
   385 									<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
   383 									<td>
   386 									<td>
   384 										<select name="add_to_cat" tabindex="1">
   387 										<select name="add_to_cat" tabindex="1">
   385 <?php
   388 <?php
   386 
   389 
   387 	$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
   390 	$result = $pun_db->query('SELECT id, cat_name FROM '.$pun_db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $pun_db->error());
   388 	while ($cur_cat = $db->fetch_assoc($result))
   391 	while ($cur_cat = $pun_db->fetch_assoc($result))
   389 		echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
   392 		echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
   390 
   393 
   391 ?>
   394 ?>
   392 										</select>
   395 										</select>
   393 										<span>Select the category to which you wish to add a new forum.</span>
   396 										<span>Select the category to which you wish to add a new forum.</span>
   407 <?php
   410 <?php
   408 
   411 
   409 $tabindex_count = 4;
   412 $tabindex_count = 4;
   410 
   413 
   411 // Display all the categories and forums
   414 // Display all the categories and forums
   412 $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
   415 $result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error());
   413 
   416 
   414 $cur_category = 0;
   417 $cur_category = 0;
   415 while ($cur_forum = $db->fetch_assoc($result))
   418 while ($cur_forum = $pun_db->fetch_assoc($result))
   416 {
   419 {
   417 	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
   420 	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
   418 	{
   421 	{
   419 		if ($cur_category != 0)
   422 		if ($cur_category != 0)
   420 			echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";
   423 			echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";