Ejemplo n.º 1
0
	Updates or creates a domain name
*/
// includes
require "../include/config.php";
require "../include/amberphplib/main.php";
require "../include/application/main.php";
if (user_permissions_get('namedadmins')) {
    /*
    	Form Input
    */
    $obj_domain = new domain();
    $obj_domain->id = security_form_input_predefined("int", "id_domain", 0, "");
    // are we editing an existing domain or adding a new one?
    if ($obj_domain->id) {
        if (!$obj_domain->verify_id()) {
            log_write("error", "process", "The domain you have attempted to edit - " . $obj_name_server->id . " - does not exist in this system.");
        } else {
            // load existing data
            $obj_domain->load_data();
            // fetch domain data
            $obj_domain->data["domain_name"] = security_form_input_predefined("any", "domain_name", 1, "");
            $obj_domain->data["domain_description"] = security_form_input_predefined("any", "domain_description", 0, "");
        }
    } else {
        // new domain, can have some special input like IPV4 reverse
        $obj_domain->data["domain_type"] = security_form_input_predefined("any", "domain_type", 1, "");
        if ($obj_domain->data["domain_type"] == "domain_standard") {
            $obj_domain->data["domain_name"] = security_form_input_predefined("any", "domain_name", 1, "");
            $obj_domain->data["domain_description"] = security_form_input_predefined("any", "domain_description", 0, "");
        } elseif ($obj_domain->data["domain_type"] == "domain_reverse_ipv4") {
Ejemplo n.º 2
0
 function fetch_records($id_domain)
 {
     log_write("debug", "api_namedmanager", "Executing fetch_records()");
     if ($this->auth_online) {
         // verify input
         $id_domain = @security_script_input_predefined("int", $id_domain);
         if (!$id_domain || $id_domain == "error") {
             throw new SoapFault("Sender", "INVALID_INPUT");
         }
         // verify domain
         $obj_domain = new domain();
         $obj_domain->id = $id_domain;
         if (!$obj_domain->verify_id()) {
             throw new SoapFault("Sender", "INVALID_INPUT");
         }
         // if querying for a name server, we filter the NS records
         // to only members of that name server group.
         if ($this->auth_group) {
             $group_nameservers = array();
             $obj_ns_sql = new sql_query();
             $obj_ns_sql->string = "SELECT server_name FROM name_servers WHERE id_group='" . $this->auth_group . "' AND server_record='1'";
             $obj_ns_sql->execute();
             $obj_ns_sql->fetch_array();
             foreach ($obj_ns_sql->data as $data_ns) {
                 $group_nameservers[] = $data_ns["server_name"];
             }
             unset($obj_ns_sql);
         }
         // fetch domain records
         $obj_domain->load_data_record_all();
         if ($obj_domain->data["records"]) {
             foreach ($obj_domain->data["records"] as $data_record) {
                 // filter to NS records that apply for the selected domain group only
                 if ($this->auth_group) {
                     if ($data_record["type"] == "NS") {
                         if (!in_array($data_record["content"], $group_nameservers)) {
                             // Current NS record isn't in the domain group list. If the nameserver exists in
                             // other domain groups, we should exclude it to avoid contaminating across groups.
                             //
                             // However if the nameserver does *not* exist in NamedManager, then it must be an
                             // NS record for an external domain, so we should include it, so that external
                             // delegation works correcty.
                             $obj_ns_sql = new sql_query();
                             $obj_ns_sql->string = "SELECT id FROM name_servers WHERE server_name='" . $data_record["content"] . "' LIMIT 1";
                             $obj_ns_sql->execute();
                             if ($obj_ns_sql->num_rows()) {
                                 // nameserver exists in other groups, we should exclude this NS record.
                                 continue;
                             }
                         }
                     }
                 }
                 // add record to return array
                 $return_tmp = array();
                 $return_tmp["id_record"] = $data_record["id_record"];
                 $return_tmp["record_name"] = $data_record["name"];
                 $return_tmp["record_type"] = $data_record["type"];
                 $return_tmp["record_content"] = $data_record["content"];
                 $return_tmp["record_ttl"] = $data_record["ttl"];
                 $return_tmp["record_prio"] = $data_record["prio"];
                 $return[] = $return_tmp;
             }
             return $return;
         }
         return 0;
     } else {
         throw new SoapFault("Sender", "ACCESS_DENIED");
     }
 }