diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin_categories.php --- a/punbb/admin_categories.php Sun Sep 02 11:00:57 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,261 +0,0 @@ -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()); - - pun_redirect('admin_categories.php', 'Category added. Redirecting …'); -} - - -// Delete a category -else if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply'])) -{ - confirm_referrer('admin_categories.php'); - - $cat_to_delete = intval($_POST['cat_to_delete']); - if ($cat_to_delete < 1) - message($lang_common['Bad request']); - - if (isset($_POST['del_cat_comply'])) // Delete a category with all forums and posts - { - @set_time_limit(0); - - $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()); - $num_forums = $pun_db->num_rows($result); - - for ($i = 0; $i < $num_forums; ++$i) - { - $cur_forum = $pun_db->result($result, $i); - - // Prune all posts and topics - prune($cur_forum, 1, -1); - - // Delete the forum - $pun_db->query('DELETE FROM '.$pun_db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $pun_db->error()); - } - - // Locate any "orphaned redirect topics" and delete them - $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()); - $num_orphans = $pun_db->num_rows($result); - - if ($num_orphans) - { - for ($i = 0; $i < $num_orphans; ++$i) - $orphans[] = $pun_db->result($result, $i); - - $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()); - } - - // Delete the category - $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()); - - // Regenerate the quickjump cache - require_once PUN_ROOT.'include/cache.php'; - generate_quickjump_cache(); - - pun_redirect('admin_categories.php', 'Category deleted. Redirecting …'); - } - else // If the user hasn't comfirmed the delete - { - $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()); - $cat_name = $pun_db->result($result); - - $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Categories'; - require PUN_ROOT.'header.php'; - - generate_admin_menu('categories'); - -?> -