} else { $zone_options = __('You need to define one or more zones first.'); } $tools_option[] = sprintf('<h2>%s</h2> <p>%s</p> <table class="form-table"> <tr> <th>%s:</th> <td><input id="import-file" name="import-file" type="file" /></td> </tr> <tr> <th>%s:</th> <td> %s<br /> <p id="table_edits" name="domains"><a id="plus" href="#" title="%s" name="forward">+ %s</a></p> </td> </table> %s <br />', __('Import Zone Files'), __('Import records from BIND-compatible zone files.'), __('File to import'), __('Zone to import to'), $zone_options, __('Add New'), __('Add New Zone'), $button); $button = null; if (currentUserCan('run_tools') && currentUserCan('manage_servers', $_SESSION['module'])) { $button = sprintf('<p class="step"><input id="dump-cache" name="submit" type="submit" value="%s" class="button" /> ' . '<input id="clear-cache" name="submit" type="submit" value="%s" class="button" /></p>', __('Dump Cache'), __('Clear Cache')); } $name_servers = buildSelect('domain_name_servers', 'domain_name_servers', availableDNSServers('id'), 0, 5, null, true, null, null, __('Select one or more servers')); $tools_option[] = sprintf('<div id="admin-tools-select"> <h2>%s</h2> <p>%s</p> %s %s </div> <br />', __('Cache Management'), __('Dump or clear server cache.'), $name_servers, $button);
/** * Displays the form to add new zone */ function printForm($data = '', $action = 'create', $map = 'forward', $show = array('popup', 'template_menu', 'create_template')) { global $fmdb, $__FM_CONFIG, $fm_dns_acls, $fm_module_options; $domain_id = $domain_view = $domain_name_servers = 0; $domain_type = $domain_clone_domain_id = $domain_name = $template_name = null; $disabled = $action == 'create' ? null : 'disabled'; if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) { if (is_array($_POST)) { $domain_id = $_POST[$action . 'Zone']['ZoneID']; extract($_POST[$action . 'Zone'][$domain_id]); } } elseif (@is_object($data[0])) { extract(get_object_vars($data[0])); } elseif (!empty($_POST) && array_key_exists('is_ajax', $_POST)) { extract($_POST); $domain_clone_dname = null; $domain_template_id = getNameFromID($domain_clone_domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id'); if ($domain_template_id) { $domain_name_servers = getNameFromID($domain_template_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name_servers'); } else { $domain_name_servers = getNameFromID($domain_clone_domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name_servers'); } } $domain_name = function_exists('idn_to_utf8') ? idn_to_utf8($domain_name) : $domain_name; /** Process multiple views */ if (strpos($domain_view, ';')) { $domain_view = explode(';', rtrim($domain_view, ';')); if (in_array('0', $domain_view)) { $domain_view = 0; } } /** Process multiple domain name servers */ if (strpos($domain_name_servers, ';')) { $domain_name_servers = explode(';', rtrim($domain_name_servers, ';')); if (in_array('0', $domain_name_servers)) { $domain_name_servers = 0; } } /** Get field length */ $domain_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_name'); $views = buildSelect('domain_view', 'domain_view', $this->availableViews(), $domain_view, 4, null, true); $zone_maps = buildSelect('domain_mapping', 'domain_mapping', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_mapping'), $map, 1, $disabled); $domain_types = buildSelect('domain_type', 'domain_type', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_type'), $domain_type, 1, $disabled); $clone = buildSelect('domain_clone_domain_id', 'domain_clone_domain_id', $this->availableCloneDomains($map, $domain_id), $domain_clone_domain_id, 1, $disabled); $name_servers = buildSelect('domain_name_servers', 'domain_name_servers', availableDNSServers('id'), $domain_name_servers, 1, null, true); $forwarders_show = $masters_show = 'none'; $domain_forward_servers = $domain_master_servers = $domain_forward = null; $available_acls = json_encode(array()); if ($domain_type == 'forward') { $forwarders_show = 'block'; $domain_forward_servers = str_replace(';', "\n", rtrim(str_replace(' ', '', getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='forwarders'")), ';')); $domain_forward = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='forward'"); $available_acls = $fm_dns_acls->buildACLJSON($domain_forward_servers, 0, 'none'); } elseif (in_array($domain_type, array('slave', 'stub'))) { $masters_show = 'block'; $domain_master_servers = str_replace(';', "\n", rtrim(str_replace(' ', '', getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='masters'")), ';')); $available_acls = $fm_dns_acls->buildACLJSON($domain_master_servers, 0, 'none'); } /** Build forward options */ $query = "SELECT def_type,def_dropdown FROM fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}functions WHERE def_option = 'forward'"; $fmdb->get_results($query); if ($fmdb->num_rows) { $forward_dropdown = $fm_module_options->populateDefTypeDropdown($fmdb->last_result[0]->def_type, $domain_forward, 'domain_forward'); } if ($action == 'create') { $domain_template_id = $this->getDefaultZone(); $zone_show = $domain_template_id ? 'none' : 'block'; global $fm_dns_records; if (!isset($fm_dns_records)) { include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_records.php'; } $soa_templates = '<tr id="define_soa"> <th>SOA</th> <td>' . buildSelect('soa_id', 'soa_id', $fm_dns_records->availableSOATemplates($map), $fm_dns_records->getDefaultSOA()) . '</td></tr>'; } else { $zone_show = 'block'; $soa_templates = $domain_templates = null; } /** Clone options */ if ($domain_clone_domain_id) { $clone_override_show = 'block'; $clone_dname_checked = $domain_clone_dname ? 'checked' : null; $clone_dname_options_show = $domain_clone_dname ? 'block' : 'none'; if (isset($no_template)) { $domain_template_id = 0; $zone_show = 'block'; } } else { $clone_override_show = $clone_dname_options_show = 'none'; $clone_dname_checked = null; } $clone_dname_dropdown = buildSelect('domain_clone_dname', 'domain_clone_dname', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_clone_dname'), $domain_clone_dname); $additional_config_link = $action == 'create' || !in_array($domain_type, array('master', 'slave')) || !currentUserCan('manage_servers', $_SESSION['module']) ? null : sprintf('<tr class="include-with-template"><td></td><td><p><a href="config-options.php?domain_id=%d">%s</a></p></td></tr>', $domain_id, __('Configure Additional Options')); $popup_title = $action == 'create' ? __('Add Zone') : __('Edit Zone'); $popup_header = buildPopup('header', $popup_title); $popup_footer = buildPopup('footer'); if (array_search('create_template', $show) !== false) { $template_name_show_hide = 'none'; $create_template = sprintf('<tr id="create_template"> <th>%s</th> <td><input type="checkbox" id="domain_create_template" name="domain_template" value="yes" /><label for="domain_create_template"> %s</label></td> </tr>', __('Create Template'), __('yes')); } else { $template_name_show_hide = 'table-row'; $create_template = <<<HTML \t\t\t<input type="hidden" id="domain_create_template" name="domain_template" value="no" /> \t\t\t<input type="hidden" name="domain_default" value="no" /> HTML; } if (array_search('template_menu', $show) !== false) { $classes = 'zone-form'; $select_template = '<tr id="define_template" class="include-with-template"> <th>' . __('Template') . '</th> <td>' . buildSelect('domain_template_id', 'domain_template_id', $this->availableZoneTemplates(), $domain_template_id); if ($action == 'edit') { $select_template .= sprintf('<p>%s</p>', __('Changing the template will delete all config options for this zone.')); } $select_template .= '</td></tr>'; } else { $classes = 'zone-template-form'; $select_template = null; } if (array_search('template_name', $show) !== false) { $default_checked = $domain_id == $this->getDefaultZone() ? 'checked' : null; $template_name = sprintf('<tr id="domain_template_default" style="display: %s"> <th></th> <td><input type="checkbox" id="domain_default" name="domain_default" value="yes" %s /><label for="domain_default"> %s</label></td> <input type="hidden" id="domain_create_template" name="domain_template" value="yes" /> </tr>', $template_name_show_hide, $default_checked, __('Make Default Template')); } $return_form = array_search('popup', $show) !== false ? '<form name="manage" id="manage" method="post" action="">' . $popup_header : null; $return_form .= sprintf('<input type="hidden" name="action" value="%s" /> <input type="hidden" name="domain_id" value="%d" /> <table class="form-table %s"> <tr class="include-with-template"> <th><label for="domain_name">%s</label></th> <td><input type="text" id="domain_name" name="domain_name" size="40" value="%s" maxlength="%d" /></td> </tr> %s <tr> <th><label for="domain_view">%s</label></th> <td>%s</td> </tr> <tr> <th><label for="domain_mapping">%s</label></th> <td>%s</td> </tr> <tr> <th><label for="domain_type">%s</label></th> <td> %s <div id="define_forwarders" style="display: %s"> <p>%s</p> <input type="hidden" name="domain_required_servers[forwarders]" id="domain_required_servers" class="address_match_element" data-placeholder="%s" value="%s" /><br /> ( address_match_element ) </div> <div id="define_masters" style="display: %s"> <input type="hidden" name="domain_required_servers[masters]" id="domain_required_servers" class="address_match_element" data-placeholder="%s" value="%s" /><br /> ( address_match_element ) </div> </td> </tr> <tr> <th><label for="domain_clone_domain_id">%s</label></th> <td> %s <div id="clone_override" style="display: %s"> <p><input type="checkbox" id="domain_clone_dname_override" name="domain_clone_dname_override" value="yes" %s /><label for="domain_clone_dname_override"> %s</label></p> <div id="clone_dname_options" style="display: %s"> %s </div> </div> </td> </tr> <tr> <th><label for="domain_name_servers">%s</label></th> <td>%s</td> </tr> %s </table>', $action, $domain_id, $classes, __('Domain Name'), $domain_name, $domain_name_length, $select_template, __('Views'), $views, __('Zone Map'), $zone_maps, __('Zone Type'), $domain_types, $forwarders_show, $forward_dropdown, __('Define forwarders'), $domain_forward_servers, $masters_show, __('Define masters'), $domain_master_servers, __('Clone Of (optional)'), $clone, $clone_override_show, $clone_dname_checked, __('Override DNAME Resource Record Setting'), $clone_dname_options_show, $clone_dname_dropdown, __('DNS Servers'), $name_servers, $soa_templates . $additional_config_link . $create_template . $template_name); $return_form .= array_search('popup', $show) !== false ? $popup_footer . '</form>' : null; $return_form .= <<<HTML \t\t<script> \t\t\t\$(document).ready(function() { \t\t\t\t\$("#manage select").select2({ \t\t\t\t\twidth: '100%', \t\t\t\t\tminimumResultsForSearch: 10, \t\t\t\t\tallowClear: true \t\t\t\t}); \t\t\t\t\$(".address_match_element").select2({ \t\t\t\t\tcreateSearchChoice:function(term, data) { \t\t\t\t\t\tif (\$(data).filter(function() { \t\t\t\t\t\t\treturn this.text.localeCompare(term)===0; \t\t\t\t\t\t}).length===0) \t\t\t\t\t\t{return {id:term, text:term};} \t\t\t\t\t}, \t\t\t\t\tmultiple: true, \t\t\t\t\twidth: '300px', \t\t\t\t\ttokenSeparators: [",", " ", ";"], \t\t\t\t\tdata: {$available_acls} \t\t\t\t}); \t\t\t\t\$("#domain_clone_dname_override").click(function() { \t\t\t\t\tif (\$(this).is(':checked')) { \t\t\t\t\t\t\$('#clone_dname_options').show('slow'); \t\t\t\t\t} else { \t\t\t\t\t\t\$('#clone_dname_options').slideUp(); \t\t\t\t\t} \t\t\t\t}); \t\t\t\t\$("#domain_create_template").click(function() { \t\t\t\t\tif (\$(this).is(':checked')) { \t\t\t\t\t\t\$('#domain_template_name').show('slow'); \t\t\t\t\t} else { \t\t\t\t\t\t\$('#domain_template_name').slideUp(); \t\t\t\t\t} \t\t\t\t}); \t\t\t\tif (\$('#domain_template_id').val() != '') { \t\t\t\t\t\$('.zone-form > tbody > tr:not(.include-with-template, #domain_template_default)').slideUp(); \t\t\t\t} else { \t\t\t\t\t\$('.zone-form > tbody > tr:not(.include-with-template, #domain_template_default)').show('slow'); \t\t\t\t} \t\t\t\tif (\$('#domain_clone_domain_id').val() != '') { \t\t\t\t\t\$('.zone-form > tbody > tr#define_soa').slideUp(); \t\t\t\t\t\$('.zone-form > tbody > tr#create_template').slideUp(); \t\t\t\t} else { \t\t\t\t\tif(\$('#domain_template_id').val() == '') { \t\t\t\t\t\t\$('.zone-form > tbody > tr#define_soa').show('slow'); \t\t\t\t\t\t\$('.zone-form > tbody > tr#create_template').show('slow'); \t\t\t\t\t} \t\t\t\t} \t\t\t}); \t\t</script> HTML; return $return_form; }
/** * Builds the server listing in a dropdown menu * * @since 1.0 * @package facileManager * @subpackage fmDNS */ function buildServerSubMenu($server_serial_no = 0, $class = null) { $server_list = buildSelect('server_serial_no', 'server_serial_no', availableDNSServers(), $server_serial_no, 1, null, false, 'this.form.submit()'); $hidden_inputs = null; foreach ($GLOBALS['URI'] as $param => $value) { if ($param == 'server_serial_no') { continue; } $hidden_inputs .= '<input type="hidden" name="' . $param . '" value="' . $value . '" />' . "\n"; } $class = $class ? 'class="' . $class . '"' : null; $return = <<<HTML \t<div id="configtypesmenu" {$class}> \t\t<form action="{$GLOBALS['basename']}" method="GET"> \t\t{$hidden_inputs} \t\t{$server_list} \t\t</form> \t</div> HTML; return $return; }