forked from poweradmin/poweradmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_user.php
118 lines (97 loc) · 3.95 KB
/
delete_user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/* Poweradmin, a friendly web-based admin tool for PowerDNS.
* See <https://www.poweradmin.org> for more details.
*
* Copyright 2007-2010 Rejo Zenger <[email protected]>
* Copyright 2010-2012 Poweradmin Development Team
* <https://www.poweradmin.org/trac/wiki/Credits>
*
* 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 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('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
verify_permission('is_ueberuser') ? $perm_is_godlike = "1" : $perm_is_godlike = "0" ;
if (!(isset($_GET['id']) && v_num($_GET['id']))) {
error(ERR_INV_INPUT);
include_once("inc/footer.inc.php");
exit;
} else {
$uid = $_GET['id'];
}
if (isset($_POST['commit'])) {
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";
echo " <th>" . _('Add new owner') . "</th>\n";
echo " <th>" . _('Owner to be added') . "</th>\n";
echo " </tr>\n";
foreach ($zones as $zone) {
echo " <input type=\"hidden\" name=\"zone[" . $zone['id'] . "][zid]\" value=\"" . $zone['id'] . "\">\n";
echo " <tr>\n";
echo " <td>" . $zone['name'] . "</td>\n";
echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"delete\"></td>\n";
echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"leave\" CHECKED></td>\n";
echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"new_owner\"></td>\n";
echo " <td>\n";
echo " <select name=\"zone[" . $zone['id'] . "][newowner]\">\n";
foreach ($users as $user) {
echo " <option value=\"" . $user["id"] . "\">" . $user["fullname"] . "</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
}
}
echo " <tr>\n";
echo " <td colspan=\"5\">\n";
echo " " . _('Really delete this user?') . "\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
echo " </form>\n";
}
}
include_once("inc/footer.inc.php");
?>