Ejemplo n.º 1
0
if ($record_type == 'SOA') {
    if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id')) {
        $record_type = $default_record_type;
    } elseif (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) {
        $record_type = $default_record_type;
    }
}
define('FM_INCLUDE_SEARCH', true);
printHeader();
@printMenu();
include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
$search_query = createSearchSQL(array('name', 'value', 'ttl', 'class', 'text', 'comment'), 'record_');
$supported_record_types = enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_type');
sort($supported_record_types);
$supported_record_types[] = 'SOA';
$parent_domain_ids = getZoneParentID($domain_id);
$zone_access_allowed = zoneAccessIsAllowed($parent_domain_ids);
if (!in_array($record_type, $supported_record_types)) {
    $record_type = $default_record_type;
}
$avail_types = buildRecordTypes($record_type, $parent_domain_ids, $map, $supported_record_types, $search_query);
$response = $form_data = $action = null;
if (reloadZone($domain_id)) {
    if (reloadAllowed($domain_id) && currentUserCan('reload_zones', $_SESSION['module']) && $zone_access_allowed) {
        $response = '** You need to <a href="" class="zone_reload" id="' . $domain_id . '">reload</a> this zone **';
    }
}
if (!getNSCount($domain_id)) {
    $response = sprintf('** %s **', __('One more more NS records still needs to be created for this zone'));
}
if (!getSOACount($domain_id)) {
Ejemplo n.º 2
0
 /**
  * Builds the records for $domain->domain_id
  *
  * @since 1.0
  * @package fmDNS
  */
 function buildRecords($domain, $server_serial_no)
 {
     global $fmdb, $__FM_CONFIG;
     $zone_file = $skipped_records = null;
     $domain_name_trim = trimFullStop($domain->domain_name);
     list($server_version) = explode('-', getNameFromID($server_serial_no, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_version'));
     /** Is this a cloned zone */
     if (isset($domain->parent_domain_id)) {
         $full_zone_clone = getOption('clones_use_dnames', $_SESSION['user']['account_id'], $_SESSION['module']) == 'yes' ? true : false;
         if ($domain->domain_clone_dname) {
             $full_zone_clone = $domain->domain_clone_dname == 'yes' ? true : false;
         }
         /** Are there any additional records? */
         basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', $domain->parent_domain_id, 'record_', 'domain_id', "AND `record_status`='active'");
         if ($fmdb->num_rows) {
             $full_zone_clone = false;
         }
         /** Are there any skipped records? */
         global $fm_dns_records;
         if (!class_exists('fm_dns_records')) {
             include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
         }
         if ($skipped_records = $fm_dns_records->getSkippedRecordIDs($domain->parent_domain_id)) {
             $full_zone_clone = false;
         }
         $valid_domain_ids = $full_zone_clone == false ? "IN (" . join(',', getZoneParentID($domain->parent_domain_id)) . ')' : "='{$domain->domain_id}' AND record_type='NS'";
     } else {
         $valid_domain_ids = "='{$domain->domain_id}'";
     }
     $order_sql = $domain->domain_mapping == 'reverse' ? array('record_type', 'INET_ATON(record_name)', 'record_value') : array('record_type', 'record_name', 'INET_ATON(record_value)');
     $record_sql = "AND domain_id {$valid_domain_ids} AND record_status='active'";
     $record_sql .= $skipped_records ? ' AND record_id NOT IN (' . implode(',', $skipped_records) . ')' : null;
     $result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', $order_sql, 'record_', $record_sql);
     if ($fmdb->num_rows) {
         $count = $fmdb->num_rows;
         $record_result = $fmdb->last_result;
         $separator = '   ';
         /** Add full zone clone dname record */
         if (isset($domain->parent_domain_id) && $full_zone_clone == true) {
             $record_result[$count]->record_name = '@';
             $record_result[$count]->record_value = trimFullStop(getNameFromID($domain->domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')) . '.';
             $record_result[$count]->record_ttl = null;
             $record_result[$count]->record_class = 'IN';
             $record_result[$count]->record_type = 'DNAME';
             $record_result[$count]->record_append = 'no';
             $record_result[$count]->record_comment = null;
             $count++;
         }
         for ($i = 0; $i < $count; $i++) {
             $domain_name = $this->getDomainName($domain->domain_mapping, $domain_name_trim);
             $record_comment = $record_result[$i]->record_comment ? ' ; ' . $record_result[$i]->record_comment : null;
             $record_name = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_name . '.' . $domain_name_trim . '.' : $record_result[$i]->record_name;
             if ($record_result[$i]->record_name[0] == '@') {
                 $record_name = $domain_name;
             }
             $record_start = str_pad($record_name, 25) . $separator . $record_result[$i]->record_ttl . $separator . $record_result[$i]->record_class . $separator . $record_result[$i]->record_type;
             switch ($record_result[$i]->record_type) {
                 case 'A':
                 case 'AAAA':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Host addresses';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_value . $record_comment . "\n";
                     break;
                 case 'CERT':
                     $record_array[$record_result[$i]->record_type]['Version'] = '9.7.0';
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Certificates';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_cert_type . ' ' . $record_result[$i]->record_key_tag . ' ' . $record_result[$i]->record_algorithm . "\t(\n\t\t\t" . str_replace("\n", "\n\t\t\t", $record_result[$i]->record_value) . ' )' . $record_comment . "\n";
                     break;
                 case 'CNAME':
                 case 'DNAME':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Aliases';
                     $record_value = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_value . '.' . $domain_name_trim . '.' : $record_result[$i]->record_value;
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_value . $record_comment . "\n";
                     break;
                 case 'DHCID':
                     $record_array[$record_result[$i]->record_type]['Version'] = '9.5.0';
                     $record_array[$record_result[$i]->record_type]['Description'] = 'DHCP ID records';
                     //						$record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_flags . ' 3 ' . $record_result[$i]->record_algorithm . "\t(\n\t\t\t" . str_replace("\n", "\n\t\t\t", $record_result[$i]->record_value) . ' )' . $record_comment . "\n";
                     break;
                 case 'DLV':
                 case 'DS':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'DNSSEC Lookaside Validation';
                     //						$record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_cert_type . ' ' . $record_result[$i]->record_key_tag . ' ' . $record_result[$i]->record_algorithm . "\t(\n\t\t\t" . str_replace("\n", "\n\t\t\t", $record_result[$i]->record_value) . ' )' . $record_comment . "\n";
                     break;
                 case 'DNSKEY':
                 case 'KEY':
                     $record_array[$record_result[$i]->record_type]['Version'] = '9.5.0';
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Key records';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_flags . ' 3 ' . $record_result[$i]->record_algorithm . "\t(\n\t\t\t" . str_replace("\n", "\n\t\t\t", $record_result[$i]->record_value) . ' )' . $record_comment . "\n";
                     break;
                 case 'HINFO':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Hardware information records';
                     $hardware = strpos($record_result[$i]->record_value, ' ') === false ? $record_result[$i]->record_value : '"' . $record_result[$i]->record_value . '"';
                     $os = strpos($record_result[$i]->record_os, ' ') === false ? $record_result[$i]->record_os : '"' . $record_result[$i]->record_os . '"';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $hardware . ' ' . $os . $record_comment . "\n";
                     break;
                 case 'KX':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Key Exchange records';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_priority . $separator . $record_result[$i]->record_value . $record_comment . "\n";
                     break;
                 case 'MX':
                     $record_array[2 . $record_result[$i]->record_type]['Description'] = 'Mail Exchange records';
                     $record_array[2 . $record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_priority . $separator . $record_result[$i]->record_value . $record_comment . "\n";
                     break;
                 case 'NAPTR':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Name Authority Pointer records';
                     $record_value = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_value . '.' . $domain_name_trim . '.' : $record_result[$i]->record_value;
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_weight . $separator . $record_result[$i]->record_priority . $separator . '"' . $record_result[$i]->record_flags . '"' . $separator . '"' . $record_result[$i]->record_params . '"' . $separator . '"' . $record_result[$i]->record_regex . '"' . $separator . $record_value . $record_comment . "\n";
                     break;
                 case 'NS':
                     $record_array[1 . $record_result[$i]->record_type]['Description'] = 'Name servers';
                     $record_value = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_value . '.' . $domain_name_trim . '.' : $record_result[$i]->record_value;
                     $record_array[1 . $record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_value . $record_comment . "\n";
                     break;
                 case 'PTR':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Addresses point to hosts';
                     $record_name = $record_result[$i]->record_append == 'yes' && $domain->domain_mapping == 'reverse' ? $record_result[$i]->record_name . '.' . $domain_name : $record_result[$i]->record_name;
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_value . $record_comment . "\n";
                     break;
                 case 'RP':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Responsible Persons';
                     $record_value = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_value . '.' . $domain_name_trim . '.' : $record_result[$i]->record_value;
                     $record_text = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_text . '.' . $domain_name_trim . '.' : $record_result[$i]->record_text;
                     if (!strlen($record_result[$i]->record_text)) {
                         $record_text = '.';
                     }
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_value . $separator . $record_text . $record_comment . "\n";
                     break;
                 case 'SSHFP':
                     $record_array[$record_result[$i]->record_type]['Version'] = '9.3.0';
                     $record_array[$record_result[$i]->record_type]['Description'] = 'SSH Key Fingerprint records';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_algorithm . ' 1 ' . $record_result[$i]->record_value . $record_comment . "\n";
                     break;
                 case 'SRV':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'Service records';
                     $record_value = $record_result[$i]->record_append == 'yes' ? $record_result[$i]->record_value . '.' . $domain_name_trim . '.' : $record_result[$i]->record_value;
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . $separator . $record_result[$i]->record_priority . $separator . $record_result[$i]->record_weight . $separator . $record_result[$i]->record_port . $separator . $record_value . $record_comment . "\n";
                     break;
                 case 'TXT':
                     $record_array[$record_result[$i]->record_type]['Description'] = 'TXT records';
                     $record_array[$record_result[$i]->record_type]['Data'][] = $record_start . "\t(\"" . join("\";\n\t\t\"", $this->characterSplit($record_result[$i]->record_value)) . "\")" . $record_comment . "\n";
                     break;
             }
         }
         ksort($record_array);
         /** Zone file output */
         foreach ($record_array as $rr => $rr_array) {
             /** Check if rr is supported by server_version */
             if (array_key_exists('Version', $rr_array) && version_compare($server_version, $rr_array['Version'], '<')) {
                 $zone_file .= ";\n; BIND " . $rr_array['Version'] . ' or greater is required for ' . $rr . ' types.' . "\n;\n\n";
                 continue;
             }
             $zone_file .= '; ' . $rr_array['Description'] . "\n";
             $zone_file .= implode('', $rr_array['Data']);
             $zone_file .= "\n";
         }
     }
     return $zone_file;
 }
Ejemplo n.º 3
0
function buildSQLRecords($record_type, $domain_id)
{
    global $fmdb, $__FM_CONFIG;
    if ($record_type == 'SOA') {
        $soa_query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` WHERE `account_id`='{$_SESSION['user']['account_id']}' AND\n\t\t\t`soa_id`=(SELECT `soa_id` FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE `domain_id`='{$domain_id}') AND \n\t\t\t`soa_template`='no' AND `soa_status`='active'";
        $fmdb->get_results($soa_query);
        if ($fmdb->num_rows) {
            $result = $fmdb->last_result;
        } else {
            return null;
        }
        foreach (get_object_vars($result[0]) as $key => $val) {
            $sql_results[$result[0]->soa_id][$key] = $val;
        }
        array_shift($sql_results[$result[0]->soa_id]);
        array_shift($sql_results[$result[0]->soa_id]);
        return $sql_results;
    } else {
        $valid_domain_ids = 'IN (' . join(',', getZoneParentID($domain_id)) . ')';
        if (in_array($record_type, array('A', 'AAAA'))) {
            $record_sql = "AND domain_id {$valid_domain_ids} AND record_type IN ('A', 'AAAA')";
        } else {
            $record_sql = "AND domain_id {$valid_domain_ids} AND record_type='{$record_type}'";
        }
        $result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_name', 'record_', $record_sql);
        if ($result) {
            $results = $fmdb->last_result;
            for ($i = 0; $i < $result; $i++) {
                $static_array = array('record_name', 'record_ttl', 'record_class', 'record_value', 'record_comment', 'record_status');
                $optional_array = array('record_priority', 'record_weight', 'record_port', 'record_os', 'record_cert_type', 'record_key_tag', 'record_algorithm', 'record_flags', 'record_text', 'record_params', 'record_regex', 'record_append');
                foreach ($static_array as $field) {
                    $sql_results[$results[$i]->record_id][$field] = $results[$i]->{$field};
                }
                foreach ($optional_array as $field) {
                    if ($results[$i]->{$field} != null) {
                        $sql_results[$results[$i]->record_id][$field] = $results[$i]->{$field};
                    }
                }
                /** Skipped record? */
                basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records_skipped', $results[$i]->record_id, 'record_', 'record_id', "AND domain_id={$domain_id}");
                $sql_results[$results[$i]->record_id]['record_skipped'] = $fmdb->num_rows ? 'on' : 'off';
            }
        }
        return $sql_results;
    }
}
Ejemplo n.º 4
0
 /**
  * Checks for duplicate entries during import process
  */
 function checkDuplicates($array, $domain_id)
 {
     global $fmdb, $__FM_CONFIG;
     $sql_select = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}records` WHERE record_status!='deleted' AND domain_id IN (" . join(',', getZoneParentID($domain_id)) . ") AND ";
     foreach ($array as $key => $data) {
         if ($key == 'record_comment' && $data == 'none') {
             $data = null;
         }
         $sql_select .= "{$key}='" . mysql_real_escape_string($data) . "' AND ";
     }
     $sql_select = rtrim($sql_select, ' AND ');
     $result = $fmdb->query($sql_select);
     if ($fmdb->num_rows) {
         return 'checked';
     }
     return null;
 }
Ejemplo n.º 5
0
 function buildZoneConfig($domain_id)
 {
     global $fmdb, $__FM_CONFIG, $fm_name;
     /** Check domain_id and soa */
     $parent_domain_ids = getZoneParentID($domain_id);
     if (!isset($parent_domain_ids[2])) {
         $query = "SELECT * FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}domains d, fm_{$__FM_CONFIG['fmDNS']['prefix']}soa s WHERE domain_status='active' AND d.account_id='{$_SESSION['user']['account_id']}' AND s.soa_id=d.soa_id AND d.domain_id IN (" . join(',', $parent_domain_ids) . ")";
     } else {
         $query = "SELECT * FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}domains d, fm_{$__FM_CONFIG['fmDNS']['prefix']}soa s WHERE domain_status='active' AND d.account_id='{$_SESSION['user']['account_id']}' AND\n\t\t\t\ts.soa_id=(SELECT soa_id FROM fm_dns_domains WHERE domain_id={$parent_domain_ids[2]})";
     }
     $result = $fmdb->query($query);
     if (!$fmdb->num_rows) {
         return sprintf('<p class="error">%s</p>' . "\n", __('Failed: There was no SOA record found for this zone.'));
     }
     $domain_details = $fmdb->last_result;
     extract(get_object_vars($domain_details[0]), EXTR_SKIP);
     $name_servers = $this->getNameServers($domain_name_servers, array('masters'));
     /** No name servers so return */
     if (!$name_servers) {
         return sprintf('<p class="error">%s</p>' . "\n", __('There are no DNS servers hosting this zone.'));
     }
     /** Loop through name servers */
     $name_server_count = $fmdb->num_rows;
     $response = '<textarea rows="12" cols="85">';
     $failures = false;
     for ($i = 0; $i < $name_server_count; $i++) {
         switch ($name_servers[$i]->server_update_method) {
             case 'cron':
                 /** Add records to fm_{$__FM_CONFIG['fmDNS']['prefix']}track_reloads */
                 foreach ($this->getZoneCloneChildren($domain_id) as $child_id) {
                     $this->addZoneReload($name_servers[$i]->server_serial_no, $child_id);
                 }
                 /** Set the server_update_config flag */
                 setBuildUpdateConfigFlag($name_servers[$i]->server_serial_no, 'yes', 'update');
                 $response .= '[' . $name_servers[$i]->server_name . '] ' . __('This zone will be updated on the next cron run.') . "\n";
                 break;
             case 'http':
             case 'https':
                 /** Test the port first */
                 if (!socketTest($name_servers[$i]->server_name, $name_servers[$i]->server_update_port, 10)) {
                     $response .= '[' . $name_servers[$i]->server_name . '] ' . sprintf(__('Failed: could not access %s (tcp/%d).'), $name_servers[$i]->server_update_method, $name_servers[$i]->server_update_port) . "\n";
                     $failures = true;
                     break;
                 }
                 /** Remote URL to use */
                 $url = $name_servers[$i]->server_update_method . '://' . $name_servers[$i]->server_name . ':' . $name_servers[$i]->server_update_port . '/' . $_SESSION['module'] . '/reload.php';
                 /** Data to post to $url */
                 $post_data = array('action' => 'reload', 'serial_no' => $name_servers[$i]->server_serial_no, 'domain_id' => $domain_id);
                 $post_result = unserialize(getPostData($url, $post_data));
                 if (!is_array($post_result)) {
                     /** Something went wrong */
                     return '<div class="error"><p>' . $post_result . '</p></div>' . "\n";
                 } else {
                     if (count($post_result) > 1) {
                         /** Loop through and format the output */
                         foreach ($post_result as $line) {
                             $response .= '[' . $name_servers[$i]->server_name . "] {$line}\n";
                             if (strpos(strtolower($line), 'fail')) {
                                 $failures = true;
                             }
                         }
                     } else {
                         $response .= "[{$name_servers[$i]->server_name}] " . $post_result[0] . "\n";
                         if (strpos(strtolower($post_result[0]), 'fail')) {
                             $failures = true;
                         }
                     }
                 }
                 /** Set the server_update_config flag */
                 setBuildUpdateConfigFlag($name_servers[$i]->server_serial_no, 'yes', 'update');
                 break;
             case 'ssh':
                 /** Test the port first */
                 if (!socketTest($name_servers[$i]->server_name, $name_servers[$i]->server_update_port, 10)) {
                     $response .= '[' . $name_servers[$i]->server_name . '] ' . sprintf(__('Failed: could not access %s (tcp/%d).'), $name_servers[$i]->server_update_method, $name_servers[$i]->server_update_port) . "\n";
                     $failures = true;
                     break;
                 }
                 /** Get SSH key */
                 $ssh_key = getOption('ssh_key_priv', $_SESSION['user']['account_id']);
                 if (!$ssh_key) {
                     return '<p class="error">' . sprintf(__('Failed: SSH key is not <a href="%s">defined</a>.'), getMenuURL(_('Settings'))) . '</p>' . "\n";
                 }
                 $temp_ssh_key = sys_get_temp_dir() . '/fm_id_rsa';
                 if (file_exists($temp_ssh_key)) {
                     @unlink($temp_ssh_key);
                 }
                 if (@file_put_contents($temp_ssh_key, $ssh_key) === false) {
                     return '<p class="error">' . sprintf(__('Failed: could not load SSH key into %s.'), $temp_ssh_key) . '</p>' . "\n";
                 }
                 @chmod($temp_ssh_key, 0400);
                 $ssh_user = getOption('ssh_user', $_SESSION['user']['account_id']);
                 if (!$ssh_user) {
                     return '<p class="error">' . sprintf(__('Failed: SSH user is not <a href="%s">defined</a>.'), getMenuURL(_('Settings'))) . '</p>' . "\n";
                 }
                 unset($post_result);
                 exec(findProgram('ssh') . " -t -i {$temp_ssh_key} -o 'StrictHostKeyChecking no' -p {$name_servers[$i]->server_update_port} -l {$ssh_user} {$name_servers[$i]->server_name} 'sudo php /usr/local/{$fm_name}/{$_SESSION['module']}/dns.php zones id={$domain_id}'", $post_result, $retval);
                 @unlink($temp_ssh_key);
                 if (!is_array($post_result)) {
                     /** Something went wrong */
                     return sprintf('<p class="error">%s</p>' . "\n", $post_result);
                 } else {
                     if (!count($post_result)) {
                         $post_result[] = __('Zone reload was successful.');
                     }
                     if (count($post_result) > 1) {
                         /** Loop through and format the output */
                         foreach ($post_result as $line) {
                             $response .= '[' . $name_servers[$i]->server_name . "] {$line}\n";
                             if (strpos(strtolower($line), 'fail')) {
                                 $failures = true;
                             }
                         }
                     } else {
                         $response .= "[{$name_servers[$i]->server_name}] " . $post_result[0] . "\n";
                         if (strpos(strtolower($post_result[0]), 'fail')) {
                             $failures = true;
                         }
                     }
                 }
                 /** Set the server_update_config flag */
                 setBuildUpdateConfigFlag($name_servers[$i]->server_serial_no, 'yes', 'update');
                 break;
         }
     }
     $response .= "</textarea>\n";
     /** Reset the domain_reload flag */
     if (!$failures) {
         global $fm_dns_records;
         if (!isset($fm_dns_records)) {
             include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
         }
         $fm_dns_records->updateSOAReload($domain_id, 'no');
     }
     addLogEntry(sprintf(__("Reloaded zone '%s'."), displayFriendlyDomainName($domain_name)));
     return $response;
 }
Ejemplo n.º 6
0
 function updateSOAReload($domain_id, $status = 'yes')
 {
     global $fmdb, $fm_dns_zones, $__FM_CONFIG;
     /** Check domain_id and soa */
     $parent_domain_ids = getZoneParentID($domain_id);
     if (isset($parent_domain_ids[2])) {
         $query = "SELECT * FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}domains d, fm_{$__FM_CONFIG['fmDNS']['prefix']}soa s WHERE domain_status='active' AND d.account_id='{$_SESSION['user']['account_id']}' AND\n\t\t\t\ts.soa_id=(SELECT soa_id FROM fm_dns_domains WHERE domain_id={$parent_domain_ids[2]})";
     } else {
         $query = "SELECT * FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}domains d, fm_{$__FM_CONFIG['fmDNS']['prefix']}soa s WHERE domain_status='active' AND d.account_id='{$_SESSION['user']['account_id']}' AND \n\t\t\t\ts.soa_id=d.soa_id AND d.domain_id IN (" . join(',', $parent_domain_ids) . ')';
     }
     $result = $fmdb->query($query);
     if (!$fmdb->num_rows) {
         return false;
     }
     /** Update the SOA serial number */
     if ($fmdb->last_result[0]->domain_reload == 'no') {
         if (!isset($fm_dns_zones)) {
             include_once ABSPATH . 'fm-modules/fmDNS/classes/class_zones.php';
         }
         $fm_dns_zones->updateSOASerialNo($domain_id, getNameFromID($domain_id, "fm_{$__FM_CONFIG['fmDNS']['prefix']}domains", 'domain_', 'domain_id', 'soa_serial_no'));
     }
     $id = ($clone_id = getNameFromID($domain_id, "fm_{$__FM_CONFIG['fmDNS']['prefix']}domains", 'domain_', 'domain_id', 'domain_clone_domain_id')) ? $clone_id : $domain_id;
     reloadZoneSQL($id, $status);
 }