delete_record.php
author rejo
Thu, 24 Apr 2008 22:33:28 +0000
changeset 141 1ede5203910d
parent 140 e68c3d6094d1
permissions -rw-r--r--
[feladat @ 247] If the user was listing the details of a zone that did not exist, all kinds of error messages were given. Now we first determine if the ID is valid and if not, immediately return the correct error message.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 98
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    21
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    23
include_once("inc/header.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    25
$record_id = "-1";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    26
if (isset($_GET['id']) && v_num($_GET['id'])) {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    27
	$record_id = $_GET['id'];
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    28
}
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    29
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    30
$confirm = "-1";
98
9c10fd623368 [feladat @ 198]
rejo
parents: 82
diff changeset
    31
if (isset($_GET['confirm']) && v_num($_GET['confirm'])) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    32
        $confirm = $_GET['confirm'];
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    33
}
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    34
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    35
if (verify_permission('zone_content_edit_others')) { $perm_content_edit = "all" ; }
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    36
elseif (verify_permission('zone_content_edit_own')) { $perm_content_edit = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    37
else { $perm_content_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    38
139
98ce0ffae5b8 [feladat @ 245]
peter
parents: 126
diff changeset
    39
$zid = get_zone_id_from_record_id($_GET['id']);
98ce0ffae5b8 [feladat @ 245]
peter
parents: 126
diff changeset
    40
$user_is_zone_owner = verify_user_is_owner_zoneid($zid);
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    41
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    42
if ($record_id == "-1" ) {
98
9c10fd623368 [feladat @ 198]
rejo
parents: 82
diff changeset
    43
	error(ERR_INV_INPUT);
9c10fd623368 [feladat @ 198]
rejo
parents: 82
diff changeset
    44
} else {
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    45
	if ($confirm == '1') {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    46
		if ( delete_record($record_id) ) {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    47
			success(SUC_RECORD_DEL);
37
b785e54690ce [feladat @ 84]
rejo
parents: 13
diff changeset
    48
		}
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    49
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    50
		$zone_id = recid_to_domid($record_id);
140
e68c3d6094d1 [feladat @ 246]
rejo
parents: 139
diff changeset
    51
		$zone_name = get_zone_name_from_id($zone_id);
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    52
		$user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    53
		$record_info = get_record_from_id($record_id);
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 2
diff changeset
    54
	
82
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    55
		echo "     <h2>" . _('Delete record') . " in zone \"" . $zone_name . "\"</h2>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    56
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    57
		if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    58
			error(ERR_PERM_EDIT_RECORD);
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    59
		} else {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    60
			echo "     <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    61
			echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    62
			echo "       <th>Name</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    63
			echo "       <th>Type</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    64
			echo "       <th>Content</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    65
			echo "       <th>Priority</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    66
			echo "       <th>TTL</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    67
			echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    68
			echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    69
			echo "       <td>" . $record_info['name'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    70
			echo "       <td>" . $record_info['type'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    71
			echo "       <td>" . $record_info['content'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    72
			echo "       <td>" . $record_info['priority'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    73
			echo "       <td>" . $record_info['ttl'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    74
			echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    75
			echo "     </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    76
			if (($record_info['type'] == 'NS' && $record_info['name'] == $zone_name) || $record_info['type'] == 'SOA') {
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    77
				echo "     <p>" . _('You are trying to delete a record that is needed for this zone to work.') . "</p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    78
			}
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    79
			echo "     <p>" . _('Are you sure?') . "</p>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    80
			echo "     <input type=\"button\" class=\"button\" OnClick=\"location.href='" . $_SERVER["REQUEST_URI"] . "&confirm=1'\" value=\"" . _('Yes') . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    81
			echo "     <input type=\"button\" class=\"button\" OnClick=\"location.href='index.php'\" value=\"" . _('No') . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 71
diff changeset
    82
		}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
include_once("inc/footer.inc.php");