<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
    Header("Location: index.php");
}

    $cat = $db->XMFnum($cat);
    $result = $db->sql_query("select title from ".TABLE_STORIES_CAT." where catid='$cat'");
    list($title) = $db->sql_fetchrow($result);
    incoh();
    GraphicAdmin();
    Max_OpenTable();
    echo "<center><font class='title'><b>"._CATEGORIESADMIN."</b></font></center>";
    Max_CloseTable();
    echo "<br />";
    Max_OpenTable();
    echo "<center><font class=\"option\"><b>"._DELETECATEGORY."</b></font><br />";
    if (!$cat) {
        $selcat = $db->sql_query("select catid, title from ".TABLE_STORIES_CAT."");
        echo "<form action=\"".$admin_file.".php\" method=\"post\">"
            ."<b>"._SELECTCATDEL.": </b>"
            ."<select name=\"cat\">";
        while(list($catid, $title) = $db->sql_fetchrow($selcat)) {
            $catid = $db->XMFnum($catid);
            echo "<option name=\"cat\" value=\"$catid\">$title</option>";
        }
        echo "</select>"
            ."<input type=\"hidden\" name=\"op\" value=\"DelCategory\">"
            ."<input type=\"submit\" value=\"Delete\">"
            ."</form>";
    } else {
        $result2 = $db->sql_query("select * from ".TABLE_STORIES." where catid='$cat'");
        $numrows = $db->sql_numrows($result2);
        if ($numrows == 0) {
            $db->sql_query("delete from ".TABLE_STORIES_CAT." where catid='$cat'");
            echo "<br /><br />"._CATDELETED."<br /><br />"._GOTOADMIN."";
        } else {
            echo "<br /><br /><b>"._WARNING.":</b> "._THECATEGORY." <b>$title</b> "._HAS." <b>$numrows</b> "._STORIESINSIDE."<br />"
                .""._DELCATWARNING1."<br />"
                .""._DELCATWARNING2."<br /><br />"
                .""._DELCATWARNING3."<br /><br />"
                ."<b>[ <a href=\"".$admin_file.".php?op=YesDelCategory&amp;catid=$cat\">"._YESDEL."</a> | "
                ."<a href=\"".$admin_file.".php?op=NoMoveCategory&amp;catid=$cat\">"._NOMOVE."</a> ]</b>";
        }
    }
    echo "</center>";
    Max_CloseTable();
    incof();