44 * NOTICE: This function will allow only 100 DNS zone transfers ;-) |
44 * NOTICE: This function will allow only 100 DNS zone transfers ;-) |
45 * YYYYMMDDnn |
45 * YYYYMMDDnn |
46 */ |
46 */ |
47 |
47 |
48 $sqlq = "SELECT `notified_serial` FROM `domains` WHERE `id` = '".$domain_id."'"; |
48 $sqlq = "SELECT `notified_serial` FROM `domains` WHERE `id` = '".$domain_id."'"; |
49 $notified_serial = $db->getOne($sqlq); |
49 $notified_serial = $db->queryOne($sqlq); |
50 |
50 |
51 $sqlq = "SELECT `content` FROM `records` WHERE `type` = 'SOA' AND `domain_id` = '".$domain_id."'"; |
51 $sqlq = "SELECT `content` FROM `records` WHERE `type` = 'SOA' AND `domain_id` = '".$domain_id."'"; |
52 $content = $db->getOne($sqlq); |
52 $content = $db->queryOne($sqlq); |
53 $need_to_update = false; |
53 $need_to_update = false; |
54 |
54 |
55 // Getting the serial field. |
55 // Getting the serial field. |
56 $soa = explode(" ", $content); |
56 $soa = explode(" ", $content); |
57 |
57 |
169 { |
169 { |
170 error(ERR_RECORD_ACCESS_DENIED); |
170 error(ERR_RECORD_ACCESS_DENIED); |
171 } |
171 } |
172 if (is_numeric($zoneid)) |
172 if (is_numeric($zoneid)) |
173 { |
173 { |
174 |
|
175 // Get the Insert ID, we can not rely on auto_increment |
|
176 $idrecords = $db->nextID('records'); |
|
177 |
|
178 // Check the user input. |
174 // Check the user input. |
179 validate_input($idrecords, $zoneid, $type, $content, $name, $prio, $ttl); |
175 validate_input($zoneid, $type, $content, $name, $prio, $ttl); |
180 |
176 |
181 // Generate new timestamp for the Daemon |
177 // Generate new timestamp for the daemon |
182 $change = time(); |
178 $change = time(); |
|
179 |
183 // Execute query. |
180 // Execute query. |
184 $db->query("INSERT INTO records (id, domain_id, name, type, content, ttl, prio, change_date) VALUES ($idrecords, $zoneid, '$name', '$type', '$content', $ttl, '$prio', $change)"); |
181 $db->query("INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES ($zoneid, '$name', '$type', '$content', $ttl, '$prio', $change)"); |
185 if ($type != 'SOA') |
182 if ($type != 'SOA') |
186 { |
183 { |
187 update_soa_serial($zoneid); |
184 update_soa_serial($zoneid); |
188 } |
185 } |
189 return true; |
186 return true; |
268 // the domain is an arpa record and owner is given |
265 // the domain is an arpa record and owner is given |
269 // THAN |
266 // THAN |
270 // Continue this function |
267 // Continue this function |
271 if (($domain && $owner && $webip && $mailip) || ($empty && $owner && $domain) || (eregi('in-addr.arpa', $domain) && $owner)) |
268 if (($domain && $owner && $webip && $mailip) || ($empty && $owner && $domain) || (eregi('in-addr.arpa', $domain) && $owner)) |
272 { |
269 { |
273 // Retrieve next zones id. |
270 |
274 $idzones = $db->nextID('zones'); |
271 // First insert zone into domain table |
275 $iddomains = $db->nextID('domains'); |
272 $db->query("INSERT INTO domains (name, type) VALUES ('$domain', '$type')"); |
276 |
273 |
277 $db->query("INSERT INTO zones (id, domain_id, owner) VALUES ('$idzones', '$iddomains', $owner)"); |
274 // Determine id of insert zone (in other words, find domain_id) |
278 |
275 $iddomain = $db->lastInsertId('domains', 'id'); |
279 /* |
276 if (PEAR::isError($iddomain)) { |
280 * TODO : NATIVE OPERATION ONLY FOR NOW |
277 die($id->getMessage()); |
281 */ |
278 } |
282 |
279 |
283 $db->query("INSERT INTO domains (id, name, type) VALUES ('$iddomains', '$domain', '$type')"); |
280 // Second, insert into zones tables |
284 |
281 $db->query("INSERT INTO zones (domain_id, owner) VALUES ('$iddomain', $owner)"); |
285 // Generate new timestamp. We need this one anyhow. |
282 |
286 $now = time(); |
283 // Generate new timestamp. We need this one anyhow. |
287 |
284 $now = time(); |
288 if ($empty && $iddomains) |
285 |
289 { |
286 if ($empty && $iddomain) |
290 // If we come into this if statement we dont want to apply templates. |
287 { |
291 // Retrieve configuration settings. |
288 // If we come into this if statement we dont want to apply templates. |
292 $ns1 = $GLOBALS["NS1"]; |
289 // Retrieve configuration settings. |
293 $hm = $GLOBALS["HOSTMASTER"]; |
290 $ns1 = $GLOBALS["NS1"]; |
294 $ttl = $GLOBALS["DEFAULT_TTL"]; |
291 $hm = $GLOBALS["HOSTMASTER"]; |
295 |
292 $ttl = $GLOBALS["DEFAULT_TTL"]; |
296 // Retrieve next records id |
293 |
297 $idrecords = $db->nextID('records'); |
294 // Build and execute query |
298 |
295 $sql = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES ('$iddomain', '$domain', '$ns1 $hm 1', 'SOA', $ttl, '', '$now')"; |
299 // Build and execute query |
296 $db->query($sql); |
300 $sql = "INSERT INTO records (id, domain_id, name, content, type, ttl, prio, change_date) VALUES ('$idrecords', '$iddomains', '$domain', '$ns1 $hm 1', 'SOA', $ttl, '', '$now')"; |
297 |
301 $db->query($sql); |
298 // Done |
302 |
299 return true; |
303 // Done |
300 } |
304 return true; |
301 elseif ($iddomain) |
305 } |
|
306 elseif ($iddomains) |
|
307 { |
302 { |
308 // If we are here we want to apply templates. |
303 // If we are here we want to apply templates. |
309 global $template; |
304 global $template; |
310 |
305 |
311 // Iterate over the template and apply it for each field. |
306 // Iterate over the template and apply it for each field. |
325 if (!$ttl) |
320 if (!$ttl) |
326 { |
321 { |
327 $ttl = $GLOBALS["DEFAULT_TTL"]; |
322 $ttl = $GLOBALS["DEFAULT_TTL"]; |
328 } |
323 } |
329 |
324 |
330 // Retrieve new record id; |
325 $sql = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES ('$iddomain', '$name','$content','$type','$ttl','$prio','$now')"; |
331 $idrecords = $db->nextID('records'); |
|
332 $sql = "INSERT INTO records (id, domain_id, name, content, type, ttl, prio, change_date) VALUES ('$idrecords', '$iddomains', '$name','$content','$type','$ttl','$prio','$now')"; |
|
333 $db->query($sql); |
326 $db->query($sql); |
334 } |
327 } |
335 } |
328 } |
336 // All done. |
329 // All done. |
337 return true; |
330 return true; |
653 AND records.domain_id = ".$id." |
645 AND records.domain_id = ".$id." |
654 |
646 |
655 GROUP BY name, owner, users.fullname |
647 GROUP BY name, owner, users.fullname |
656 ORDER BY name"; |
648 ORDER BY name"; |
657 |
649 |
658 $result = $db->getRow($sqlq); |
650 $result = $db->queryRow($sqlq); |
659 |
651 |
660 $ret = array( |
652 $ret = array( |
661 "name" => $result["name"], |
653 "name" => $result["name"], |
662 "ownerid" => $_SESSION["userid"], |
654 "ownerid" => $_SESSION["userid"], |
663 "owner" => $result["owner"], |
655 "owner" => $result["owner"], |
680 WHERE domains.id=$id |
672 WHERE domains.id=$id |
681 GROUP BY name, owner, users.fullname |
673 GROUP BY name, owner, users.fullname |
682 ORDER BY zones.id"; |
674 ORDER BY zones.id"; |
683 |
675 |
684 // Put the first occurence in an array and return it. |
676 // Put the first occurence in an array and return it. |
685 $result = $db->getRow($sqlq); |
677 $result = $db->queryRow($sqlq); |
686 |
678 |
687 //$result["ownerid"] = ($result["ownerid"] == NULL) ? $db->getOne("select min(id) from users where users.level=10") : $result["ownerid"]; |
679 //$result["ownerid"] = ($result["ownerid"] == NULL) ? $db->queryOne("select min(id) from users where users.level=10") : $result["ownerid"]; |
688 |
680 |
689 $ret = array( |
681 $ret = array( |
690 "name" => $result["name"], |
682 "name" => $result["name"], |
691 "ownerid" => $result["ownerid"], |
683 "ownerid" => $result["ownerid"], |
692 "owner" => $result["owner"], |
684 "owner" => $result["owner"], |
827 } |
819 } |
828 */ |
820 */ |
829 |
821 |
830 while($r = $result->fetchRow()) |
822 while($r = $result->fetchRow()) |
831 { |
823 { |
832 $r["owner"] = ($r["owner"] == NULL) ? $db->getOne("select min(id) from users where users.level=10") : $r["owner"]; |
824 $r["owner"] = ($r["owner"] == NULL) ? $db->queryOne("select min(id) from users where users.level=10") : $r["owner"]; |
833 $ret[$r["domainname"]] = array( |
825 $ret[$r["domainname"]] = array( |
834 "name" => $r["domainname"], |
826 "name" => $r["domainname"], |
835 "id" => $r["domain_id"], |
827 "id" => $r["domain_id"], |
836 "owner" => $r["owner"], |
828 "owner" => $r["owner"], |
837 "numrec" => $r["aantal"] |
829 "numrec" => $r["aantal"] |