| http://www.facilemanager.com/modules/fmdns/                             |
 +-------------------------------------------------------------------------+
 | Processes zone record updates                                           |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
if (empty($_POST)) {
    header('Location: ' . $GLOBALS['RELPATH']);
}
extract($_POST);
/** Should the user be here? */
if (!currentUserCan('manage_records', $_SESSION['module'])) {
    unAuth();
}
if (!zoneAccessIsAllowed(array($domain_id))) {
    unAuth();
}
if (in_array($record_type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) {
    unAuth();
}
/** Make sure we can handle all of the variables */
checkMaxInputVars();
$domain_info['id'] = $domain_id;
$domain_info['name'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name');
$domain_info['map'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping');
$domain_info['clone_of'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id');
$domain_info['template_id'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id');
if (isset($_POST['update'])) {
    if ($_POST['update']['soa_template_chosen']) {
        global $fm_dns_records;
Exemplo n.º 2
0
    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)) {
    $response = sprintf('** %s **', __('The SOA record still needs to be created for this zone'));
Exemplo n.º 3
0
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 | fmDNS: Easily manage one or more ISC BIND servers                       |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/modules/fmdns/                             |
 +-------------------------------------------------------------------------+
 | Processes zone reloads                                                  |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (is_array($_POST) && count($_POST)) {
    include ABSPATH . 'fm-modules/fmDNS/classes/class_zones.php';
    /** Clean variable */
    $domain_id = intval($_POST['domain_id']);
    /** Ensure user is allowed to reload zone */
    $zone_access_allowed = zoneAccessIsAllowed(array($domain_id), 'reload');
    if ($domain_id && $zone_access_allowed) {
        echo buildPopup('header', __('Zone Reload Results'));
        if (isset($_POST['domain_id']) && !empty($_POST['domain_id'])) {
            $response = $fm_dns_zones->buildZoneConfig($_POST['domain_id']);
        }
        echo $response . "<br />\n";
    } else {
        echo buildPopup('header', __('Error'));
        printf('<p>%s</p>' . "\n", __('You are not authorized to reload this zone.'));
    }
}
Exemplo n.º 4
0
    /**
     * Imports records from a zone file and presents a confirmation
     */
    function zoneImportWizard()
    {
        global $__FM_CONFIG, $fm_name;
        if (!currentUserCan('manage_records', $_SESSION['module'])) {
            return $this->unAuth('zone');
        }
        if (!zoneAccessIsAllowed(array($_POST['domain_id']))) {
            return $this->unAuth('zone');
        }
        $raw_contents = file_get_contents($_FILES['import-file']['tmp_name']);
        /** Strip commented lines */
        $clean_contents = preg_replace('/^;.*\\n?/m', '', $raw_contents);
        /** Strip blank lines */
        $clean_contents = preg_replace('/^\\n?/m', '', $clean_contents);
        /** Strip $GENERATE lines */
        $clean_contents = preg_replace('/^\\$GENERATE.*\\n?/m', '', $clean_contents, -1, $generate_count);
        /** Strip $ORIGIN lines */
        $clean_contents = preg_replace('/^\\$ORIGIN.*\\n?/m', '', $clean_contents, -1, $origin_count);
        /** Handle unsupported message */
        if ($generate_count || $origin_count) {
            $unsupported[] = sprintf('<h4>%s:</h4>', __('Unsupported Entries'));
            $unsupported[] = '<p class="soa_import">' . sprintf(__('%s currently does not support importing $GENERATE and $ORIGIN entries which were found in your zone file.'), $fm_name) . '</p>';
            $unsupported = implode("\n", $unsupported);
        } else {
            $unsupported = null;
        }
        $domain_name = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name');
        $domain_map = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping');
        $count = 1;
        /** Detect SOA */
        if (!getSOACount($_POST['domain_id']) && strpos($clean_contents, ' SOA ') !== false && (in_array('SOA', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module']))) {
            $raw_soa = preg_replace("/SOA(.+?)\\)/esim", "str_replace(PHP_EOL, ' ', '\\1')", $clean_contents);
            preg_match("/SOA(.+?)\\)/esim", $clean_contents, $raw_soa);
            preg_match("/TTL(.+?)\$/esim", $clean_contents, $raw_ttl);
            if (is_array($raw_ttl)) {
                $soa_array['soa_ttl'] = trim(preg_replace('/;(.+?)+/', '', $raw_ttl[1]));
            }
            if (is_array($raw_soa)) {
                $raw_soa = preg_replace('/;(.+?)+/', '', $raw_soa[1]);
                $soa = str_replace(array("\n", "\t", '(', ')', '  '), ' ', preg_replace('/\\s\\s+/', ' ', $raw_soa));
                $soa = str_replace(' ', '|', trim($soa));
                $soa_fields = explode('|', str_replace('||', '|', $soa));
                list($soa_array['soa_master_server'], $soa_array['soa_email_address'], $tmp_serial, $soa_array['soa_refresh'], $soa_array['soa_retry'], $soa_array['soa_expire'], $tmp_neg_cache) = $soa_fields;
                if (strpos($soa_array['soa_master_server'], $domain_name) !== false) {
                    $soa_array['soa_master_server'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_master_server']);
                    $soa_array['soa_email_address'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_email_address']);
                    $soa_array['soa_append'] = 'yes';
                } else {
                    $soa_array['soa_append'] = 'no';
                }
            }
            $soa_row = '<h4>SOA:</h4><p class="soa_import">' . trimFullStop($domain_name) . '. IN SOA ' . $soa_array['soa_master_server'];
            if ($soa_array['soa_append'] == 'yes') {
                $soa_row .= '.' . trimFullStop($domain_name) . '.';
            }
            $soa_row .= ' ' . $soa_array['soa_email_address'];
            if ($soa_array['soa_append'] == 'yes') {
                $soa_row .= '.' . trimFullStop($domain_name) . '.';
            }
            $soa_row .= ' ( &lt;autogen_serial&gt; ' . $soa_array['soa_refresh'] . ' ' . $soa_array['soa_retry'] . ' ' . $soa_array['soa_expire'] . ' ' . $soa_array['soa_ttl'] . ' )';
            $soa_row = <<<HTML
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_master_server]" value="{$soa_array['soa_master_server']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_email_address]" value="{$soa_array['soa_email_address']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_refresh]" value="{$soa_array['soa_refresh']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_retry]" value="{$soa_array['soa_retry']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_expire]" value="{$soa_array['soa_expire']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_ttl]" value="{$soa_array['soa_ttl']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][record_type]" value="SOA" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_append]" value="{$soa_array['soa_append']}" />
\t\t\t\t\t\t{$soa_row}
\t\t\t\t\t\t<span><label><input type="checkbox" name="create[{$count}][record_skip]" />Skip Import</label></span>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t
\t\t\t\t\t\t<h4>Records:</h4>

HTML;
            $count++;
        } else {
            $soa_row = null;
        }
        $clean_contents = str_replace('.' . trimFullStop($domain_name) . '.', '', $clean_contents);
        $clean_contents = str_replace(trimFullStop($domain_name) . '.', '', $clean_contents);
        $available_record_types = array_filter(enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_type'), 'removeRestrictedRR');
        sort($available_record_types);
        /** Loop through the lines */
        $lines = explode(PHP_EOL, $clean_contents);
        $failed = 0;
        $rows = null;
        $valid_hashes = array(';', '//', '#');
        foreach ($lines as $line) {
            $null_keys = array('record_ttl', 'record_priority', 'record_weight', 'record_port');
            foreach ($null_keys as $key) {
                $array[$key] = null;
            }
            if (!strlen(trim($line))) {
                continue;
            }
            foreach ($valid_hashes as $tmp_hash) {
                if (strpos($line, $tmp_hash)) {
                    $hash = $tmp_hash;
                    break;
                } else {
                    $hash = null;
                }
            }
            if ($hash == '//') {
                $hash = '\\/\\/';
            }
            /** Break up the line for comments */
            if ($hash) {
                $comment_parts = preg_split("/{$hash}+/", $line);
                $array['record_comment'] = trim($comment_parts[1]) ? trim($comment_parts[1]) : 'none';
            } else {
                $comment_parts[0] = $line;
                $array['record_comment'] = 'none';
            }
            /** Break up the line for parts */
            $parts = preg_split('/\\s+/', trim($comment_parts[0]));
            if ($domain_map == 'forward') {
                if (in_array('MX', $parts)) {
                    switch (array_search('MX', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                    }
                } elseif (in_array('SRV', $parts)) {
                    switch (array_search('SRV', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                    }
                } elseif (in_array('TXT', $parts)) {
                    $key = array_search('TXT', $parts);
                    $txt_record = null;
                    for ($i = $key + 1; $i < count($parts); $i++) {
                        $txt_record .= $parts[$i] . ' ';
                    }
                    $parts[$key + 1] = rtrim($txt_record);
                    switch ($key) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                    $array['record_value'] = str_replace('"', '', $array['record_value']);
                } elseif (in_array('A', $parts) || in_array('CNAME', $parts) || in_array('AAAA', $parts)) {
                    if (in_array('AAAA', $parts)) {
                        $key = array_search('AAAA', $parts);
                    } else {
                        $key = in_array('A', $parts) ? array_search('A', $parts) : array_search('CNAME', $parts);
                    }
                    switch ($key) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                }
            } else {
                if (in_array('PTR', $parts)) {
                    switch (array_search('PTR', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if ($parts[0] > 255) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                }
            }
            if (in_array('NS', $parts) && in_array('NS', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module'])) {
                switch (array_search('NS', $parts)) {
                    case 3:
                        list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        break;
                    case 2:
                        if (is_numeric($parts[0])) {
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        } else {
                            list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        }
                        break;
                    case 1:
                        $array['record_name'] = isset($current_name) ? $current_name : '@';
                        list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                }
            }
            if (empty($array['record_name']) && !empty($array['record_comment'])) {
                continue;
            }
            $array['record_append'] = substr($array['record_value'], -1) == '.' ? 'no' : 'yes';
            /** Set current_name to check for blanks on next run */
            $current_name = $array['record_name'];
            /** Automatically skip duplicates */
            $checked = $this->checkDuplicates($array, $_POST['domain_id']);
            $rows .= <<<ROW
\t\t\t\t\t<tr class="import_swap">
\t\t\t\t\t\t<td><span id="name{$count}" onclick="exchange(this);">{$array['record_name']}</span><input onblur="exchange(this);" type="text" id="name{$count}b" name="create[{$count}][record_name]" value="{$array['record_name']}" /></td>
\t\t\t\t\t\t<td><span id="ttl{$count}" onclick="exchange(this);">{$array['record_ttl']}</span><input onblur="exchange(this);" type="number" id="ttl{$count}b" name="create[{$count}][record_ttl]" value="{$array['record_ttl']}" /></td>
\t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_class]" value="{$array['record_class']}" />{$array['record_class']}</td>
\t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_type]" value="{$array['record_type']}" />{$array['record_type']}</td>
\t\t\t\t\t\t<td><span id="priority{$count}" onclick="exchange(this);">{$array['record_priority']}</span><input onblur="exchange(this);" type="number" id="priority{$count}b" name="create[{$count}][record_priority]" value="{$array['record_priority']}" /></td>
\t\t\t\t\t\t<td><span id="value{$count}" onclick="exchange(this);">{$array['record_value']}</span><input onblur="exchange(this);" type="text" id="value{$count}b" name="create[{$count}][record_value]" value="{$array['record_value']}" /></td>
\t\t\t\t\t\t<td><span id="weight{$count}" onclick="exchange(this);">{$array['record_weight']}</span><input onblur="exchange(this);" type="number" id="weight{$count}b" name="create[{$count}][record_weight]" value="{$array['record_weight']}" /></td>
\t\t\t\t\t\t<td><span id="port{$count}" onclick="exchange(this);">{$array['record_port']}</span><input onblur="exchange(this);" type="number" id="port{$count}b" name="create[{$count}][record_port]" value="{$array['record_port']}" /></td>
\t\t\t\t\t\t<td><span id="comment{$count}" onclick="exchange(this);">{$array['record_comment']}</span><input onblur="exchange(this);" type="text" id="comment{$count}b" name="create[{$count}][record_comment]" value="{$array['record_comment']}" /></td>
\t\t\t\t\t\t<td style="text-align: center;" nowrap><input type="hidden" name="create[{$count}][record_append]" value="{$array['record_append']}" />{$array['record_append']}</td>
\t\t\t\t\t\t<td style="text-align: center;"><label><input type="checkbox" name="create[{$count}][record_skip]" {$checked} />Skip Import</label></td>
\t\t\t\t\t</tr>

ROW;
            $count++;
        }
        $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'views');
        $title_array = array(__('Record'), __('TTL'), __('Class'), __('Type'), __('Priority'), __('Value'), __('Weight'), __('Port'), __('Comment'));
        $title_array[] = array('title' => __('Append Domain'), 'style' => 'text-align: center;', 'nowrap' => null);
        $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions');
        $table_header = displayTableHeader($table_info, $title_array);
        $popup_header = buildPopup('header', __('Import Verification'));
        $popup_footer = buildPopup('footer', __('Import'), array('import' => 'submit', 'cancel_button' => 'cancel'));
        $body = <<<BODY
\t\t<form method="post" action="zone-records-write.php">
\t\t{$popup_header}
\t\t\t<p>Domain: {$domain_name}</p>
\t\t\t<input type="hidden" name="domain_id" value="{$_POST['domain_id']}">
\t\t\t<input type="hidden" name="map" value="{$domain_map}">
\t\t\t<input type="hidden" name="import_records" value="true">
\t\t\t<input type="hidden" name="import_file" value="{$_FILES['import-file']['name']}">
\t\t\t{$unsupported}
\t\t\t{$soa_row}
\t\t\t{$table_header}
\t\t\t\t{$rows}
\t\t\t\t</tbody>
\t\t\t</table>
\t\t\t<br />
\t\t{$popup_footer}
\t\t</form>
BODY;
        return $body;
    }
Exemplo n.º 5
0
 /**
  * Process bulk zone reloads
  *
  * @since 1.2
  * @package facileManager
  */
 function doBulkZoneReload($domain_id)
 {
     global $fmdb, $__FM_CONFIG;
     /** Check serial number */
     basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', sanitize($domain_id), 'domain_', 'domain_id');
     if (!$fmdb->num_rows) {
         return sprintf(__('%s is not a valid zone ID.'), $domain_id);
     }
     $server_details = $fmdb->last_result;
     extract(get_object_vars($server_details[0]), EXTR_SKIP);
     $response[] = displayFriendlyDomainName($domain_name);
     /** Ensure domain is reloadable */
     if ($domain_reload != 'yes') {
         $response[] = ' --> ' . __('Failed: Zone is not available for reload.');
     }
     /** Ensure domain is master */
     if (count($response) == 1 && $domain_type != 'master') {
         $response[] = ' --> ' . __('Failed: Zone is not a master zone.');
     }
     /** Ensure user is allowed to reload zone */
     $zone_access_allowed = zoneAccessIsAllowed(array($domain_id), 'reload');
     if (count($response) == 1 && !$zone_access_allowed) {
         $response[] = ' --> ' . __('Failed: You do not have permission to reload this zone.');
     }
     /** Format output */
     if (count($response) == 1) {
         foreach (makePlainText($this->buildZoneConfig($domain_id), true) as $line) {
             $response[] = ' --> ' . $line;
         }
     }
     $response[] = "\n";
     return implode("\n", $response);
 }
Exemplo n.º 6
0
function autoCreatePTR($domain_id, $record_type, $data)
{
    if ($record_type == 'A' && isset($data['PTR']) && zoneAccessIsAllowed(array($data['PTR']))) {
        global $__FM_CONFIG;
        $domain = '.' . trimFullStop(getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')) . '.';
        if ($data['record_name'][0] == '@') {
            $data['record_name'] = null;
            $domain = substr($domain, 1);
        }
        /** Get reverse zone */
        if (!strrpos($data['record_value'], ':')) {
            $rev_domain = trimFullStop(getNameFromID($data['PTR'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name'));
            $domain_pieces = array_reverse(explode('.', $rev_domain));
            $domain_parts = count($domain_pieces);
            $subnet_ips = null;
            for ($i = 2; $i < $domain_parts; $i++) {
                $subnet_ips .= $domain_pieces[$i] . '.';
            }
            $record_octets = array_reverse(explode('.', str_replace($subnet_ips, '', $data['record_value'])));
            $temp_record_value = null;
            for ($j = 0; $j < count($record_octets); $j++) {
                $temp_record_value .= $record_octets[$j] . '.';
            }
            $data['record_value'] = rtrim($temp_record_value, '.');
        } else {
            /** IPv6 not yet supported */
            break;
        }
        $array = array('record_name' => $data['record_value'], 'record_value' => $data['record_name'] . $domain, 'record_comment' => $data['record_comment'], 'record_status' => $data['record_status']);
        global $fm_dns_records;
        $fm_dns_records->add($data['PTR'], 'PTR', $array, 'replace');
    }
}
Exemplo n.º 7
0
/**
 * Gets the count for zones requiring a reload
 *
 * @since 2.0
 * @package facileManager
 * @subpackage fmDNS
 *
 * @param string $return_what What to return (count|ids)
 * @return integer|array
 */
function getZoneReloads($return_what)
{
    global $fmdb, $__FM_CONFIG;
    $zone_count = 0;
    $zone_ids = array();
    basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', 'domain_id', 'domain_', 'AND domain_reload!="no"');
    if ($fmdb->num_rows) {
        $num_rows = $fmdb->num_rows;
        $domain_list = $fmdb->last_result;
        for ($i = 0; $i < $num_rows; $i++) {
            $zone_access_allowed = zoneAccessIsAllowed(array($domain_list[$i]->domain_id, $domain_list[$i]->domain_clone_domain_id));
            if (currentUserCan('reload_zones', $_SESSION['module']) && $zone_access_allowed) {
                $zone_count++;
                $zone_ids[] = $domain_list[$i]->domain_clone_domain_id ? $domain_list[$i]->domain_clone_domain_id : $domain_list[$i]->domain_id;
            }
        }
    }
    return $return_what == 'count' ? $zone_count : $zone_ids;
}