1
|
1 |
<?php |
|
2 |
|
119
|
3 |
/* Poweradmin, a friendly web-based admin tool for PowerDNS. |
47
|
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"); |
82
|
23 |
include_once("inc/header.inc.php"); |
1
|
24 |
|
82
|
25 |
$zone_id = "-1"; |
|
26 |
if (isset($_GET['id']) && v_num($_GET['id'])) { |
|
27 |
$zone_id = $_GET['id']; |
|
28 |
} |
|
29 |
|
|
30 |
if ($zone_id == "-1") { |
|
31 |
error(ERR_INV_INPUT); |
|
32 |
include_once("inc/footer.inc.php"); |
|
33 |
exit; |
|
34 |
} |
|
35 |
|
|
36 |
if (isset($_POST['commit'])) { |
|
37 |
foreach ($_POST['record'] as $record) { |
|
38 |
edit_record($record); |
13
|
39 |
} |
1
|
40 |
} |
82
|
41 |
|
|
42 |
if (verify_permission(zone_content_view_others)) { $perm_view = "all" ; } |
|
43 |
elseif (verify_permission(zone_content_view_own)) { $perm_view = "own" ; } |
|
44 |
else { $perm_view = "none" ; } |
|
45 |
|
|
46 |
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
47 |
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
48 |
else { $perm_content_edit = "none" ; } |
|
49 |
|
|
50 |
if (verify_permission(zone_meta_edit_others)) { $perm_meta_edit = "all" ; } |
|
51 |
elseif (verify_permission(zone_meta_edit_own)) { $perm_meta_edit = "own" ; } |
|
52 |
else { $perm_meta_edit = "none" ; } |
|
53 |
|
|
54 |
$user_is_zone_owner = verify_user_is_owner_zoneid($zone_id); |
|
55 |
if ( $perm_meta_edit == "all" || ( $perm_meta_edit == "own" && $user_is_zone_owner == "1") ) { |
|
56 |
$meta_edit = "1"; |
1
|
57 |
} |
82
|
58 |
|
|
59 |
if(isset($_POST['slave_master_change']) && is_numeric($_POST["domain"]) ) { |
|
60 |
change_zone_slave_master($_POST['domain'], $_POST['new_master']); |
1
|
61 |
} |
82
|
62 |
if(isset($_POST['type_change']) && in_array($_POST['newtype'], $server_types)) { |
|
63 |
change_zone_type($_POST['newtype'], $zone_id); |
|
64 |
} |
|
65 |
if(isset($_POST["newowner"]) && is_numeric($_POST["domain"]) && is_numeric($_POST["newowner"])) { |
|
66 |
add_owner_to_zone($_POST["domain"], $_POST["newowner"]); |
|
67 |
} |
|
68 |
if(isset($_POST["delete_owner"]) && is_numeric($_POST["delete_owner"]) ) { |
|
69 |
delete_owner_from_zone($zone_id, $_POST["delete_owner"]); |
45
|
70 |
} |
|
71 |
|
82
|
72 |
$domain_type=get_domain_type($zone_id); |
|
73 |
$record_count=count_zone_records($zone_id); |
|
74 |
|
|
75 |
echo " <h2>" . _('Edit zone') . " \"" . get_domain_name_from_id($zone_id) . "\"</h2>\n"; |
|
76 |
|
|
77 |
if ( $perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0" ) { |
|
78 |
error(ERR_PERM_VIEW_ZONE); |
|
79 |
} else { |
|
80 |
echo " <div class=\"showmax\">\n"; |
|
81 |
show_pages($record_count,ROWAMOUNT,$zone_id); |
|
82 |
echo " </div>\n"; |
|
83 |
|
|
84 |
$records = get_records_from_domain_id($zone_id,ROWSTART,ROWAMOUNT); |
|
85 |
if ( $records == "-1" ) { |
|
86 |
echo " <p>" . _("This zone does not have any records. Weird.") . "</p>\n"; |
|
87 |
} else { |
|
88 |
echo " <form method=\"post\">\n"; |
|
89 |
echo " <table>\n"; |
|
90 |
echo " <tr>\n"; |
|
91 |
echo " <th> </th>\n"; |
|
92 |
echo " <th>" . _('Name') . "</th>\n"; |
|
93 |
echo " <th>" . _('Type') . "</th>\n"; |
|
94 |
echo " <th>" . _('Content') . "</th>\n"; |
|
95 |
echo " <th>" . _('Priority') . "</th>\n"; |
|
96 |
echo " <th>" . _('TTL') . "</th>\n"; |
|
97 |
echo " </tr>\n"; |
|
98 |
foreach ($records as $r) { |
|
99 |
echo " <input type=\"hidden\" name=\"record[" . $r['id'] . "][rid]\" value=\"" . $r['id'] . "\">\n"; |
|
100 |
echo " <input type=\"hidden\" name=\"record[" . $r['id'] . "][zid]\" value=\"" . $zone_id . "\">\n"; |
|
101 |
echo " <tr>\n"; |
|
102 |
if ( $domain_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
103 |
echo " <td class=\"n\"> </td>\n"; |
|
104 |
} else { |
|
105 |
echo " <td class=\"n\">\n"; |
|
106 |
echo " <a href=\"edit_record.php?id=" . $r['id'] . "&domain=" . $zone_id . "\"> |
|
107 |
<img src=\"images/edit.gif\" alt=\"[ ". _('Edit record') . " ]\"></a>\n"; |
|
108 |
echo " <a href=\"delete_record.php?id=" . $r['id'] . "&domain=" . $zone_id . "\"> |
|
109 |
<img src=\"images/delete.gif\" ALT=\"[ " . _('Delete record') . " ]\" BORDER=\"0\"></a>\n"; |
|
110 |
echo " </td>\n"; |
|
111 |
} |
|
112 |
echo " <td class=\"u\"><input class=\"wide\" name=\"record[" . $r['id'] . "][name]\" value=\"" . $r['name'] . "\"></td>\n"; |
|
113 |
echo " <td class=\"u\">\n"; |
|
114 |
echo " <select name=\"record[" . $r['id'] . "][type]\">\n"; |
|
115 |
foreach (get_record_types() as $type_available) { |
|
116 |
if ($type_available == $r["type"]) { |
|
117 |
$add = " SELECTED"; |
|
118 |
} else { |
|
119 |
$add = ""; |
|
120 |
} |
|
121 |
echo " <option" . $add . " value=\"" . $type_available . "\" >" . $type_available . "</option>\n"; |
|
122 |
} |
|
123 |
echo " </select>\n"; |
|
124 |
echo " </td>\n"; |
|
125 |
echo " <td class=\"u\"><input class=\"wide\" name=\"record[" . $r['id'] . "][content]\" value=\"" . $r['content'] . "\"></td>\n"; |
|
126 |
if ($r['type'] == "MX") { |
|
127 |
echo " <td class=\"u\"><input name=\"record[" . $r['id'] . "][prio]\" value=\"" . $r['prio'] . "\"></td>\n"; |
|
128 |
} else { |
|
129 |
echo " <td class=\"n\"> </td>\n"; |
|
130 |
} |
|
131 |
echo " <td class=\"u\"><input name=\"record[" . $r['id'] . "][ttl]\" value=\"" . $r['ttl'] . "\"></td>\n"; |
|
132 |
echo " </tr>\n"; |
|
133 |
} |
|
134 |
echo " </table>\n"; |
|
135 |
echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n"; |
|
136 |
echo " </form>"; |
|
137 |
} |
|
138 |
|
|
139 |
if ( $perm_content_edit == "all" || $perm_content_edit == "own" && $user_is_zone_owner == "1" ) { |
|
140 |
if ( $domain_type != "SLAVE") { |
|
141 |
echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='add_record.php?id=" . $zone_id . "'\" value=\"" . _('Add record') . "\">  \n"; |
|
142 |
} |
|
143 |
echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='delete_domain.php?id=" . $zone_id . "'\" value=\"" . _('Delete zone') . "\">\n"; |
|
144 |
} |
|
145 |
|
|
146 |
echo " <div id=\"meta\">\n"; |
|
147 |
echo " <table>\n"; |
|
148 |
echo " <tr>\n"; |
|
149 |
echo " <th colspan=\"2\">" . _('Owner of zone') . "</th>\n"; |
|
150 |
echo " </tr>\n"; |
|
151 |
|
|
152 |
$owners = get_users_from_domain_id($zone_id); |
|
153 |
|
|
154 |
if ($owners == "-1") { |
111
|
155 |
echo " <tr><td>" . _('No owner set for this zone.') . "</td></tr>"; |
82
|
156 |
} else { |
|
157 |
if ($meta_edit) { |
|
158 |
foreach ($owners as $owner) { |
|
159 |
echo " <form method=\"post\" action=\"edit.php?id=" . $zone_id . "\">\n"; |
|
160 |
echo " <tr>\n"; |
|
161 |
echo " <td>" . $owner["fullname"] . "</td>\n"; |
|
162 |
echo " <td>\n"; |
|
163 |
echo " <input type=\"hidden\" name=\"delete_owner\" value=\"" . $owner["id"] . "\">\n"; |
|
164 |
echo " <input type=\"submit\" class=\"sbutton\" name=\"co\" value=\"" . _('Delete') . "\">\n"; |
|
165 |
echo " </td>\n"; |
|
166 |
echo " </tr>\n"; |
|
167 |
echo " </form>\n"; |
|
168 |
} |
|
169 |
} else { |
|
170 |
foreach ($owners as $owner) { |
|
171 |
echo " <tr><td>" . $owner["fullname"] . "</td><td> </td></tr>"; |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
} |
|
176 |
if ($meta_edit) { |
|
177 |
echo " <form method=\"post\" action=\"edit.php?id=" . $zone_id . "\">\n"; |
|
178 |
echo " <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n"; |
|
179 |
echo " <tr>\n"; |
|
180 |
echo " <td>\n"; |
|
181 |
echo " <select name=\"newowner\">\n"; |
|
182 |
$users = show_users(); |
|
183 |
foreach ($users as $user) { |
|
184 |
unset($add); |
|
185 |
if ($user["id"] == $_SESSION["userid"]) { |
|
186 |
$add = " SELECTED"; |
|
187 |
} |
|
188 |
echo " <option" . $add . " value=\"" . $user["id"] . "\">" . $user["fullname"] . "</option>\n"; |
|
189 |
} |
|
190 |
echo " </select>\n"; |
|
191 |
echo " </td>\n"; |
|
192 |
echo " <td>\n"; |
|
193 |
echo " <input type=\"submit\" class=\"sbutton\" name=\"co\" value=\"" . _('Add') . "\">\n"; |
|
194 |
echo " </td>\n"; |
|
195 |
echo " </tr>\n"; |
|
196 |
echo " </form>\n"; |
|
197 |
} |
|
198 |
echo " <tr>\n"; |
111
|
199 |
echo " <th colspan=\"2\">" . _('Type') . "</th>\n"; |
82
|
200 |
echo " </tr>\n"; |
|
201 |
|
|
202 |
if ($meta_edit) { |
|
203 |
echo " <form action=\"" . $_SERVER['PHP_SELF'] . "?id=" . $zone_id . "\" method=\"post\">\n"; |
|
204 |
echo " <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n"; |
|
205 |
echo " <tr>\n"; |
|
206 |
echo " <td>\n"; |
|
207 |
echo " <select name=\"newtype\">\n"; |
|
208 |
foreach($server_types as $type) { |
|
209 |
unset($add); |
|
210 |
if ($type == $domain_type) { |
|
211 |
$add = " SELECTED"; |
|
212 |
} |
|
213 |
echo " <option" . $add . " value=\"" . $type . "\">" . strtolower($type) . "</option>\n"; |
|
214 |
} |
|
215 |
echo " </select>\n"; |
|
216 |
echo " </td>\n"; |
|
217 |
echo " <td>\n"; |
|
218 |
echo " <input type=\"submit\" class=\"sbutton\" name=\"type_change\" value=\"" . _('Change') . "\">\n"; |
|
219 |
echo " </td>\n"; |
|
220 |
echo " </tr>\n"; |
|
221 |
echo " </form>\n"; |
|
222 |
} else { |
|
223 |
echo " <tr><td>" . strtolower($domain_type) . "</td><td> </td></tr>\n"; |
|
224 |
} |
|
225 |
|
|
226 |
if ($domain_type == "SLAVE" ) { |
|
227 |
$slave_master=get_domain_slave_master($zone_id); |
|
228 |
echo " <tr>\n"; |
|
229 |
echo " <th colspan=\"2\">" . _('IP address of master NS') . "</th>\n"; |
|
230 |
echo " </tr>\n"; |
|
231 |
|
|
232 |
if ($meta_edit) { |
|
233 |
echo " <form action=\"" . $_SERVER['PHP_SELF'] . "?id=" . $zone_id . "\" method=\"post\">\n"; |
|
234 |
echo " <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n"; |
|
235 |
echo " <tr>\n"; |
|
236 |
echo " <td>\n"; |
|
237 |
echo " <input type=\"text\" name=\"new_master\" value=\"" . $slave_master . "\" class=\"input\">\n"; |
|
238 |
echo " </td>\n"; |
|
239 |
echo " <td>\n"; |
|
240 |
echo " <input type=\"submit\" class=\"sbutton\" name=\"slave_master_change\" value=\"" . _('Change') . "\">\n"; |
|
241 |
echo " </td>\n"; |
|
242 |
echo " </tr>\n"; |
|
243 |
echo " </form>\n"; |
|
244 |
} else { |
|
245 |
echo " <tr><td>" . $slave_master . "</td><td> </td></tr>\n"; |
13
|
246 |
} |
|
247 |
} |
82
|
248 |
echo " </table>\n"; |
|
249 |
echo " </div>\n"; // eo div meta |
38
|
250 |
} |
1
|
251 |
|
|
252 |
include_once("inc/footer.inc.php"); |
|
253 |
?> |