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 |
|
|
24 |
// Assigning records to user: Check for records owned by user |
45
|
25 |
$recordOwnerError = ''; |
1
|
26 |
if (isset($_POST["action"]) && $_POST["action"]=="record-user") { |
45
|
27 |
if (!is_array($_POST['rowid'])) { |
|
28 |
$recordOwnerError = 'No records where selected to assign an sub-owner.'; |
|
29 |
} else { |
|
30 |
foreach ($_POST["rowid"] as $x_user => $x_value){ |
|
31 |
$x_userid = $db->queryOne("SELECT id FROM record_owners WHERE user_id = '".$_POST["userid"]."' AND record_id='".$x_value."'"); |
|
32 |
if (empty($x_userid)) { |
|
33 |
$db->query("INSERT INTO record_owners SET user_id = '".$_POST["userid"]."',record_id='".$x_value."'"); |
|
34 |
} |
13
|
35 |
} |
|
36 |
} |
1
|
37 |
} |
13
|
38 |
if(isset($_POST['change_slave_master']) && is_numeric($_POST["domain"]) && level(5)) |
|
39 |
{ |
|
40 |
change_domain_slave_master($_POST['domain'], $_POST['slave_master']); |
|
41 |
} |
1
|
42 |
if(isset($_POST['type_change']) && in_array($_POST['newtype'], $server_types)) |
|
43 |
{ |
13
|
44 |
change_domain_type($_POST['newtype'], $_GET['id']); |
1
|
45 |
} |
|
46 |
if(isset($_POST["newowner"]) && is_numeric($_POST["domain"]) && is_numeric($_POST["newowner"])) |
|
47 |
{ |
|
48 |
add_owner($_POST["domain"], $_POST["newowner"]); |
|
49 |
} |
|
50 |
if(isset($_POST["del_user"]) && is_numeric($_POST["del_user"]) && level(5)) |
|
51 |
{ |
|
52 |
delete_owner($_GET["id"], $_POST["del_user"]); |
|
53 |
} |
13
|
54 |
$info = get_domain_info_from_id($_GET["id"]); |
1
|
55 |
include_once("inc/header.inc.php"); |
38
|
56 |
|
|
57 |
$domain_type=get_domain_type($_GET['id']); |
|
58 |
if ($domain_type == "SLAVE" ) { $slave_master=get_domain_slave_master($_GET['id']); }; |
13
|
59 |
|
45
|
60 |
if (strlen($recordOwnerError)) { |
|
61 |
?> |
|
62 |
<div class="error"><?php echo _('Error'); ?>: <?php echo _($recordOwnerError); ?></div> |
|
63 |
<?php |
|
64 |
} |
|
65 |
|
38
|
66 |
if(!isset($info["ownerid"]) && $domain_type != "SLAVE") |
13
|
67 |
{ |
1
|
68 |
?> |
38
|
69 |
<div class="error"><? echo _('Error'); ?>: <? echo ('There is no owner for this zone, please assign someone.'); ?></div> |
13
|
70 |
<? |
|
71 |
} |
41
|
72 |
if ($domain_type == "SLAVE" && ! $slave_master ) |
38
|
73 |
{ |
|
74 |
?> |
|
75 |
<div class="error"><? echo _('Error'); ?>: <? echo _('Type of this zone is "slave", but there is no IP address for it\'s master given.'); ?></div> |
|
76 |
<? |
|
77 |
} |
13
|
78 |
?> |
|
79 |
<h2><? echo _('Edit zone'); ?> "<? echo get_domain_name_from_id($_GET["id"]) ?>"</h2> |
|
80 |
<? |
|
81 |
if (level(5)) |
|
82 |
{ ?> |
|
83 |
<div id="meta"> |
|
84 |
<div id="meta-left"> |
|
85 |
<table> |
|
86 |
<tr> |
|
87 |
<th colspan="2"><? echo _('Owner of zone'); ?></th> |
|
88 |
</tr> |
|
89 |
<? |
|
90 |
if(isset($info["ownerid"])) |
|
91 |
{ |
|
92 |
$userRes = get_users_from_domain_id($_GET["id"]); |
|
93 |
foreach($userRes as $user) |
|
94 |
{ ?> |
|
95 |
<tr> |
|
96 |
<form method="post" action="edit.php?id=<? echo $_GET['id']?>"> |
|
97 |
<td> |
|
98 |
<? echo $user["fullname"]?> |
|
99 |
</td> |
|
100 |
<td> |
|
101 |
<input type="hidden" name="del_user" value="<? echo $user["id"]?>"> |
|
102 |
<input type="submit" class="sbutton" name="co" value="<? echo _('Delete'); ?>"> |
|
103 |
</td> |
|
104 |
</form> |
|
105 |
</tr> |
|
106 |
<? |
|
107 |
} |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
?> |
|
112 |
<tr> |
|
113 |
<td><? echo _('No owner set or this zone!'); ?></td> |
|
114 |
</tr> |
1
|
115 |
<? |
13
|
116 |
} |
|
117 |
?> |
|
118 |
<tr> |
|
119 |
<form method="post" action="edit.php?id=<? echo $_GET['id']?>"> |
|
120 |
<td> |
|
121 |
<input type="hidden" name="domain" value="<? echo $_GET["id"] ?>"> |
|
122 |
<select name="newowner"> |
|
123 |
<? |
|
124 |
$users = show_users(); |
|
125 |
foreach ($users as $u) |
|
126 |
{ |
|
127 |
unset($add); |
|
128 |
if ($u["id"] == $info["ownerid"]) |
|
129 |
{ |
|
130 |
$add = " SELECTED"; |
|
131 |
} |
|
132 |
?> |
|
133 |
<option<? echo $add ?> value="<? echo $u["id"] ?>"><? echo $u["fullname"] ?></option><? |
|
134 |
} |
|
135 |
?> |
|
136 |
</select> |
|
137 |
</td> |
|
138 |
<td> |
|
139 |
<input type="submit" class="sbutton" name="co" value="<? echo _('Add'); ?>"> |
|
140 |
</td> |
|
141 |
</form> |
|
142 |
</tr> |
|
143 |
</table> |
|
144 |
</div> <? // eo div meta-left ?> |
|
145 |
<div id="meta-right"> |
|
146 |
<table> |
|
147 |
<tr> |
|
148 |
<th colspan="2"><? echo _('Type of zone'); ?></th> |
|
149 |
</tr> |
|
150 |
<form action="<? echo $_SERVER['PHP_SELF']?>?id=<? echo $_GET['id']?>" method="post"> |
|
151 |
<input type="hidden" name="domain" value="<? echo $_GET["id"] ?>"> |
|
152 |
<tr> |
|
153 |
<td> |
|
154 |
<select name="newtype"> |
|
155 |
<? |
|
156 |
foreach($server_types as $s) |
|
157 |
{ |
|
158 |
unset($add); |
|
159 |
if ($s == $domain_type) |
|
160 |
{ |
|
161 |
$add = " SELECTED"; |
|
162 |
} |
|
163 |
?> |
|
164 |
<option<? echo $add ?> value="<? echo $s?>"><? echo $s?></option><? |
|
165 |
} |
|
166 |
?> |
|
167 |
</select> |
|
168 |
</td> |
|
169 |
<td> |
|
170 |
<input type="submit" class="sbutton" name="type_change" value="<? echo _('Change'); ?>"> |
|
171 |
</td> |
|
172 |
</tr> |
|
173 |
</form> |
|
174 |
|
|
175 |
<? |
|
176 |
if ($domain_type == "SLAVE" ) |
|
177 |
{ |
|
178 |
$slave_master=get_domain_slave_master($_GET['id']); |
|
179 |
?> |
|
180 |
<tr> |
|
181 |
<th colspan="2"> |
|
182 |
<? echo _('IP address of master NS'); ?> |
|
183 |
</th> |
|
184 |
</tr> |
|
185 |
<form action="<? echo $_SERVER['PHP_SELF']?>?&id=<? echo $_GET['id']?>" method="post"> |
|
186 |
<input type="hidden" name="domain" value="<? echo $_GET["id"] ?>"> |
|
187 |
<tr> |
|
188 |
<td> |
|
189 |
<input type="text" name="slave_master" value="<? echo $slave_master; ?>" class="input"> |
|
190 |
</td> |
|
191 |
<td> |
|
192 |
<input type="submit" class="sbutton" name="change_slave_master" value="<? echo _('Change'); ?>"> |
|
193 |
</td> |
|
194 |
</tr> |
|
195 |
</form> |
|
196 |
<? |
|
197 |
} |
1
|
198 |
?> |
13
|
199 |
</table> |
|
200 |
</div> <? // eo div meta-right ?> |
38
|
201 |
</div> <? // eo div meta |
|
202 |
} |
|
203 |
else |
|
204 |
{ |
|
205 |
?> |
|
206 |
<div id="meta"> |
|
207 |
<div id="meta-right"> |
|
208 |
<table> |
|
209 |
<tr> |
|
210 |
<th><? echo _('Type of zone'); ?></th><td class="y"><? echo $domain_type; ?></td> |
|
211 |
</tr> |
|
212 |
<? |
|
213 |
if ($domain_type == "SLAVE" && $slave_master ) |
|
214 |
{ |
|
215 |
?> |
|
216 |
<tr> |
|
217 |
<th><? echo _('IP address of master NS'); ?></th><td class="y"><? echo $slave_master; ?></td> |
|
218 |
</tr> |
|
219 |
<? |
|
220 |
} |
|
221 |
?> |
|
222 |
</table> |
|
223 |
</div> <? //eo div meta-right ?> |
|
224 |
</div> <? // eo div meta |
|
225 |
} |
|
226 |
?> |
13
|
227 |
<div id="meta"> |
|
228 |
<? |
|
229 |
if ($_SESSION[$_GET["id"]."_ispartial"] != 1 && $domain_type != "SLAVE" ) |
|
230 |
{ |
1
|
231 |
?> |
13
|
232 |
<input type="button" class="button" OnClick="location.href='add_record.php?id=<? echo $_GET["id"] ?>'" value="<? echo _('Add record'); ?>"> |
|
233 |
<? |
|
234 |
} |
|
235 |
if (level(5)) |
|
236 |
{ |
|
237 |
?> |
|
238 |
<input type="button" class="button" OnClick="location.href='delete_domain.php?id=<? echo $_GET["id"] ?>'" value="<? echo _('Delete zone'); ?>"> |
|
239 |
<? |
|
240 |
} |
|
241 |
?> |
|
242 |
</div> <? // eo div meta ?> |
|
243 |
<div class="showmax"> |
1
|
244 |
<? |
|
245 |
show_pages($info["numrec"],ROWAMOUNT,$_GET["id"]); |
|
246 |
?> |
13
|
247 |
</div> <? // eo div showmax ?> |
|
248 |
<form action="<? echo $_SERVER["PHP_SELF"]?>?id=<? echo $_GET["id"]?>" method="post"> |
|
249 |
<input type="hidden" name="action" value="record-user"> |
|
250 |
<table> |
1
|
251 |
<? |
|
252 |
$countinput=0; |
|
253 |
$rec_result = get_records_from_domain_id($_GET["id"],ROWSTART,ROWAMOUNT); |
|
254 |
if($rec_result != -1) |
|
255 |
{ |
13
|
256 |
?> |
|
257 |
<tr> |
|
258 |
<th> </th> |
|
259 |
<? |
|
260 |
if (level(10) && $domain_type != "SLAVE") |
|
261 |
{ |
|
262 |
echo "<th class=\"n\">" . _('Sub-owners') . "</td>"; |
|
263 |
} |
|
264 |
?> |
|
265 |
<th><? echo _('Name'); ?></th> |
|
266 |
<th><? echo _('Type'); ?></th> |
|
267 |
<th><? echo _('Content'); ?></th> |
|
268 |
<th><? echo _('Priority'); ?></th> |
|
269 |
<th><? echo _('TTL'); ?></th> |
|
270 |
</tr> |
|
271 |
<? |
|
272 |
$recs = sort_zone($rec_result); |
|
273 |
foreach($recs as $r) |
|
274 |
{ |
|
275 |
?> |
|
276 |
<tr> |
|
277 |
<td class="n"> |
|
278 |
<? |
|
279 |
if ($domain_type != "SLAVE" ) |
|
280 |
{ |
|
281 |
if(level(5) || (!($r["type"] == "SOA" && !$GLOBALS["ALLOW_SOA_EDIT"]) && !($r["type"] == "NS" && !$GLOBALS["ALLOW_NS_EDIT"]))) |
|
282 |
{ |
|
283 |
?> |
38
|
284 |
<a href="edit_record.php?id=<? echo $r['id'] ?>&domain=<? echo $_GET["id"] ?>"><img src="images/edit.gif" alt="[ <? echo _('Edit record'); ?> ]"></a> |
|
285 |
<a href="delete_record.php?id=<? echo $r['id'] ?>&domain=<? echo $_GET["id"] ?>"><img src="images/delete.gif" ALT="[ <? echo _('Delete record'); ?> ]" BORDER="0"></a> |
1
|
286 |
<? |
13
|
287 |
} |
|
288 |
} |
|
289 |
if(level(10) && $domain_type != "SLAVE") |
|
290 |
{ |
|
291 |
?> |
38
|
292 |
<input type="checkbox" name="rowid[<? echo $countinput++?>]" value="<? echo $r['id']?>" /> |
13
|
293 |
<? |
|
294 |
} |
|
295 |
?> |
|
296 |
</td> |
|
297 |
<? |
|
298 |
if (level(10) && $domain_type != "SLAVE") |
|
299 |
{ |
1
|
300 |
?> |
13
|
301 |
<td class="n"> |
|
302 |
<? |
|
303 |
$x_result = $db->query("SELECT r.user_id,u.username,u.fullname FROM record_owners as r, users as u WHERE r.record_id='".$r['id']."' AND u.id=r.user_id"); |
|
304 |
echo "<select style=\"width:120px;\">"; |
|
305 |
while ($x_r = $x_result->fetchRow()) { |
|
306 |
echo "<option value=\"".$x_r["username"]."\">".$x_r["fullname"]."</option>"; |
|
307 |
} |
|
308 |
echo "</select>"; |
|
309 |
?> |
|
310 |
</td> |
|
311 |
<? |
|
312 |
} |
|
313 |
?> |
|
314 |
<td class="y"><? echo $r['name'] ?></td> |
|
315 |
<td class="y"><? echo $r['type'] ?></td> |
|
316 |
<td class="y"><? echo $r['content'] ?></td> |
|
317 |
<? |
|
318 |
if ($r['prio'] != 0) |
|
319 |
{ |
|
320 |
?> |
|
321 |
<td class="y"><? echo $r['prio']; ?></td> |
|
322 |
<? |
|
323 |
} else { |
|
324 |
?> |
|
325 |
<td class="n"></td><? |
|
326 |
} |
|
327 |
?> |
|
328 |
<td class="y"><? echo $r['ttl'] ?></td> |
|
329 |
</tr> |
|
330 |
<? |
1
|
331 |
} |
|
332 |
} |
|
333 |
else |
|
334 |
{ |
|
335 |
?> |
13
|
336 |
<tr> |
|
337 |
<td class="n"> |
|
338 |
<div class="warning"><? echo _('No records for this zone.'); ?></div> |
|
339 |
</td> |
|
340 |
</tr> |
1
|
341 |
<? |
|
342 |
} |
|
343 |
?> |
13
|
344 |
</table> |
1
|
345 |
|
13
|
346 |
<? |
|
347 |
if ($domain_type != "SLAVE") |
|
348 |
{ |
|
349 |
if (level(10)) { ?> |
|
350 |
<img src="images/arrow.png" alt="arrow" class="edit-assign-to-user"> |
|
351 |
<select name="userid"> |
|
352 |
<? |
|
353 |
$users = show_users(); |
|
354 |
foreach ($users as $user) { |
|
355 |
echo "<option value=\"".$user[id]."\">".$user[fullname]."</option>"; |
|
356 |
} |
|
357 |
?> |
|
358 |
</select> |
|
359 |
<input type="submit" class="button" value="<? echo _('Assign to user'); ?>"> |
|
360 |
</form> |
|
361 |
<? |
|
362 |
} |
1
|
363 |
} |
|
364 |
include_once("inc/footer.inc.php"); |
|
365 |
?> |