71
|
1 |
<?php |
1
|
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 |
*/ |
1
|
21 |
|
82
|
22 |
function count_zone_records($zone_id) { |
|
23 |
global $db; |
|
24 |
$sqlq = "SELECT COUNT(id) FROM records WHERE domain_id = ".$db->quote($zone_id); |
|
25 |
$record_count = $db->queryOne($sqlq); |
|
26 |
return $record_count; |
|
27 |
} |
|
28 |
|
1
|
29 |
function update_soa_serial($domain_id) |
|
30 |
{ |
82
|
31 |
global $db; |
1
|
32 |
|
65
|
33 |
$sqlq = "SELECT notified_serial FROM domains WHERE id = ".$db->quote($domain_id); |
8
|
34 |
$notified_serial = $db->queryOne($sqlq); |
1
|
35 |
|
65
|
36 |
$sqlq = "SELECT content FROM records WHERE type = 'SOA' AND domain_id = ".$db->quote($domain_id); |
8
|
37 |
$content = $db->queryOne($sqlq); |
82
|
38 |
$need_to_update = false; |
|
39 |
|
1
|
40 |
// Getting the serial field. |
|
41 |
$soa = explode(" ", $content); |
82
|
42 |
|
|
43 |
if(empty($notified_serial)) { |
|
44 |
// Ok native replication, so we have to update. |
|
45 |
$need_to_update = true; |
|
46 |
} elseif($notified_serial >= $soa[2]) { |
|
47 |
$need_to_update = true; |
|
48 |
} elseif(strlen($soa[2]) != 10) { |
|
49 |
$need_to_update = true; |
|
50 |
} else { |
|
51 |
$need_to_update = false; |
|
52 |
} |
|
53 |
|
|
54 |
if($need_to_update) { |
|
55 |
// Ok so we have to update it seems. |
|
56 |
$current_serial = $soa[2]; |
1
|
57 |
$new_serial = date('Ymd'); // we will add revision number later |
|
58 |
|
82
|
59 |
if(strncmp($new_serial, $current_serial, 8) === 0) { |
|
60 |
$revision_number = (int) substr($current_serial, -2); |
|
61 |
if ($revision_number == 99) return false; // ok, we cannot update anymore tonight |
|
62 |
++$revision_number; |
|
63 |
// here it is ... same date, new revision |
|
64 |
$new_serial .= str_pad($revision_number, 2, "0", STR_PAD_LEFT); |
|
65 |
} else { |
|
66 |
/* |
1
|
67 |
* Current serial is not RFC1912 compilant, so let's make a new one |
|
68 |
*/ |
82
|
69 |
$new_serial .= '00'; |
1
|
70 |
} |
82
|
71 |
$soa[2] = $new_serial; // change serial in SOA array |
1
|
72 |
$new_soa = ""; |
|
73 |
// build new soa and update SQL after that |
82
|
74 |
for ($i = 0; $i < count($soa); $i++) { |
1
|
75 |
$new_soa .= $soa[$i] . " "; |
|
76 |
} |
65
|
77 |
$sqlq = "UPDATE records SET content = ".$db->quote($new_soa)." WHERE domain_id = ".$db->quote($domain_id)." AND type = 'SOA'"; |
1
|
78 |
$db->Query($sqlq); |
|
79 |
return true; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
/* |
|
84 |
* Edit a record. |
|
85 |
* This function validates it if correct it inserts it into the database. |
|
86 |
* return values: true if succesful. |
|
87 |
*/ |
82
|
88 |
function edit_record($record) { |
|
89 |
|
|
90 |
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
91 |
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
92 |
else { $perm_content_edit = "none" ; } |
|
93 |
|
|
94 |
$user_is_zone_owner = verify_user_is_owner_zoneid($record['zid']); |
|
95 |
$zone_type = get_domain_type($record['zid']); |
|
96 |
|
|
97 |
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
111
|
98 |
error(ERR_PERM_EDIT_RECORD); |
|
99 |
return false; |
82
|
100 |
} else { |
|
101 |
if($record['content'] == "") { |
111
|
102 |
error(ERR_DNS_CONTENT); |
|
103 |
return false; |
82
|
104 |
} |
|
105 |
global $db; |
|
106 |
// TODO: no need to check for numeric-ness of zone id if we check with validate_input as well? |
|
107 |
if (is_numeric($record['zid'])) { |
|
108 |
validate_input($record['zid'], $record['type'], $record['content'], $record['name'], $record['prio'], $record['ttl']); |
|
109 |
$query = "UPDATE records |
|
110 |
SET name=".$db->quote($record['name']).", |
|
111 |
type=".$db->quote($record['type']).", |
|
112 |
content=".$db->quote($record['content']).", |
|
113 |
ttl=".$db->quote($record['ttl']).", |
|
114 |
prio=".$db->quote($record['prio']).", |
|
115 |
change_date=".$db->quote(time())." |
|
116 |
WHERE id=".$db->quote($record['rid']); |
|
117 |
$result = $db->Query($query); |
|
118 |
if (PEAR::isError($result)) { |
|
119 |
error($result->getMessage()); |
|
120 |
return false; |
|
121 |
} elseif ($record['type'] != 'SOA') { |
|
122 |
update_soa_serial($record['zid']); |
|
123 |
} |
|
124 |
return true; |
|
125 |
} |
|
126 |
else |
|
127 |
{ |
|
128 |
// TODO change to error style as above (returning directly) |
|
129 |
error(sprintf(ERR_INV_ARGC, "edit_record", "no zoneid given")); |
|
130 |
} |
1
|
131 |
} |
82
|
132 |
return true; |
1
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
/* |
|
137 |
* Adds a record. |
|
138 |
* This function validates it if correct it inserts it into the database. |
|
139 |
* return values: true if succesful. |
|
140 |
*/ |
82
|
141 |
function add_record($zoneid, $name, $type, $content, $ttl, $prio) { |
1
|
142 |
global $db; |
82
|
143 |
|
|
144 |
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
145 |
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
146 |
else { $perm_content_edit = "none" ; } |
|
147 |
|
|
148 |
$user_is_zone_owner = verify_user_is_owner_zoneid($zoneid); |
|
149 |
$zone_type = get_domain_type($zoneid); |
1
|
150 |
|
82
|
151 |
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
152 |
error(ERR_PERM_ADD_RECORD); |
|
153 |
return false; |
|
154 |
} else { |
|
155 |
if (validate_input($zoneid, $type, $content, $name, $prio, $ttl) ) { |
|
156 |
$change = time(); |
106
|
157 |
$query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES (" |
82
|
158 |
. $db->quote($zoneid) . "," |
|
159 |
. $db->quote($name) . "," |
|
160 |
. $db->quote($type) . "," |
|
161 |
. $db->quote($content) . "," |
|
162 |
. $db->quote($ttl) . "," |
|
163 |
. $db->quote($prio) . "," |
|
164 |
. $db->quote($change) . ")"; |
|
165 |
$response = $db->query($query); |
|
166 |
if (PEAR::isError($response)) { |
|
167 |
error($response->getMessage()); |
|
168 |
return false; |
|
169 |
} else { |
|
170 |
if ($type != 'SOA') { update_soa_serial($zoneid); } |
|
171 |
return true; |
|
172 |
} |
|
173 |
} else { |
|
174 |
return false; |
1
|
175 |
} |
|
176 |
return true; |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
|
13
|
181 |
function add_supermaster($master_ip, $ns_name, $account) |
|
182 |
{ |
|
183 |
global $db; |
82
|
184 |
if (!is_valid_ip($master_ip) && !is_valid_ip6($master_ip)) { |
|
185 |
error(ERR_DNS_IP); |
|
186 |
return false; |
13
|
187 |
} |
82
|
188 |
if (!is_valid_hostname($ns_name)) { |
13
|
189 |
error(ERR_DNS_HOSTNAME); |
82
|
190 |
return false; |
13
|
191 |
} |
82
|
192 |
if (!validate_account($account)) { |
13
|
193 |
error(sprintf(ERR_INV_ARGC, "add_supermaster", "given account name is invalid (alpha chars only)")); |
82
|
194 |
return false; |
13
|
195 |
} |
82
|
196 |
if (supermaster_exists($master_ip)) { |
|
197 |
error(ERR_SM_EXISTS); |
|
198 |
return false; |
|
199 |
} else { |
65
|
200 |
$db->query("INSERT INTO supermasters VALUES (".$db->quote($master_ip).", ".$db->quote($ns_name).", ".$db->quote($account).")"); |
13
|
201 |
return true; |
|
202 |
} |
|
203 |
} |
|
204 |
|
82
|
205 |
function delete_supermaster($master_ip) { |
|
206 |
global $db; |
13
|
207 |
if (is_valid_ip($master_ip) || is_valid_ip6($master_ip)) |
|
208 |
{ |
65
|
209 |
$db->query("DELETE FROM supermasters WHERE ip = ".$db->quote($master_ip)); |
13
|
210 |
return true; |
|
211 |
} |
|
212 |
else |
|
213 |
{ |
|
214 |
error(sprintf(ERR_INV_ARGC, "delete_supermaster", "No or no valid ipv4 or ipv6 address given.")); |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
function get_supermaster_info_from_ip($master_ip) |
|
219 |
{ |
|
220 |
global $db; |
|
221 |
if (is_valid_ip($master_ip) || is_valid_ip6($master_ip)) |
|
222 |
{ |
65
|
223 |
$result = $db->queryRow("SELECT ip,nameserver,account FROM supermasters WHERE ip = ".$db->quote($master_ip)); |
13
|
224 |
|
|
225 |
$ret = array( |
|
226 |
"master_ip" => $result["ip"], |
|
227 |
"ns_name" => $result["nameserver"], |
|
228 |
"account" => $result["account"] |
|
229 |
); |
|
230 |
|
|
231 |
return $ret; |
|
232 |
} |
|
233 |
else |
|
234 |
{ |
|
235 |
error(sprintf(ERR_INV_ARGC, "get_supermaster_info_from_ip", "No or no valid ipv4 or ipv6 address given.")); |
|
236 |
} |
|
237 |
} |
|
238 |
|
82
|
239 |
function get_record_details_from_record_id($rid) { |
|
240 |
|
|
241 |
global $db; |
|
242 |
|
98
|
243 |
$query = "SELECT id AS rid, domain_id AS zid, name, type, content, ttl, prio, change_date FROM records WHERE id = " . $db->quote($rid) ; |
82
|
244 |
|
|
245 |
$response = $db->query($query); |
|
246 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
98
|
247 |
|
|
248 |
$return = $response->fetchRow(); |
82
|
249 |
return $return; |
|
250 |
} |
13
|
251 |
|
1
|
252 |
/* |
|
253 |
* Delete a record by a given id. |
|
254 |
* return values: true, this function is always succesful. |
|
255 |
*/ |
82
|
256 |
function delete_record($rid) |
1
|
257 |
{ |
|
258 |
global $db; |
|
259 |
|
82
|
260 |
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
261 |
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
262 |
else { $perm_content_edit = "none" ; } |
1
|
263 |
|
82
|
264 |
// Determine ID of zone first. |
|
265 |
$record = get_record_details_from_record_id($rid); |
|
266 |
$user_is_zone_owner = verify_user_is_owner_zoneid($record['zid']); |
1
|
267 |
|
82
|
268 |
if ( $perm_content_edit == "all" || ($perm_content_edit == "own" && $user_is_zone_owner == "0" )) { |
|
269 |
if ($record['type'] == "SOA") { |
|
270 |
error(_('You are trying to delete the SOA record. If are not allowed to remove it, unless you remove the entire zone.')); |
|
271 |
} else { |
98
|
272 |
$query = "DELETE FROM records WHERE id = " . $db->quote($rid); |
82
|
273 |
$response = $db->query($query); |
|
274 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
|
275 |
return true; |
1
|
276 |
} |
82
|
277 |
} else { |
|
278 |
error(ERR_PERM_DEL_RECORD); |
|
279 |
return false; |
1
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
|
|
284 |
/* |
|
285 |
* Add a domain to the database. |
|
286 |
* A domain is name obligatory, so is an owner. |
|
287 |
* return values: true when succesful. |
|
288 |
* Empty means templates dont have to be applied. |
|
289 |
* -------------------------------------------------------------------------- |
|
290 |
* This functions eats a template and by that it inserts various records. |
|
291 |
* first we start checking if something in an arpa record |
|
292 |
* remember to request nextID's from the database to be able to insert record. |
|
293 |
* if anything is invalid the function will error |
|
294 |
*/ |
13
|
295 |
function add_domain($domain, $owner, $webip, $mailip, $empty, $type, $slave_master) |
1
|
296 |
{ |
82
|
297 |
if(verify_permission(zone_master_add)) { $zone_master_add = "1" ; } ; |
|
298 |
if(verify_permission(zone_slave_add)) { $zone_slave_add = "1" ; } ; |
1
|
299 |
|
82
|
300 |
// TODO: make sure only one is possible if only one is enabled |
86
|
301 |
if($zone_master_add == "1" || $zone_slave_add == "1") { |
1
|
302 |
|
82
|
303 |
global $db; |
|
304 |
if (($domain && $owner && $webip && $mailip) || |
|
305 |
($empty && $owner && $domain) || |
|
306 |
(eregi('in-addr.arpa', $domain) && $owner) || |
|
307 |
$type=="SLAVE" && $domain && $owner && $slave_master) { |
|
308 |
|
|
309 |
$response = $db->query("INSERT INTO domains (name, type) VALUES (".$db->quote($domain).", ".$db->quote($type).")"); |
|
310 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
1
|
311 |
|
82
|
312 |
$domain_id = $db->lastInsertId('domains', 'id'); |
|
313 |
if (PEAR::isError($domain_id)) { error($id->getMessage()); return false; } |
|
314 |
|
|
315 |
$response = $db->query("INSERT INTO zones (domain_id, owner) VALUES (".$db->quote($domain_id).", ".$db->quote($owner).")"); |
|
316 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
1
|
317 |
|
82
|
318 |
if ($type == "SLAVE") { |
|
319 |
$response = $db->query("UPDATE domains SET master = ".$db->quote($slave_master)." WHERE id = ".$db->quote($domain_id)); |
|
320 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
|
321 |
return true; |
|
322 |
} else { |
|
323 |
$now = time(); |
|
324 |
if ($empty && $domain_id) { |
|
325 |
$ns1 = $GLOBALS['NS1']; |
|
326 |
$hm = $GLOBALS['HOSTMASTER']; |
|
327 |
$ttl = $GLOBALS['DEFAULT_TTL']; |
1
|
328 |
|
106
|
329 |
$query = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES (" |
82
|
330 |
. $db->quote($domain_id) . "," |
|
331 |
. $db->quote($domain) . "," |
106
|
332 |
. $db->quote('SOA')."," |
87
|
333 |
. $db->quote($ns1.' '.$hm.' 1') . "," |
82
|
334 |
. $db->quote($ttl) |
|
335 |
. ", 0, " |
|
336 |
. $db->quote($now).")"; |
|
337 |
$response = $db->query($query); |
|
338 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
|
339 |
} elseif ($domain_id) { |
|
340 |
global $template; |
1
|
341 |
|
82
|
342 |
foreach ($template as $r) { |
|
343 |
if ((eregi('in-addr.arpa', $domain) && ($r["type"] == "NS" || $r["type"] == "SOA")) || (!eregi('in-addr.arpa', $domain))) |
|
344 |
{ |
|
345 |
$name = parse_template_value($r["name"], $domain, $webip, $mailip); |
|
346 |
$type = $r["type"]; |
|
347 |
$content = parse_template_value($r["content"], $domain, $webip, $mailip); |
|
348 |
$ttl = $r["ttl"]; |
|
349 |
$prio = intval($r["prio"]); |
13
|
350 |
|
82
|
351 |
if (!$ttl) { |
|
352 |
$ttl = $GLOBALS["DEFAULT_TTL"]; |
|
353 |
} |
1
|
354 |
|
106
|
355 |
$query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES (" |
82
|
356 |
. $db->quote($domain_id) . "," |
|
357 |
. $db->quote($name) . "," |
87
|
358 |
. $db->quote($type) . "," |
82
|
359 |
. $db->quote($content) . "," |
|
360 |
. $db->quote($ttl) . "," |
|
361 |
. $db->quote($prio) . "," |
|
362 |
. $db->quote($now) . ")"; |
|
363 |
$response = $db->query($query); |
|
364 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
13
|
365 |
} |
|
366 |
} |
82
|
367 |
return true; |
|
368 |
} else { |
|
369 |
error(sprintf(ERR_INV_ARGC, "add_domain", "could not create zone")); |
|
370 |
} |
|
371 |
} |
|
372 |
} else { |
|
373 |
error(sprintf(ERR_INV_ARG, "add_domain")); |
13
|
374 |
} |
82
|
375 |
} else { |
|
376 |
error(ERR_PERM_ADD_ZONE_MASTER); |
|
377 |
return false; |
1
|
378 |
} |
|
379 |
} |
|
380 |
|
|
381 |
|
|
382 |
/* |
|
383 |
* Deletes a domain by a given id. |
|
384 |
* Function always succeeds. If the field is not found in the database, thats what we want anyway. |
|
385 |
*/ |
|
386 |
function delete_domain($id) |
|
387 |
{ |
|
388 |
global $db; |
|
389 |
|
82
|
390 |
if (verify_permission(zone_content_edit_others)) { $perm_edit = "all" ; } |
|
391 |
elseif (verify_permission(zone_content_edit_own)) { $perm_edit = "own" ; } |
|
392 |
else { $perm_edit = "none" ; } |
|
393 |
$user_is_zone_owner = verify_user_is_owner_zoneid($id); |
1
|
394 |
|
82
|
395 |
if ( $perm_edit == "all" || ( $perm_edit == "own" && $user_is_zone_owner == "1") ) { |
|
396 |
if (is_numeric($id)) { |
|
397 |
$db->query("DELETE FROM zones WHERE domain_id=".$db->quote($id)); |
|
398 |
$db->query("DELETE FROM domains WHERE id=".$db->quote($id)); |
|
399 |
$db->query("DELETE FROM records WHERE domain_id=".$db->quote($id)); |
|
400 |
return true; |
|
401 |
} else { |
|
402 |
error(sprintf(ERR_INV_ARGC, "delete_domain", "id must be a number")); |
|
403 |
return false; |
|
404 |
} |
|
405 |
} else { |
|
406 |
error(ERR_PERM_DEL_ZONE); |
1
|
407 |
} |
|
408 |
} |
|
409 |
|
|
410 |
|
|
411 |
/* |
|
412 |
* Gets the id of the domain by a given record id. |
|
413 |
* return values: the domain id that was requested. |
|
414 |
*/ |
|
415 |
function recid_to_domid($id) |
|
416 |
{ |
|
417 |
global $db; |
|
418 |
if (is_numeric($id)) |
|
419 |
{ |
65
|
420 |
$result = $db->query("SELECT domain_id FROM records WHERE id=".$db->quote($id)); |
1
|
421 |
$r = $result->fetchRow(); |
|
422 |
return $r["domain_id"]; |
|
423 |
} |
|
424 |
else |
|
425 |
{ |
|
426 |
error(sprintf(ERR_INV_ARGC, "recid_to_domid", "id must be a number")); |
|
427 |
} |
|
428 |
} |
|
429 |
|
|
430 |
|
|
431 |
/* |
|
432 |
* Change owner of a domain. |
|
433 |
* return values: true when succesful. |
|
434 |
*/ |
82
|
435 |
function add_owner_to_zone($zone_id, $user_id) |
1
|
436 |
{ |
|
437 |
global $db; |
82
|
438 |
if ( (verify_permission(zone_meta_edit_others)) || (verify_permission(zone_meta_edit_own)) && verify_user_is_owner_zoneid($_GET["id"])) { |
|
439 |
// User is allowed to make change to meta data of this zone. |
|
440 |
if (is_numeric($zone_id) && is_numeric($user_id) && is_valid_user($user_id)) |
1
|
441 |
{ |
82
|
442 |
if($db->queryOne("SELECT COUNT(id) FROM zones WHERE owner=".$db->quote($user_id)." AND domain_id=".$db->quote($zone_id)) == 0) |
|
443 |
{ |
|
444 |
$db->query("INSERT INTO zones (domain_id, owner) VALUES(".$db->quote($zone_id).", ".$db->quote($user_id).")"); |
|
445 |
} |
|
446 |
return true; |
|
447 |
} else { |
|
448 |
error(sprintf(ERR_INV_ARGC, "add_owner_to_zone", "$zone_id / $user_id")); |
1
|
449 |
} |
82
|
450 |
} else { |
|
451 |
return false; |
1
|
452 |
} |
|
453 |
} |
|
454 |
|
|
455 |
|
82
|
456 |
function delete_owner_from_zone($zone_id, $user_id) |
1
|
457 |
{ |
|
458 |
global $db; |
82
|
459 |
if ( (verify_permission(zone_meta_edit_others)) || (verify_permission(zone_meta_edit_own)) && verify_user_is_owner_zoneid($_GET["id"])) { |
|
460 |
// User is allowed to make change to meta data of this zone. |
|
461 |
if (is_numeric($zone_id) && is_numeric($user_id) && is_valid_user($user_id)) |
|
462 |
{ |
|
463 |
// TODO: Next if() required, why not just execute DELETE query? |
|
464 |
if($db->queryOne("SELECT COUNT(id) FROM zones WHERE owner=".$db->quote($user_id)." AND domain_id=".$db->quote($zone_id)) != 0) |
|
465 |
{ |
|
466 |
$db->query("DELETE FROM zones WHERE owner=".$db->quote($user_id)." AND domain_id=".$db->quote($zone_id)); |
|
467 |
} |
|
468 |
return true; |
|
469 |
} else { |
|
470 |
error(sprintf(ERR_INV_ARGC, "delete_owner_from_zone", "$zone_id / $user_id")); |
|
471 |
} |
|
472 |
} else { |
|
473 |
return false; |
1
|
474 |
} |
82
|
475 |
|
1
|
476 |
} |
|
477 |
|
|
478 |
/* |
|
479 |
* Retrieves all supported dns record types |
|
480 |
* This function might be deprecated. |
|
481 |
* return values: array of types in string form. |
|
482 |
*/ |
|
483 |
function get_record_types() |
|
484 |
{ |
|
485 |
global $rtypes; |
|
486 |
return $rtypes; |
|
487 |
} |
|
488 |
|
|
489 |
|
|
490 |
/* |
|
491 |
* Retrieve all records by a given type and domain id. |
|
492 |
* Example: get all records that are of type A from domain id 1 |
|
493 |
* return values: a DB class result object |
|
494 |
*/ |
|
495 |
function get_records_by_type_from_domid($type, $recid) |
|
496 |
{ |
|
497 |
global $rtypes; |
|
498 |
global $db; |
|
499 |
|
|
500 |
// Does this type exist? |
|
501 |
if(!in_array(strtoupper($type), $rtypes)) |
|
502 |
{ |
|
503 |
error(sprintf(ERR_INV_ARGC, "get_records_from_type", "this is not a supported record")); |
|
504 |
} |
|
505 |
|
|
506 |
// Get the domain id. |
|
507 |
$domid = recid_to_domid($recid); |
|
508 |
|
65
|
509 |
$result = $db->query("select id, type from records where domain_id=".$db->quote($recid)." and type=".$db->quote($type)); |
1
|
510 |
return $result; |
|
511 |
} |
|
512 |
|
|
513 |
|
|
514 |
/* |
|
515 |
* Retrieves the type of a record from a given id. |
|
516 |
* return values: the type of the record (one of the records types in $rtypes assumable). |
|
517 |
*/ |
|
518 |
function get_recordtype_from_id($id) |
|
519 |
{ |
|
520 |
global $db; |
|
521 |
if (is_numeric($id)) |
|
522 |
{ |
65
|
523 |
$result = $db->query("SELECT type FROM records WHERE id=".$db->quote($id)); |
1
|
524 |
$r = $result->fetchRow(); |
|
525 |
return $r["type"]; |
|
526 |
} |
|
527 |
else |
|
528 |
{ |
|
529 |
error(sprintf(ERR_INV_ARG, "get_recordtype_from_id")); |
|
530 |
} |
|
531 |
} |
|
532 |
|
|
533 |
|
|
534 |
/* |
|
535 |
* Retrieves the name (e.g. bla.test.com) of a record by a given id. |
|
536 |
* return values: the name associated with the id. |
|
537 |
*/ |
|
538 |
function get_name_from_record_id($id) |
|
539 |
{ |
|
540 |
global $db; |
82
|
541 |
if (is_numeric($id)) { |
65
|
542 |
$result = $db->query("SELECT name FROM records WHERE id=".$db->quote($id)); |
1
|
543 |
$r = $result->fetchRow(); |
|
544 |
return $r["name"]; |
82
|
545 |
} else { |
1
|
546 |
error(sprintf(ERR_INV_ARG, "get_name_from_record_id")); |
|
547 |
} |
|
548 |
} |
|
549 |
|
|
550 |
|
|
551 |
/* |
|
552 |
* Get domain name from a given id |
|
553 |
* return values: the name of the domain associated with the id. |
|
554 |
*/ |
|
555 |
function get_domain_name_from_id($id) |
|
556 |
{ |
|
557 |
global $db; |
82
|
558 |
|
1
|
559 |
if (is_numeric($id)) |
|
560 |
{ |
65
|
561 |
$result = $db->query("SELECT name FROM domains WHERE id=".$db->quote($id)); |
82
|
562 |
$rows = $result->numRows() ; |
|
563 |
if ($rows == 1) { |
1
|
564 |
$r = $result->fetchRow(); |
|
565 |
return $r["name"]; |
82
|
566 |
} elseif ($rows == "0") { |
|
567 |
error(sprintf("Zone does not exist.")); |
|
568 |
return false; |
|
569 |
} else { |
1
|
570 |
error(sprintf(ERR_INV_ARGC, "get_domain_name_from_id", "more than one domain found?! whaaa! BAD! BAD! Contact admin!")); |
82
|
571 |
return false; |
1
|
572 |
} |
|
573 |
} |
|
574 |
else |
|
575 |
{ |
|
576 |
error(sprintf(ERR_INV_ARGC, "get_domain_name_from_id", "Not a valid domainid: $id")); |
|
577 |
} |
|
578 |
} |
|
579 |
|
82
|
580 |
function get_zone_info_from_id($zone_id) { |
1
|
581 |
|
82
|
582 |
if (verify_permission(zone_content_view_others)) { $perm_view = "all" ; } |
|
583 |
elseif (verify_permission(zone_content_view_own)) { $perm_view = "own" ; } |
|
584 |
else { $perm_view = "none" ;} |
1
|
585 |
|
82
|
586 |
if ($perm_view == "none") { |
|
587 |
error(ERR_PERM_VIEW_ZONE); |
|
588 |
} else { |
|
589 |
global $db; |
1
|
590 |
|
82
|
591 |
$query = "SELECT domains.type AS type, |
|
592 |
domains.name AS name, |
|
593 |
domains.master AS master_ip, |
|
594 |
count(records.domain_id) AS record_count |
|
595 |
FROM domains, records |
|
596 |
WHERE domains.id = " . $db->quote($zone_id) . " |
|
597 |
AND domains.id = records.domain_id |
|
598 |
GROUP BY domains.id"; |
88
|
599 |
$result = $db->query($query); |
|
600 |
if (PEAR::isError($result)) { error($result->getMessage()); return false; } |
1
|
601 |
|
88
|
602 |
if($result->numRows() != 1) { |
|
603 |
error(_('Function returned an error (multiple zones matching this zone ID).')); |
|
604 |
return false; |
|
605 |
} else { |
|
606 |
$r = $result->fetchRow(); |
|
607 |
$return = array( |
|
608 |
"name" => $r['name'], |
|
609 |
"type" => $r['type'], |
|
610 |
"master_ip" => $r['master_ip'], |
|
611 |
"record_count" => $r['record_count'] |
|
612 |
); |
|
613 |
} |
82
|
614 |
return $return; |
1
|
615 |
} |
|
616 |
} |
|
617 |
|
|
618 |
|
|
619 |
/* |
|
620 |
* Check if a domain is already existing. |
|
621 |
* return values: true if existing, false if it doesnt exist. |
|
622 |
*/ |
|
623 |
function domain_exists($domain) |
|
624 |
{ |
|
625 |
global $db; |
|
626 |
|
82
|
627 |
if (is_valid_domain($domain)) { |
65
|
628 |
$result = $db->query("SELECT id FROM domains WHERE name=".$db->quote($domain)); |
82
|
629 |
if ($result->numRows() == 0) { |
1
|
630 |
return false; |
82
|
631 |
} elseif ($result->numRows() >= 1) { |
1
|
632 |
return true; |
|
633 |
} |
82
|
634 |
} else { |
1
|
635 |
error(ERR_DOMAIN_INVALID); |
|
636 |
} |
|
637 |
} |
|
638 |
|
13
|
639 |
function get_supermasters() |
|
640 |
{ |
|
641 |
global $db; |
82
|
642 |
|
|
643 |
$result = $db->query("SELECT ip, nameserver, account FROM supermasters"); |
|
644 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
|
645 |
|
13
|
646 |
$ret = array(); |
|
647 |
|
82
|
648 |
if($result->numRows() == 0) { |
13
|
649 |
return -1; |
82
|
650 |
} else { |
|
651 |
while ($r = $result->fetchRow()) { |
13
|
652 |
$ret[] = array( |
|
653 |
"master_ip" => $r["ip"], |
|
654 |
"ns_name" => $r["nameserver"], |
|
655 |
"account" => $r["account"], |
|
656 |
); |
|
657 |
} |
36
|
658 |
return $ret; |
13
|
659 |
} |
|
660 |
} |
|
661 |
|
|
662 |
function supermaster_exists($master_ip) |
|
663 |
{ |
|
664 |
global $db; |
|
665 |
if (is_valid_ip($master_ip) || is_valid_ip6($master_ip)) |
|
666 |
{ |
65
|
667 |
$result = $db->query("SELECT ip FROM supermasters WHERE ip = ".$db->quote($master_ip)); |
13
|
668 |
if ($result->numRows() == 0) |
|
669 |
{ |
|
670 |
return false; |
|
671 |
} |
|
672 |
elseif ($result->numRows() >= 1) |
|
673 |
{ |
|
674 |
return true; |
|
675 |
} |
|
676 |
} |
|
677 |
else |
|
678 |
{ |
|
679 |
error(sprintf(ERR_INV_ARGC, "supermaster_exists", "No or no valid IPv4 or IPv6 address given.")); |
|
680 |
} |
|
681 |
} |
|
682 |
|
1
|
683 |
|
82
|
684 |
function get_zones($perm,$userid=0,$letterstart=all,$rowstart=0,$rowamount=999999) |
1
|
685 |
{ |
|
686 |
global $db; |
55
|
687 |
global $sql_regexp; |
82
|
688 |
if ($perm != "own" && $perm != "all") { |
|
689 |
error(ERR_PERM_VIEW_ZONE); |
|
690 |
return false; |
1
|
691 |
} |
|
692 |
else |
|
693 |
{ |
82
|
694 |
if ($perm == "own") { |
|
695 |
$sql_add = " AND zones.domain_id = domains.id |
|
696 |
AND zones.owner = ".$db->quote($userid); |
|
697 |
} |
|
698 |
if ($letterstart!=all && $letterstart!=1) { |
|
699 |
$sql_add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." "; |
|
700 |
} elseif ($letterstart==1) { |
|
701 |
$sql_add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'"; |
|
702 |
} |
1
|
703 |
} |
82
|
704 |
|
|
705 |
$sqlq = "SELECT domains.id, |
|
706 |
domains.name, |
|
707 |
domains.type, |
|
708 |
COUNT(DISTINCT records.id) AS count_records |
|
709 |
FROM domains |
|
710 |
LEFT JOIN zones ON domains.id=zones.domain_id |
|
711 |
LEFT JOIN records ON records.domain_id=domains.id |
|
712 |
WHERE 1=1".$sql_add." |
106
|
713 |
GROUP BY domains.name, domains.id, domains.type |
82
|
714 |
ORDER BY domains.name"; |
|
715 |
|
74
|
716 |
$db->setLimit($rowamount, $rowstart); |
1
|
717 |
$result = $db->query($sqlq); |
|
718 |
|
|
719 |
while($r = $result->fetchRow()) |
|
720 |
{ |
82
|
721 |
$ret[$r["name"]] = array( |
|
722 |
"id" => $r["id"], |
|
723 |
"name" => $r["name"], |
|
724 |
"type" => $r["type"], |
|
725 |
"count_records" => $r["count_records"] |
|
726 |
); |
1
|
727 |
} |
82
|
728 |
return $ret; |
1
|
729 |
} |
|
730 |
|
82
|
731 |
// TODO: letterstart limitation and userid permission limitiation should be applied at the same time? |
|
732 |
function zone_count_ng($perm, $letterstart=all) { |
|
733 |
global $db; |
55
|
734 |
global $sql_regexp; |
115
|
735 |
|
|
736 |
$fromTable = 'domains'; |
|
737 |
|
82
|
738 |
if ($perm != "own" && $perm != "all") { |
|
739 |
$zone_count = "0"; |
|
740 |
} |
|
741 |
else |
|
742 |
{ |
|
743 |
if ($perm == "own") { |
|
744 |
$sql_add = " AND zones.domain_id = domains.id |
|
745 |
AND zones.owner = ".$db->quote($_SESSION['userid']); |
115
|
746 |
$fromTable .= ',zones'; |
82
|
747 |
} |
|
748 |
if ($letterstart!=all && $letterstart!=1) { |
|
749 |
$sql_add .=" AND domains.name LIKE ".$db->quote($letterstart."%")." "; |
|
750 |
} elseif ($letterstart==1) { |
|
751 |
$sql_add .=" AND substring(domains.name,1,1) ".$sql_regexp." '^[[:digit:]]'"; |
37
|
752 |
} |
|
753 |
|
82
|
754 |
$sqlq = "SELECT COUNT(distinct domains.id) AS count_zones |
115
|
755 |
FROM ".$fromTable." WHERE 1=1 |
82
|
756 |
".$sql_add.";"; |
|
757 |
|
|
758 |
$zone_count = $db->queryOne($sqlq); |
|
759 |
} |
|
760 |
return $zone_count; |
|
761 |
} |
30
|
762 |
|
82
|
763 |
function zone_count_for_uid($uid) { |
|
764 |
global $db; |
|
765 |
$query = "SELECT COUNT(domain_id) |
|
766 |
FROM zones |
|
767 |
WHERE owner = " . $db->quote($uid) . " |
|
768 |
ORDER BY domain_id"; |
|
769 |
$zone_count = $db->queryOne($query); |
|
770 |
return $zone_count; |
|
771 |
} |
30
|
772 |
|
|
773 |
|
|
774 |
/* |
1
|
775 |
* Get a record from an id. |
|
776 |
* Retrieve all fields of the record and send it back to the function caller. |
|
777 |
* return values: the array with information, or -1 is nothing is found. |
|
778 |
*/ |
|
779 |
function get_record_from_id($id) |
|
780 |
{ |
|
781 |
global $db; |
|
782 |
if (is_numeric($id)) |
|
783 |
{ |
65
|
784 |
$result = $db->query("SELECT id, domain_id, name, type, content, ttl, prio, change_date FROM records WHERE id=".$db->quote($id)); |
1
|
785 |
if($result->numRows() == 0) |
|
786 |
{ |
|
787 |
return -1; |
|
788 |
} |
|
789 |
elseif ($result->numRows() == 1) |
|
790 |
{ |
|
791 |
$r = $result->fetchRow(); |
|
792 |
$ret = array( |
82
|
793 |
"id" => $r["id"], |
|
794 |
"domain_id" => $r["domain_id"], |
|
795 |
"name" => $r["name"], |
|
796 |
"type" => $r["type"], |
|
797 |
"content" => $r["content"], |
|
798 |
"ttl" => $r["ttl"], |
|
799 |
"prio" => $r["prio"], |
|
800 |
"change_date" => $r["change_date"] |
|
801 |
); |
1
|
802 |
return $ret; |
|
803 |
} |
|
804 |
else |
|
805 |
{ |
|
806 |
error(sprintf(ERR_INV_ARGC, "get_record_from_id", "More than one row returned! This is bad!")); |
|
807 |
} |
|
808 |
} |
|
809 |
else |
|
810 |
{ |
|
811 |
error(sprintf(ERR_INV_ARG, "get_record_from_id")); |
|
812 |
} |
|
813 |
} |
|
814 |
|
|
815 |
|
|
816 |
/* |
|
817 |
* Get all records from a domain id. |
|
818 |
* Retrieve all fields of the records and send it back to the function caller. |
|
819 |
* return values: the array with information, or -1 is nothing is found. |
|
820 |
*/ |
82
|
821 |
function get_records_from_domain_id($id,$rowstart=0,$rowamount=999999) { |
1
|
822 |
global $db; |
82
|
823 |
if (is_numeric($id)) { |
1
|
824 |
if ($_SESSION[$id."_ispartial"] == 1) { |
82
|
825 |
$db->setLimit($rowamount, $rowstart); |
|
826 |
$result = $db->query("SELECT record_owners.record_id as id |
|
827 |
FROM record_owners,domains,records |
|
828 |
WHERE record_owners.user_id = " . $db->quote($_SESSION["userid"]) . " |
|
829 |
AND record_owners.record_id = records.id |
|
830 |
AND records.domain_id = " . $db->quote($id) . " |
|
831 |
GROUP BY record_owners.record_id"); |
1
|
832 |
|
82
|
833 |
$ret = array(); |
|
834 |
if($result->numRows() == 0) { |
|
835 |
return -1; |
|
836 |
} else { |
|
837 |
$ret[] = array(); |
|
838 |
$retcount = 0; |
|
839 |
while($r = $result->fetchRow()) |
|
840 |
{ |
|
841 |
// Call get_record_from_id for each row. |
|
842 |
$ret[$retcount] = get_record_from_id($r["id"]); |
|
843 |
$retcount++; |
|
844 |
} |
|
845 |
return $ret; |
|
846 |
} |
1
|
847 |
|
|
848 |
} else { |
82
|
849 |
$db->setLimit($rowamount, $rowstart); |
|
850 |
$result = $db->query("SELECT id FROM records WHERE domain_id=".$db->quote($id)); |
|
851 |
$ret = array(); |
|
852 |
if($result->numRows() == 0) |
|
853 |
{ |
|
854 |
return -1; |
|
855 |
} |
|
856 |
else |
1
|
857 |
{ |
82
|
858 |
$ret[] = array(); |
|
859 |
$retcount = 0; |
|
860 |
while($r = $result->fetchRow()) |
|
861 |
{ |
|
862 |
// Call get_record_from_id for each row. |
|
863 |
$ret[$retcount] = get_record_from_id($r["id"]); |
|
864 |
$retcount++; |
|
865 |
} |
|
866 |
return $ret; |
1
|
867 |
} |
|
868 |
|
|
869 |
} |
|
870 |
} |
|
871 |
else |
|
872 |
{ |
|
873 |
error(sprintf(ERR_INV_ARG, "get_records_from_domain_id")); |
|
874 |
} |
|
875 |
} |
|
876 |
|
|
877 |
|
82
|
878 |
function get_users_from_domain_id($id) { |
1
|
879 |
global $db; |
82
|
880 |
$sqlq = "SELECT owner FROM zones WHERE domain_id =" .$db->quote($id); |
|
881 |
$id_owners = $db->query($sqlq); |
|
882 |
if ($id_owners->numRows() == 0) { |
|
883 |
return -1; |
|
884 |
} else { |
|
885 |
while ($r = $id_owners->fetchRow()) { |
|
886 |
$fullname = $db->queryOne("SELECT fullname FROM users WHERE id=".$r['owner']); |
|
887 |
$owners[] = array( |
|
888 |
"id" => $r['owner'], |
|
889 |
"fullname" => $fullname |
|
890 |
); |
|
891 |
} |
1
|
892 |
} |
82
|
893 |
return $owners; |
1
|
894 |
} |
|
895 |
|
82
|
896 |
|
|
897 |
function search_zone_and_record($holy_grail,$perm) { |
|
898 |
|
1
|
899 |
global $db; |
82
|
900 |
|
|
901 |
$holy_grail = trim($holy_grail); |
|
902 |
|
|
903 |
if (verify_permission(zone_content_view_others)) { $perm_view = "all" ; } |
|
904 |
elseif (verify_permission(zone_content_view_own)) { $perm_view = "own" ; } |
|
905 |
else { $perm_view = "none" ; } |
|
906 |
|
|
907 |
if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
908 |
elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
909 |
else { $perm_content_edit = "none" ; } |
|
910 |
|
|
911 |
// Search for matching domains |
62
|
912 |
|
82
|
913 |
if ($perm == "own") { |
|
914 |
$sql_add_from = ", zones "; |
|
915 |
$sql_add_where = " AND zones.domain_id = domains.id AND zones.owner = " . $db->quote($userid); |
|
916 |
} |
|
917 |
|
|
918 |
$query = "SELECT |
|
919 |
domains.id AS zid, |
|
920 |
domains.name AS name, |
|
921 |
domains.type AS type, |
|
922 |
domains.master AS master |
|
923 |
FROM domains" . $sql_add_from . " |
|
924 |
WHERE domains.name LIKE " . $db->quote($holy_grail) |
|
925 |
. $sql_add_where ; |
|
926 |
|
|
927 |
$response = $db->query($query); |
|
928 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
62
|
929 |
|
82
|
930 |
while ($r = $response->fetchRow()) { |
|
931 |
$return_zones[] = array( |
|
932 |
"zid" => $r['zid'], |
|
933 |
"name" => $r['name'], |
|
934 |
"type" => $r['type'], |
|
935 |
"master" => $r['master']); |
1
|
936 |
} |
|
937 |
|
82
|
938 |
// Search for matching records |
|
939 |
|
|
940 |
if ($perm == "own") { |
|
941 |
$sql_add_from = ", zones "; |
|
942 |
$sql_add_where = " AND zones.domain_id = record.id AND zones.owner = " . $db->quote($userid); |
|
943 |
} |
|
944 |
|
|
945 |
$query = "SELECT |
|
946 |
records.id AS rid, |
|
947 |
records.name AS name, |
|
948 |
records.type AS type, |
|
949 |
records.content AS content, |
|
950 |
records.ttl AS ttl, |
|
951 |
records.prio AS prio, |
|
952 |
records.domain_id AS zid |
|
953 |
FROM records" . $sql_add_from . " |
|
954 |
WHERE (records.name LIKE " . $db->quote($holy_grail) . " OR records.content LIKE " . $db->quote($holy_grail) . ")" |
|
955 |
. $sql_add_where ; |
|
956 |
|
|
957 |
$response = $db->query($query); |
|
958 |
if (PEAR::isError($response)) { error($response->getMessage()); return false; } |
|
959 |
|
|
960 |
while ($r = $response->fetchRow()) { |
|
961 |
$return_records[] = array( |
|
962 |
"rid" => $r['rid'], |
|
963 |
"name" => $r['name'], |
|
964 |
"type" => $r['type'], |
|
965 |
"content" => $r['content'], |
|
966 |
"ttl" => $r['ttl'], |
|
967 |
"zid" => $r['zid'], |
|
968 |
"prio" => $r['prio']); |
|
969 |
} |
|
970 |
return array('zones' => $return_zones, 'records' => $return_records); |
1
|
971 |
} |
|
972 |
|
82
|
973 |
function get_domain_type($id) { |
1
|
974 |
global $db; |
82
|
975 |
if (is_numeric($id)) { |
65
|
976 |
$type = $db->queryOne("SELECT type FROM domains WHERE id = ".$db->quote($id)); |
82
|
977 |
if ($type == "") { |
13
|
978 |
$type = "NATIVE"; |
|
979 |
} |
|
980 |
return $type; |
82
|
981 |
} else { |
13
|
982 |
error(sprintf(ERR_INV_ARG, "get_record_from_id", "no or no valid zoneid given")); |
|
983 |
} |
|
984 |
} |
|
985 |
|
82
|
986 |
function get_domain_slave_master($id){ |
13
|
987 |
global $db; |
82
|
988 |
if (is_numeric($id)) { |
65
|
989 |
$slave_master = $db->queryOne("SELECT master FROM domains WHERE type = 'SLAVE' and id = ".$db->quote($id)); |
13
|
990 |
return $slave_master; |
82
|
991 |
} else { |
13
|
992 |
error(sprintf(ERR_INV_ARG, "get_domain_slave_master", "no or no valid zoneid given")); |
|
993 |
} |
1
|
994 |
} |
|
995 |
|
82
|
996 |
function change_zone_type($type, $id) |
1
|
997 |
{ |
13
|
998 |
global $db; |
79
|
999 |
$add = ''; |
13
|
1000 |
if (is_numeric($id)) |
|
1001 |
{ |
82
|
1002 |
// It is not really neccesary to clear the field that contains the IP address |
|
1003 |
// of the master if the type changes from slave to something else. PowerDNS will |
|
1004 |
// ignore the field if the type isn't something else then slave. But then again, |
|
1005 |
// it's much clearer this way. |
|
1006 |
if ($type != "SLAVE") { |
13
|
1007 |
$add = ", master=''"; |
|
1008 |
} |
82
|
1009 |
$result = $db->query("UPDATE domains SET type = " . $db->quote($type) . $add . " WHERE id = ".$db->quote($id)); |
|
1010 |
} else { |
13
|
1011 |
error(sprintf(ERR_INV_ARG, "change_domain_type", "no or no valid zoneid given")); |
|
1012 |
} |
|
1013 |
} |
|
1014 |
|
82
|
1015 |
function change_zone_slave_master($zone_id, $ip_slave_master) { |
13
|
1016 |
global $db; |
82
|
1017 |
if (is_numeric($zone_id)) { |
|
1018 |
if (is_valid_ip($ip_slave_master) || is_valid_ip6($ip_slave_master)) { |
|
1019 |
$result = $db->query("UPDATE domains SET master = " .$db->quote($ip_slave_master). " WHERE id = ".$db->quote($zone_id)); |
|
1020 |
} else { |
|
1021 |
error(sprintf(ERR_INV_ARGC, "change_domain_ip_slave_master", "This is not a valid IPv4 or IPv6 address: $ip_slave_master")); |
13
|
1022 |
} |
82
|
1023 |
} else { |
13
|
1024 |
error(sprintf(ERR_INV_ARG, "change_domain_type", "no or no valid zoneid given")); |
|
1025 |
} |
|
1026 |
} |
|
1027 |
|
|
1028 |
|
82
|
1029 |
function validate_account($account) { |
|
1030 |
if(preg_match("/^[A-Z0-9._-]+$/i",$account)) { |
13
|
1031 |
return true; |
82
|
1032 |
} else { |
13
|
1033 |
return false; |
|
1034 |
} |
1
|
1035 |
} |
82
|
1036 |
|
|
1037 |
|
1
|
1038 |
?> |