punbb/admin_forums.php
author Dan
Thu, 12 Jul 2007 01:04:01 -0400
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
permissions -rw-r--r--
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     1
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     2
/***********************************************************************
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     3
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     5
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     7
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    12
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    17
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    22
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    23
************************************************************************/
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    24
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    25
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    26
// Tell header.php to use the admin template
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    27
define('PUN_ADMIN_CONSOLE', 1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    28
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    29
//define('PUN_ROOT', './');
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    30
//require PUN_ROOT.'include/common.php';
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    31
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    32
global $pun_db, $pun_user, $pun_config, $lang_common;
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    33
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    34
require PUN_ROOT.'include/common_admin.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    35
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    36
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    37
if ($pun_user['g_id'] < PUN_ADMIN)
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    38
	message($lang_common['No permission']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    39
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    40
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    41
// Add a "default" forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
if (isset($_POST['add_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	$add_to_cat = intval($_POST['add_to_cat']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
	if ($add_to_cat < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    49
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    52
	// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
	require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
	generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    56
	pun_redirect('admin_forums.php', 'Forum added. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
// Delete a forum
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
else if (isset($_GET['del_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	$forum_id = intval($_GET['del_forum']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	if ($forum_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    69
	if (isset($_POST['del_forum_comply']))	// Delete a forum with all posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    70
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
		@set_time_limit(0);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
		// Prune all posts and topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    74
		prune($forum_id, 1, -1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
		// Locate any "orphaned redirect topics" and delete them
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    78
		$num_orphans = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    80
		if ($num_orphans)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
			for ($i = 0; $i < $num_orphans; ++$i)
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    83
				$orphans[] = $pun_db->result($result, $i);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    84
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
		// Delete the forum and any forum specific group permissions
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    92
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    93
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
    96
		pun_redirect('admin_forums.php', 'Forum deleted. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
	else	// If the user hasn't confirmed the delete
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
	{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   101
		$forum_name = pun_htmlspecialchars($pun_db->result($result));
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   102
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
		require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   106
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   107
		generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
		<h2><span>Confirm delete forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
			<form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
						<legend>Important! Read before deleting</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
							<p>Are you sure that you want to delete the forum "<?php echo $forum_name ?>"?</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
							<p>WARNING! Deleting a forum will delete all posts (if any) in that forum!</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
				<p><input type="submit" name="del_forum_comply" value="Delete" /><a href="javascript:history.go(-1)">Go back</a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
		require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
// Update forum positions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
else if (isset($_POST['update_positions']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
	confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
	while (list($forum_id, $disp_position) = @each($_POST['position']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
		if (!@preg_match('#^\d+$#', $disp_position))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
			message('Position must be a positive integer value.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   149
	// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   150
	require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
	generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   153
	pun_redirect('admin_forums.php', 'Forums updated. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
else if (isset($_GET['edit_forum']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
	$forum_id = intval($_GET['edit_forum']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   160
	if ($forum_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   162
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
	// Update group permissions for $forum_id
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
	if (isset($_POST['save']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
		confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
		// Start with the forum details
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   169
		$forum_name = trim($_POST['forum_name']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
		$forum_desc = pun_linebreaks(trim($_POST['forum_desc']));
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
		$cat_id = intval($_POST['cat_id']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
		$sort_by = intval($_POST['sort_by']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
		$redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   174
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   175
		if ($forum_name == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
			message('You must enter a forum name.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   178
		if ($cat_id < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
			message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   181
		$forum_desc = ($forum_desc != '') ? '\''.$pun_db->escape($forum_desc).'\'' : 'NULL';
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   182
		$redirect_url = ($redirect_url != '') ? '\''.$pun_db->escape($redirect_url).'\'' : 'NULL';
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   185
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   186
		// Now let's deal with the permissions
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
		if (isset($_POST['read_forum_old']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
		{
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   190
			while ($cur_group = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   191
			{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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']]);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   193
				$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
				$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
				// Check if the new settings differ from the old
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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']])
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
				{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   199
					// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   200
					if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   202
					else
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
					{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   204
						// Run an UPDATE and see if it affected a row, if not, INSERT
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   206
						if (!$pun_db->affected_rows())
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   208
					}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   209
				}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
			}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   211
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   212
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   213
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   217
		pun_redirect('admin_forums.php', 'Forum updated. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   218
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   219
	else if (isset($_POST['revert_perms']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   221
		confirm_referrer('admin_forums.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   222
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   229
		pun_redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   230
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
	// Fetch forum info
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   235
	if (!$pun_db->num_rows($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   238
	$cur_forum = $pun_db->fetch_assoc($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
	$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
	require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
	generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
		<h2><span>Edit forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
			<form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
				<p class="submittop"><input type="submit" name="save" value="Save changes" tabindex="6" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
						<legend>Edit forum details</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
							<table class="aligntop" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   258
									<th scope="row">Forum name</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
									<td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   262
									<th scope="row">Description (HTML)</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   263
									<td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   264
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   265
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   266
									<th scope="row">Category</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   267
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   268
										<select name="cat_id" tabindex="3">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   269
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   270
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   272
	while ($cur_cat = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   273
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   274
		$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   276
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   277
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   278
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   279
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   280
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   281
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   282
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   283
									<th scope="row">Sort topics by</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   284
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   285
										<select name="sort_by" tabindex="4">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   286
											<option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>>Last post</option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   287
											<option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>>Topic start</option>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   288
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   289
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   290
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   291
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   292
									<th scope="row">Redirect URL</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   293
									<td><?php echo ($cur_forum['num_topics']) ? 'Only available in empty forums' : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   294
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   295
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   296
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   297
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   298
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   299
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   300
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   301
						<legend>Edit group permissions for this forum</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   302
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   303
							<p>In this form, you can set the forum specific permissions for the different user groups. If you haven't made any changes to this forums group permissions, what you see below is the default based on settings in <a href="admin_groups.php">User groups</a>. Administrators always have full permissions and are thus excluded. Permission settings that differ from the default permissions for the user group are marked red. The "Read forum" permission checkbox will be disabled if the group in question lacks the "Read board" permission. For redirect forums, only the "Read forum" permission is editable.</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   304
							<table id="forumperms" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   305
							<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   306
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   307
									<th class="atcl">&nbsp;</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   308
									<th>Read forum</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   309
									<th>Post replies</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   310
									<th>Post topics</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   311
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   312
							</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   313
							<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   314
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   315
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   317
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   318
	while ($cur_perm = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   319
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   320
		$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   323
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   324
		// Determine if the current sittings differ from the default or not
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   325
		$read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   326
		$post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   327
		$post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   328
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   329
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   330
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   331
									<th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   332
									<td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   333
										<input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   334
										<input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   335
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   336
									<td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   337
										<input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   338
										<input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   339
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   340
									<td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   341
										<input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   342
										<input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   343
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   344
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   345
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   346
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   347
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   348
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   349
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   350
							</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   351
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   352
							<div class="fsetsubmit"><input type="submit" name="revert_perms" value="Revert to default" /></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   353
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   354
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   355
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   356
				<p class="submitend"><input type="submit" name="save" value="Save changes" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   357
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   358
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   359
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   360
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   361
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   362
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   363
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   364
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   365
	require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   366
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   367
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   368
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   369
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   370
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   371
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   372
generate_admin_menu('forums');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   373
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   374
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   375
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   376
		<h2><span>Add forum</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   377
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   378
			<form method="post" action="admin_forums.php?action=adddel">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   379
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   380
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   381
						<legend>Create a new forum</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   382
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   383
							<table class="aligntop" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   384
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   385
									<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   386
									<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   387
										<select name="add_to_cat" tabindex="1">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   388
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   389
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   391
	while ($cur_cat = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   392
		echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   393
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   394
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   395
										</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   396
										<span>Select the category to which you wish to add a new forum.</span>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   397
									</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   398
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   399
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   400
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   401
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   402
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   403
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   404
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   405
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   406
		<h2 class="block2"><span>Edit forums</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   407
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   408
			<form id="edforum" method="post" action="admin_forums.php?action=edit">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   409
				<p class="submittop"><input type="submit" name="update_positions" value="Update positions" tabindex="3" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   410
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   411
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   412
$tabindex_count = 4;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   413
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   414
// Display all the categories and forums
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   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());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   416
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   417
$cur_category = 0;
2
a8a21e1c7afa Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents: 0
diff changeset
   418
while ($cur_forum = $pun_db->fetch_assoc($result))
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   419
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   420
	if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   421
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   422
		if ($cur_category != 0)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   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";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   424
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   425
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   426
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   427
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   428
						<legend>Category: <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   429
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   430
							<table cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   431
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   432
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   433
		$cur_category = $cur_forum['cid'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   434
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   435
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   436
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   437
								<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   438
									<th><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>">Edit</a> - <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>">Delete</a></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   439
									<td>Position&nbsp;&nbsp;<input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $tabindex_count ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   440
									&nbsp;&nbsp;<strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   441
								</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   442
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   443
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   444
	$tabindex_count += 2;
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   445
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   446
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   447
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   448
							</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   449
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   450
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   451
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   452
				<p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   453
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   454
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   455
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   456
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   457
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   458
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   459
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   460
require PUN_ROOT.'footer.php';