inc/record.inc.php
changeset 136 c795dd75a77e
parent 135 3673b1c9246c
child 138 3e36ebbfe048
equal deleted inserted replaced
135:3673b1c9246c 136:c795dd75a77e
   308 
   308 
   309 	// TODO: make sure only one is possible if only one is enabled
   309 	// TODO: make sure only one is possible if only one is enabled
   310 	if($zone_master_add == "1" || $zone_slave_add == "1") {
   310 	if($zone_master_add == "1" || $zone_slave_add == "1") {
   311 
   311 
   312 		global $db;
   312 		global $db;
       
   313 		global $dns_ns1;
       
   314 		global $dns_hostmaster;
       
   315 		global $dns_ttl;
   313 		if (($domain && $owner && $webip && $mailip) || 
   316 		if (($domain && $owner && $webip && $mailip) || 
   314 				($empty && $owner && $domain) || 
   317 				($empty && $owner && $domain) || 
   315 				(eregi('in-addr.arpa', $domain) && $owner) || 
   318 				(eregi('in-addr.arpa', $domain) && $owner) || 
   316 				$type=="SLAVE" && $domain && $owner && $slave_master) {
   319 				$type=="SLAVE" && $domain && $owner && $slave_master) {
   317 
   320 
   329 				if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   332 				if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   330 				return true;
   333 				return true;
   331 			} else {
   334 			} else {
   332 				$now = time();
   335 				$now = time();
   333 				if ($empty && $domain_id) {
   336 				if ($empty && $domain_id) {
   334 					$ns1 = $GLOBALS['NS1'];
   337 					$ns1 = $dns_ns1;
   335 					$hm  = $GLOBALS['HOSTMASTER'];
   338 					$hm  = $dns_hostmaster;
   336 					$ttl = $GLOBALS['DEFAULT_TTL'];
   339 					$ttl = $dns_ttl;
   337 
   340 
   338 					$query = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES (" 
   341 					$query = "INSERT INTO records (domain_id, name, content, type, ttl, prio, change_date) VALUES (" 
   339 							. $db->quote($domain_id) . "," 
   342 							. $db->quote($domain_id) . "," 
   340 							. $db->quote($domain) . "," 
   343 							. $db->quote($domain) . "," 
   341 							. $db->quote($ns1.' '.$hm.' 1') . ","
   344 							. $db->quote($ns1.' '.$hm.' 1') . ","
   345 							. $db->quote($now).")";
   348 							. $db->quote($now).")";
   346 					$response = $db->query($query);
   349 					$response = $db->query($query);
   347 					if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   350 					if (PEAR::isError($response)) { error($response->getMessage()); return false; }
   348 				} elseif ($domain_id) {
   351 				} elseif ($domain_id) {
   349 					global $template;
   352 					global $template;
       
   353 					global $dns_ttl;
   350 
   354 
   351 					foreach ($template as $r) {
   355 					foreach ($template as $r) {
   352 						if ((eregi('in-addr.arpa', $domain) && ($r["type"] == "NS" || $r["type"] == "SOA")) || (!eregi('in-addr.arpa', $domain)))
   356 						if ((eregi('in-addr.arpa', $domain) && ($r["type"] == "NS" || $r["type"] == "SOA")) || (!eregi('in-addr.arpa', $domain)))
   353 						{
   357 						{
   354 							$name     = parse_template_value($r["name"], $domain, $webip, $mailip);
   358 							$name     = parse_template_value($r["name"], $domain, $webip, $mailip);
   356 							$content  = parse_template_value($r["content"], $domain, $webip, $mailip);
   360 							$content  = parse_template_value($r["content"], $domain, $webip, $mailip);
   357 							$ttl      = $r["ttl"];
   361 							$ttl      = $r["ttl"];
   358 							$prio     = intval($r["prio"]);
   362 							$prio     = intval($r["prio"]);
   359 
   363 
   360 							if (!$ttl) {
   364 							if (!$ttl) {
   361 								$ttl = $GLOBALS["DEFAULT_TTL"];
   365 								$ttl = $dns_ttl;
   362 							}
   366 							}
   363 
   367 
   364 							$query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES (" 
   368 							$query = "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date) VALUES (" 
   365 									. $db->quote($domain_id) . ","
   369 									. $db->quote($domain_id) . ","
   366 									. $db->quote($name) . ","
   370 									. $db->quote($name) . ","