diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php index 26199c24393f4e1931bd935bd7cdf92ef8ac092b..cfdc227f484d6f0ec57e8e3dd91d265de3fb6d88 100644 --- a/interface/lib/classes/remoting.inc.php +++ b/interface/lib/classes/remoting.inc.php @@ -1558,6 +1558,30 @@ class remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_soa.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } + + //* Get record id by origin + public function dns_zone_get_id($session_id, $origin) + { + global $app; + + if(!$this->checkPerm($session_id, 'dns_zone_get_id')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + if (preg_match('/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i', $origin)) { + $this->server->fault('no_domain_found', 'Invalid domain name.'); + return false; + } + + $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like '".$origin.'%'); + if(isset($rec['id'])) { + return intval($rec['id']); + } else { + $this->server->fault('no_domain_found', 'There is no domain ID with informed domain name.'); + return false; + } + } //* Add a record public function dns_zone_add($session_id, $client_id, $params) diff --git a/interface/web/dns/lib/remote.conf.php b/interface/web/dns/lib/remote.conf.php index b712334fbe22e8b3b1c6b802554ac683b840db2c..4caf53f379744cf7d7f74c043bf1bca870fdb23e 100644 --- a/interface/web/dns/lib/remote.conf.php +++ b/interface/web/dns/lib/remote.conf.php @@ -1,6 +1,6 @@ <?php -$function_list['dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions'; +$function_list['dns_zone_get,dns_zone_get_id,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions'; $function_list['dns_a_get,dns_a_add,dns_a_update,dns_a_delete'] = 'DNS a functions'; $function_list['dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete'] = 'DNS aaaa functions'; $function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';