if (is_valid_user($uid)) {
        $zones = $_POST['zone'];
        if (delete_user($uid, $zones)) {
            success(SUC_USER_DEL);
        }
    } else {
        header("Location: users.php");
        exit;
    }
} else {
    if ($uid != $_SESSION['userid'] && $perm_edit_others == "0" || $uid == $_SESSION['userid'] && $perm_is_godlike == "0") {
        error(ERR_PERM_DEL_USER);
        include_once "inc/footer.inc.php";
        exit;
    } else {
        $fullname = get_fullname_from_userid($uid);
        $zones = get_zones("own", $uid);
        echo "     <h2>" . _('Delete user') . " \"" . $fullname . "\"</h2>\n";
        echo "     <form method=\"post\" action=\"\">\n";
        echo "      <table>\n";
        if (count($zones) > 0) {
            $users = show_users();
            echo "       <tr>\n";
            echo "        <td colspan=\"5\">\n";
            echo "         " . _('You are about to delete a user. This user is owner for a number of zones. Please decide what to do with these zones.') . "\n";
            echo "        </td>\n";
            echo "       </tr>\n";
            echo "       <tr>\n";
            echo "        <th>" . _('Zone') . "</th>\n";
            echo "        <th>" . _('Delete') . "</th>\n";
            echo "        <th>" . _('Leave') . "</th>\n";
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "inc/toolkit.inc.php";
include_once "inc/header.inc.php";
verify_permission('zone_master_add') ? $perm_zone_master_add = "1" : ($perm_zone_master_add = "0");
$zone_templ = get_list_zone_templ($_SESSION['userid']);
$username = get_fullname_from_userid($_SESSION['userid']);
if ($perm_zone_master_add == "0") {
    error(ERR_PERM_EDIT_ZONE_TEMPL);
} else {
    echo "    <h2>" . _('Zone templates for') . " " . $username . "</h2>\n";
    echo "     <table>\n";
    echo "      <tr>\n";
    echo "       <th>&nbsp;</th>\n";
    echo "       <th>" . _('Name') . "</th>\n";
    echo "       <th>" . _('Description') . "</th>\n";
    echo "      </tr>\n";
    foreach ($zone_templ as $template) {
        echo "      <tr>\n";
        if ($perm_zone_master_add == "1") {
            echo "       <td>\n";
            echo "        <a href=\"edit_zone_templ.php?id=" . $template["id"] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _('Edit template') . " ]\"></a>\n";