示例#1
0
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'));
}
$body = '<div id="body_container" class="fm-noscroll">' . "\n";
if (!empty($response)) {
    $body .= '<div id="response"><p>' . $response . '</p></div>';
}
$body .= sprintf('<h2>%s</h2>
	<div id="pagination_container" class="submenus record-types">
示例#2
0
                        unlink($tmp_file);
                        exit;
                    }
                }
            } else {
                header('Location: ' . $GLOBALS['basename']);
            }
            break;
    }
}
define('FM_INCLUDE_SEARCH', true);
printHeader();
@printMenu();
$search_query = createSearchSQL(array('name', 'mapping', 'type'), 'domain_');
/** Check if any servers need their configs built first */
$reload_allowed = reloadAllowed();
if (!$reload_allowed && !$response) {
    $response = '<p>' . sprintf(__('You currently have no name servers hosting zones. <a href="%s">Click here</a> to manage one or more servers.'), getMenuURL(__('Servers'))) . '</p>';
}
echo printPageHeader($response, null, currentUserCan('manage_zones', $_SESSION['module']), $map);
$sort_direction = null;
$sort_field = 'domain_name';
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
/** Get zones based on access */
$user_capabilities = getUserCapabilities($_SESSION['user']['id'], 'all');
$limited_domain_ids = array_key_exists('access_specific_zones', $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0] ? "AND domain_id IN (" . implode(',', $user_capabilities[$_SESSION['module']]['access_specific_zones']) . ")" : null;
/** Process domain_view filtering */
if (isset($_GET['domain_view']) && !in_array(0, $_GET['domain_view'])) {
    foreach ((array) $_GET['domain_view'] as $view_id) {
示例#3
0
 /**
  * Assigns SOA to domain_id
  *
  * @since 1.3
  * @package facileManager
  * @subpackage fmDNS
  *
  * @param id $soa_id SOA ID to assign
  * @param id $domain_id Domain ID to assign to
  * @return boolean
  */
 function assignSOA($soa_id, $domain_id)
 {
     global $__FM_CONFIG, $fm_dns_zones;
     $old_soa_id = getNameFromID($domain_id, "fm_{$__FM_CONFIG['fmDNS']['prefix']}domains", 'domain_', 'domain_id', 'soa_id');
     if (basicUpdate("fm_{$__FM_CONFIG['fmDNS']['prefix']}domains", $domain_id, 'soa_id', $soa_id, 'domain_id')) {
         /** Delete old custom SOA */
         if (getNameFromID($old_soa_id, "fm_{$__FM_CONFIG['fmDNS']['prefix']}soa", 'soa_', 'soa_id', 'soa_template') == 'no') {
             updateStatus("fm_{$__FM_CONFIG['fmDNS']['prefix']}soa", $old_soa_id, 'soa_', 'deleted', 'soa_id');
         }
         if (!isset($fm_dns_zones)) {
             include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_zones.php';
         }
         /** Update the SOA serial number */
         foreach ($fm_dns_zones->getZoneTemplateChildren($domain_id) as $child_id) {
             $domain_id = getParentDomainID($child_id);
             if (reloadAllowed($domain_id) && getSOACount($domain_id) && getNSCount($domain_id)) {
                 $this->updateSOAReload($child_id, 'yes');
             }
         }
     }
 }
示例#4
0
    function displayRow($row, $map, $reload_allowed)
    {
        global $fmdb, $__FM_CONFIG;
        if (!currentUserCan(array('access_specific_zones', 'view_all'), $_SESSION['module'], array(0, $row->domain_id))) {
            return;
        }
        $zone_access_allowed = zoneAccessIsAllowed(array($row->domain_id));
        if ($row->domain_status == 'disabled') {
            $classes[] = 'disabled';
        }
        $response = $add_new = null;
        $checkbox = currentUserCan('reload_zones', $_SESSION['module']) ? '<td></td>' : null;
        $soa_count = getSOACount($row->domain_id);
        $ns_count = getNSCount($row->domain_id);
        $reload_allowed = reloadAllowed($row->domain_id);
        if (!$soa_count && $row->domain_type == 'master') {
            $response = __('The SOA record still needs to be created for this zone');
            $classes[] = 'attention';
        }
        if (!$ns_count && $row->domain_type == 'master' && !$response) {
            $response = __('One more more NS records still needs to be created for this zone');
            $classes[] = 'attention';
        }
        if ($row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            global $map;
            $add_new = displayAddNew($map, $row->domain_id, __('Clone this zone'), 'fa-plus-square-o');
        }
        $clones = $this->cloneDomainsList($row->domain_id);
        $clone_names = $clone_types = $clone_views = $clone_counts = null;
        foreach ($clones as $clone_id => $clone_array) {
            $clone_names .= '<p class="clone' . $clone_id . '"><a href="' . $clone_array['clone_link'] . '" title="' . __('Edit zone records') . '">' . $clone_array['clone_name'] . '</a>' . $clone_array['clone_edit'] . $clone_array['clone_delete'] . "</p>\n";
            $clone_types .= '<p class="clone' . $clone_id . '">' . __('clone') . '</p>' . "\n";
            $clone_views .= '<p class="clone' . $clone_id . '">' . $this->IDs2Name($clone_array['clone_views'], 'view') . "</p>\n";
            $clone_counts_array = explode('|', $clone_array['clone_count']);
            $clone_counts .= '<p class="clone' . $clone_id . '" title="' . __('Differences from parent zone') . '">';
            if ($clone_counts_array[0]) {
                $clone_counts .= '<span class="record-additions">' . $clone_counts_array[0] . '</span>&nbsp;';
            }
            if ($clone_counts_array[1]) {
                $clone_counts .= '&nbsp;<span class="record-subtractions">' . $clone_counts_array[1] . '</span> ';
            }
            if (!array_sum($clone_counts_array)) {
                $clone_counts .= '-';
            }
            $clone_counts .= "</p>\n";
        }
        if ($clone_names) {
            $classes[] = 'clones';
        }
        if ($soa_count && $row->domain_reload == 'yes' && $reload_allowed) {
            if (currentUserCan('reload_zones', $_SESSION['module']) && $zone_access_allowed) {
                $reload_zone = '<form name="reload" id="' . $row->domain_id . '" method="post" action="' . $GLOBALS['basename'] . '?map=' . $map . '"><input type="hidden" name="action" value="reload" /><input type="hidden" name="domain_id" id="domain_id" value="' . $row->domain_id . '" />' . $__FM_CONFIG['icons']['reload'] . '</form>';
                $checkbox = '<td><input type="checkbox" name="domain_list[]" value="' . $row->domain_id . '" /></td>';
            } else {
                $reload_zone = __('Reload Available') . '<br />';
            }
        } else {
            $reload_zone = null;
        }
        if ($reload_zone) {
            $classes[] = 'build';
        }
        /*
        		$edit_status = <<<FORM
        <form method="post" action="{$GLOBALS['basename']}?map={$map}">
        	<input type="hidden" name="action" value="download" />
        	<input type="hidden" name="domain_id" value="{$row->domain_id}" />
        	{$__FM_CONFIG['icons']['export']}
        	</form>
        FORM;
        */
        $edit_status = null;
        if (!$soa_count && $row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            $type = 'SOA';
        } elseif (!$ns_count && $row->domain_type == 'master' && currentUserCan('manage_zones', $_SESSION['module'])) {
            $type = 'NS';
        } else {
            $type = $row->domain_mapping == 'forward' ? 'A' : 'PTR';
        }
        if ($soa_count && $ns_count && $row->domain_type == 'master') {
            $edit_status = '<a href="preview.php" onclick="javascript:void window.open(\'preview.php?server_serial_no=-1&config=zone&domain_id=' . $row->domain_id . '\',\'1356124444538\',\'width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0\');return false;">' . $__FM_CONFIG['icons']['preview'] . '</a>';
        }
        if (currentUserCan('manage_zones', $_SESSION['module']) && $zone_access_allowed) {
            $edit_status .= '<a class="edit_form_link" name="' . $map . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="delete" href="#">' . $__FM_CONFIG['icons']['delete'] . '</a>' . "\n";
        }
        $domain_name = displayFriendlyDomainName($row->domain_name);
        $edit_name = $row->domain_type == 'master' ? "<a href=\"zone-records.php?map={$map}&domain_id={$row->domain_id}&record_type={$type}\" title=\"" . __('Edit zone records') . "\">{$domain_name}</a>" : $domain_name;
        $domain_view = $this->IDs2Name($row->domain_view, 'view');
        $class = 'class="' . implode(' ', $classes) . '"';
        $record_count = null;
        if ($row->domain_type == 'master') {
            $query = "SELECT COUNT(*) record_count FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}records WHERE account_id={$_SESSION['user']['account_id']} AND domain_id={$row->domain_id} AND record_status!='deleted'";
            $fmdb->query($query);
            $record_count = $fmdb->last_result[0]->record_count;
        }
        $template_icon = ($domain_template_id = getNameFromID($row->domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) ? sprintf('<i class="template-icon fa fa-picture-o" title="%s"></i>', sprintf(__('Based on %s'), getNameFromID($domain_template_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name'))) : null;
        echo <<<HTML
\t\t<tr title="{$response}" id="{$row->domain_id}" {$class}>
\t\t\t{$checkbox}
\t\t\t<td>{$row->domain_id}</td>
\t\t\t<td><b>{$edit_name}</b> {$template_icon} {$add_new} {$clone_names}</td>
\t\t\t<td>{$row->domain_type}
\t\t\t\t{$clone_types}</td>
\t\t\t<td>{$domain_view}
\t\t\t\t{$clone_views}</td>
\t\t\t<td align="center">{$record_count}
\t\t\t\t{$clone_counts}</td>
\t\t\t<td id="edit_delete_img">
\t\t\t\t{$reload_zone}
\t\t\t\t{$edit_status}
\t\t\t</td>
\t\t</tr>

HTML;
    }
示例#5
0
 /**
  * Sets SOA serials and reload flags per domain_id
  *
  * @since 2.1
  * @package facileManager
  * @subpackage fmDNS
  *
  * @param id $domain_id domain_id to set
  * @param id $record_type Record type to check
  * @param id $action Add or update
  * @return null
  */
 function processSOAUpdates($domain_id, $record_type, $action)
 {
     global $fm_dns_zones;
     if (!$fm_dns_zones) {
         include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_zones.php';
     }
     foreach ($fm_dns_zones->getZoneTemplateChildren($domain_id) as $child_id) {
         $domain_id = getParentDomainID($child_id);
         $soa_count = getSOACount($domain_id);
         $ns_count = getNSCount($domain_id);
         if (reloadAllowed($domain_id) && $soa_count && $ns_count) {
             $this->updateSOAReload($child_id, 'yes');
         }
         if ($action == 'add') {
             if (in_array($record_type, array('SOA', 'NS')) && $soa_count && $ns_count) {
                 /** Update all associated DNS servers */
                 setBuildUpdateConfigFlag(getZoneServers($child_id), 'yes', 'build');
             }
         }
     }
 }