punbb/admin_categories.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 new category
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    42
if (isset($_POST['add_cat']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    43
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    44
	confirm_referrer('admin_categories.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    45
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    46
	$new_cat_name = trim($_POST['new_cat_name']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    47
	if ($new_cat_name == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    48
		message('You must enter a name for the category.');
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.'categories (cat_name) VALUES(\''.$pun_db->escape($new_cat_name).'\')') or error('Unable to create category', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    51
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
    52
	pun_redirect('admin_categories.php', 'Category added. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    53
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    54
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    55
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    56
// Delete a category
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    57
else if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply']))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    58
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    59
	confirm_referrer('admin_categories.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    60
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    61
	$cat_to_delete = intval($_POST['cat_to_delete']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    62
	if ($cat_to_delete < 1)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    63
		message($lang_common['Bad request']);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    64
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    65
	if (isset($_POST['del_cat_comply']))	// Delete a category with all forums and posts
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    66
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    67
		@set_time_limit(0);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    68
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
    69
		$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Unable to fetch forum 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
    70
		$num_forums = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    71
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    72
		for ($i = 0; $i < $num_forums; ++$i)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    73
		{
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
    74
			$cur_forum = $pun_db->result($result, $i);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    75
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    76
			// Prune all posts and topics
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    77
			prune($cur_forum, 1, -1);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    78
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    79
			// Delete the forum
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
    80
			$pun_db->query('DELETE FROM '.$pun_db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    81
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    82
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    83
		// 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
    84
		$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
    85
		$num_orphans = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    86
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    87
		if ($num_orphans)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    88
		{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    89
			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
    90
				$orphans[] = $pun_db->result($result, $i);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    91
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
    92
			$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
    93
		}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    94
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    95
		// Delete the category
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_db->query('DELETE FROM '.$pun_db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    97
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    98
		// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
    99
		require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   100
		generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   101
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
   102
		pun_redirect('admin_categories.php', 'Category deleted. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   103
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   104
	else	// If the user hasn't comfirmed the delete
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   105
	{
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
   106
		$result = $pun_db->query('SELECT cat_name FROM '.$pun_db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to fetch category 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
   107
		$cat_name = $pun_db->result($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   108
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   109
		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Categories';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   110
		require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   111
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   112
		generate_admin_menu('categories');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   113
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   114
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   115
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   116
		<h2><span>Category delete</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   117
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   118
			<form method="post" action="admin_categories.php">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   119
				<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   120
				<input type="hidden" name="cat_to_delete" value="<?php echo $cat_to_delete ?>" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   121
					<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   122
						<legend>Confirm delete category</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   123
						<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   124
							<p>Are you sure that you want to delete the category "<?php echo pun_htmlspecialchars($cat_name) ?>"?</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   125
							<p>WARNING! Deleting a category will delete all forums and posts (if any) in that category!</p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   126
						</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   127
					</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   128
				</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   129
				<p><input type="submit" name="del_cat_comply" value="Delete" /><a href="javascript:history.go(-1)">Go back</a></p>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   130
			</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   131
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   132
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   133
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   134
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   135
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   136
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   137
		require PUN_ROOT.'footer.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   138
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   139
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   140
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   141
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   142
else if (isset($_POST['update']))	// Change position and name of the categories
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   143
{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   144
	confirm_referrer('admin_categories.php');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   145
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   146
	$cat_order = $_POST['cat_order'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   147
	$cat_name = $_POST['cat_name'];
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   148
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
   149
	$result = $pun_db->query('SELECT id, disp_position 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
   150
	$num_cats = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   151
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   152
	for ($i = 0; $i < $num_cats; ++$i)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   153
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   154
		if ($cat_name[$i] == '')
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   155
			message('You must enter a category name.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   156
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   157
		if (!@preg_match('#^\d+$#', $cat_order[$i]))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   158
			message('Position must be an integer value.');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   159
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
   160
		list($cat_id, $position) = $pun_db->fetch_row($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   161
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
   162
		$pun_db->query('UPDATE '.$pun_db->prefix.'categories SET cat_name=\''.$pun_db->escape($cat_name[$i]).'\', disp_position='.$cat_order[$i].' WHERE id='.$cat_id) or error('Unable to update category', __FILE__, __LINE__, $pun_db->error());
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   163
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   164
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   165
	// Regenerate the quickjump cache
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   166
	require_once PUN_ROOT.'include/cache.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   167
	generate_quickjump_cache();
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   168
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
   169
	pun_redirect('admin_categories.php', 'Categories updated. Redirecting &hellip;');
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   170
}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   171
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   172
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   173
// Generate an array with all categories
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
   174
$result = $pun_db->query('SELECT id, cat_name, disp_position 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
   175
$num_cats = $pun_db->num_rows($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   176
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   177
for ($i = 0; $i < $num_cats; ++$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
   178
	$cat_list[] = $pun_db->fetch_row($result);
0
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   179
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   180
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   181
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Categories';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   182
require PUN_ROOT.'header.php';
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   183
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   184
generate_admin_menu('categories');
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   185
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   186
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   187
	<div class="blockform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   188
		<h2><span>Add/remove/edit categories</span></h2>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   189
		<div class="box">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   190
		<form method="post" action="admin_categories.php?action=foo">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   191
			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   192
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   193
					<legend>Add/delete categories</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   194
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   195
						<table class="aligntop" cellspacing="0">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   196
							<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   197
								<th scope="row">Add a new category<div><input type="submit" name="add_cat" value="Add New" tabindex="2" /></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   198
								<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   199
									<input type="text" name="new_cat_name" size="35" maxlength="80" tabindex="1" />
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   200
									<span>The name of the new category you want to add. You can edit the name of the category later (see below).Go to <a href="admin_forums.php">Forums</a> to add forums to your new category.</span>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   201
								</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   202
							</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   203
<?php if ($num_cats): ?>							<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   204
								<th scope="row">Delete a category<div><input type="submit" name="del_cat" value="Delete" tabindex="4" /></div></th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   205
								<td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   206
									<select name="cat_to_delete" tabindex="3">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   207
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   208
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   209
	while (list(, list($cat_id, $cat_name, ,)) = @each($cat_list))
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   210
		echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cat_id.'">'.pun_htmlspecialchars($cat_name).'</option>'."\n";
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   211
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   212
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   213
									</select>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   214
									<span>Select the name of the category you want to delete. You will be asked to confirm your choice of category for deletion before it is deleted.</span>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   215
								</td>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   216
							</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   217
<?php endif; ?>						</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   218
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   219
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   220
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   221
<?php if ($num_cats): ?>			<div class="inform">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   222
				<fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   223
					<legend>Edit categories</legend>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   224
					<div class="infldset">
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   225
						<table id="categoryedit" cellspacing="0" >
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   226
						<thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   227
							<tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   228
								<th class="tcl" scope="col">Name</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   229
								<th scope="col">Position</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   230
								<th>&nbsp;</th>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   231
							</tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   232
						</thead>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   233
						<tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   234
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   235
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   236
	@reset($cat_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   237
	for ($i = 0; $i < $num_cats; ++$i)
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   238
	{
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   239
		list(, list($cat_id, $cat_name, $position)) = @each($cat_list);
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   240
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   241
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   242
							<tr><td><input type="text" name="cat_name[<?php echo $i ?>]" value="<?php echo pun_htmlspecialchars($cat_name) ?>" size="35" maxlength="80" /></td><td><input type="text" name="cat_order[<?php echo $i ?>]" value="<?php echo $position ?>" size="3" maxlength="3" /></td><td>&nbsp;</td></tr>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   243
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   244
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   245
	}
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   246
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   247
?>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   248
						</tbody>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   249
						</table>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   250
						<div class="fsetsubmit"><input type="submit" name="update" value="Update" /></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   251
					</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   252
				</fieldset>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   253
			</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   254
<?php endif; ?>		</form>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   255
		</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   256
	</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   257
	<div class="clearer"></div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   258
</div>
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   259
<?php
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   260
f9ffdbd96607 Initial population
Dan
parents:
diff changeset
   261
require PUN_ROOT.'footer.php';