1
|
1 |
<?php |
|
2 |
|
47
|
3 |
/* PowerAdmin, a friendly web-based admin tool for PowerDNS. |
|
4 |
* See <https://rejo.zenger.nl/poweradmin> for more details. |
|
5 |
* |
|
6 |
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl> |
|
7 |
* |
|
8 |
* This program is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
*/ |
|
21 |
|
1
|
22 |
require_once("inc/toolkit.inc.php"); |
|
23 |
include_once("inc/header.inc.php"); |
|
24 |
|
82
|
25 |
$edit_id = "-1"; |
|
26 |
if (isset($_GET['id']) && v_num($_GET['id'])) { |
|
27 |
$edit_id = $_GET['id']; |
1
|
28 |
} |
82
|
29 |
|
|
30 |
verify_permission(user_edit_own) ? $perm_edit_own = "1" : $perm_edit_own = "0" ; |
|
31 |
verify_permission(user_edit_others) ? $perm_edit_others = "1" : $perm_edit_others = "0" ; |
|
32 |
|
|
33 |
if ($edit_id == "-1") { |
|
34 |
error(ERR_INV_INPUT); |
|
35 |
} elseif (($edit_id == $_SESSION["userid"] && $perm_edit_own == "1") || ($edit_id != $_SESSION["userid"] && $perm_edit_others == "1" )) { |
|
36 |
|
|
37 |
if($_POST["commit"]) { |
|
38 |
|
|
39 |
$i_username = "-1"; |
|
40 |
$i_fullname = "-1"; |
|
41 |
$i_email = "-1"; |
|
42 |
$i_description = "-1"; |
|
43 |
$i_password = "-1"; |
|
44 |
$i_perm_templ = "0"; |
|
45 |
$i_active = "0"; |
|
46 |
|
|
47 |
if (isset($_POST['username'])) { |
|
48 |
$i_username = $_POST['username']; |
|
49 |
} |
|
50 |
|
|
51 |
if (isset($_POST['fullname'])) { |
|
52 |
$i_fullname = $_POST['fullname']; |
|
53 |
} |
|
54 |
|
|
55 |
if (isset($_POST['email'])) { |
|
56 |
$i_email = $_POST['email']; |
|
57 |
} |
|
58 |
|
|
59 |
if (isset($_POST['description'])) { |
|
60 |
$i_description = $_POST['description']; |
|
61 |
} |
|
62 |
|
|
63 |
if (isset($_POST['password'])) { |
|
64 |
$i_password = $_POST['password']; |
|
65 |
} |
|
66 |
|
|
67 |
if (isset($_POST['perm_templ']) && v_num($_POST['perm_templ'])) { |
|
68 |
$i_perm_templ = $_POST['perm_templ']; |
|
69 |
} |
|
70 |
|
|
71 |
if (isset($_POST['active']) && v_num($_POST['active'])) { |
|
72 |
$i_active = $_POST['active']; |
|
73 |
} |
|
74 |
|
|
75 |
if ( $i_username == "-1" || $i_fullname == "-1" || $i_email < "1" || $i_description == "-1" || $i_password == "-1" ) { |
|
76 |
error(ERR_INV_INPUT); |
|
77 |
} else { |
|
78 |
if($i_username != "" && $i_perm_templ > "0" && $i_fullname) { |
|
79 |
if(!isset($i_active)) { |
|
80 |
$active = 0; |
|
81 |
} else { |
|
82 |
$active = 1; |
|
83 |
} |
|
84 |
if(edit_user($edit_id, $i_username, $i_fullname, $i_email, $i_perm_templ, $i_description, $active, $i_password)) { |
|
85 |
success(SUC_USER_UPD); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
$users = get_user_detail_list($edit_id) ; |
|
92 |
|
|
93 |
foreach ($users as $user) { |
|
94 |
|
|
95 |
(($user['active']) == "1") ? $check = " CHECKED" : $check = "" ; |
|
96 |
|
|
97 |
echo " <h2>" . _('Edit user') . " \"" . $user['fullname'] . "\"</h2>\n"; |
|
98 |
echo " <form method=\"post\">\n"; |
|
99 |
echo " <input type=\"hidden\" name=\"number\" value=\"" . $edit_id . "\">\n"; |
|
100 |
echo " <table>\n"; |
|
101 |
echo " <tr>\n"; |
|
102 |
echo " <td class=\"n\">" . _('Username') . "</td>\n"; |
|
103 |
echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"username\" value=\"" . $user['username'] . "\"></td>\n"; |
|
104 |
echo " </tr>\n"; |
|
105 |
echo " <tr>\n"; |
|
106 |
echo " <td class=\"n\">" . _('Fullname') . "</td>\n"; |
|
107 |
echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"fullname\" value=\"" . $user['fullname'] . "\"></td>\n"; |
|
108 |
echo " </tr>\n"; |
|
109 |
echo " <tr>\n"; |
|
110 |
echo " <td class=\"n\">" . _('Password') . "</td>\n"; |
103
|
111 |
echo " <td class=\"n\"><input type=\"password\" class=\"input\" name=\"password\"></td>\n"; |
82
|
112 |
echo " </tr>\n"; |
|
113 |
echo " <tr>\n"; |
110
|
114 |
echo " <td class=\"n\">" . _('Emailaddress') . "</td>\n"; |
82
|
115 |
echo " <td class=\"n\"><input type=\"text\" class=\"input\" name=\"email\" value=\"" . $user['email'] . "\"></td>\n"; |
|
116 |
echo " </tr>\n"; |
|
117 |
echo " <tr>\n"; |
|
118 |
echo " <td class=\"n\">" . _('Permission template') . "</td>\n"; |
|
119 |
echo " <td class=\"n\">\n"; |
|
120 |
echo " <select name=\"perm_templ\">\n"; |
|
121 |
foreach (list_permission_templates() as $template) { |
|
122 |
($template['id'] == $user['tpl_id']) ? $select = " SELECTED" : $select = "" ; |
|
123 |
echo " <option value=\"" . $template['id'] . "\"" . $select . ">" . $template['name'] . "</option>\n"; |
|
124 |
} |
|
125 |
echo " </select>\n"; |
|
126 |
echo " </td>\n"; |
|
127 |
echo " </tr>\n"; |
|
128 |
echo " <tr>\n"; |
|
129 |
echo " <td class=\"n\">" . _('Description') . "</td>\n"; |
|
130 |
echo " <td class=\"n\"><textarea rows=\"4\" cols=\"30\" class=\"inputarea\" name=\"description\">" . $user['descr'] . "</textarea></td>\n"; |
|
131 |
echo " </tr>\n"; |
|
132 |
echo " <tr>\n"; |
|
133 |
echo " <td class=\"n\">" . _('Enabled') . "</td>\n"; |
|
134 |
echo " <td class=\"n\"><input type=\"checkbox\" class=\"input\" name=\"active\" value=\"1\"" . $check . "></td>\n"; |
|
135 |
echo " </tr>\n"; |
|
136 |
echo " <tr>\n"; |
|
137 |
echo " <td class=\"n\"> </td>\n"; |
|
138 |
echo " <td class=\"n\"><input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\"></td>\n"; |
|
139 |
echo " </table>\n"; |
|
140 |
echo " </form>\n"; |
|
141 |
|
|
142 |
echo " <p>\n"; |
|
143 |
printf(" This user has been assigned the \"%s\" permission template.", $user['tpl_name']); |
|
144 |
if ($user['tpl_descr'] != "") { |
|
145 |
echo " The description for this template is: \"" . $user['tpl_descr'] . "\"."; |
|
146 |
} |
|
147 |
echo " Based on this template, this user has the following permissions:"; |
|
148 |
echo " </p>\n"; |
|
149 |
echo " <ul>\n"; |
|
150 |
foreach (get_permissions_by_template_id($user['tpl_id']) as $item) { |
|
151 |
echo " <li>" . $item['descr'] . " (" . $item['name'] . ")</li>\n"; |
|
152 |
} |
|
153 |
echo " </ul>\n"; |
|
154 |
} |
|
155 |
} else { |
|
156 |
error(ERR_PERM_EDIT_USER); |
|
157 |
} |
1
|
158 |
|
|
159 |
include_once("inc/footer.inc.php"); |
|
160 |
|
|
161 |
?> |