mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-20 20:13:40 +03:00
Resolve conflicts and create a converter for old values to the new ones. Also let the user know they should be changing their configuration
This commit is contained in:
commit
a2aba25712
4 changed files with 41 additions and 52 deletions
|
@ -50,9 +50,9 @@ $templates[] = array(
|
|||
$defaults['soa_edit'] = 'INCEPTION-INCREMENT';
|
||||
$defaults['soa_edit_api'] = 'INCEPTION-INCREMENT';
|
||||
$defaults['defaulttype'] = 'Master'; # Choose between 'Native' or 'Master'
|
||||
$defaults['primaryns'] = 'unconfigured.primaryns'; # The value of the first NS-record
|
||||
$defaults['secondaryns'] = 'unconfigured.secondaryns'; # The value of the second NS-record
|
||||
$defaults['ttl'] = 3600; # Default TTL for records
|
||||
$defaults['ns'][0] = 'unconfigured.primaryns'; # The value of the first NS-record
|
||||
$defaults['ns'][1] = 'unconfigured.secondaryns'; # The value of the second NS-record
|
||||
$defaults['ttl'] = 3600; # Default TTL for records
|
||||
|
||||
## UI Options
|
||||
$menutype = 'horizontal'; # horizontal|vertical - use a horizontal or vertical menu
|
||||
|
|
|
@ -31,6 +31,14 @@ if (!isset($authdb)) {
|
|||
$blocklogin = TRUE;
|
||||
}
|
||||
|
||||
if (isset($defaults['primaryns'])) {
|
||||
$errormsg = "You should reconfigure your \$defaults['primaryns'] settings to use <code>\$defaults['ns'][0]</code>. We converted if for you now.";
|
||||
$defaults['ns'][] = $defaults['primaryns'];
|
||||
if (isset($defaults['secondaryns'])) {
|
||||
$defaults['ns'][] = $defaults['secondaryns'];
|
||||
}
|
||||
}
|
||||
|
||||
/* No need to change stuf below */
|
||||
|
||||
if (function_exists('curl_init') === FALSE) {
|
||||
|
|
58
index.php
58
index.php
|
@ -453,23 +453,21 @@ $(document).ready(function () {
|
|||
edit: false,
|
||||
inputClass: 'template'
|
||||
},
|
||||
nameserver1: {
|
||||
title: 'Pri. Nameserver',
|
||||
nameserver: {
|
||||
title: 'Nameservers',
|
||||
create: true,
|
||||
list: false,
|
||||
edit: false,
|
||||
input: function(data) {
|
||||
var $template = data.form.find('#Edit-template');
|
||||
var $elem = $('<input type="text" name="nameserver1" />');
|
||||
$elem.val(<?php echo "'".$defaults['primaryns']."'"; ?>);
|
||||
var ns_form = '<?php foreach($defaults['ns'] as $ns) echo '<input type="text" name="nameserver[]" value="'.$ns.'" /><br />'; ?>';
|
||||
var $elem = $('<div id="nameservers">' + ns_form + '</div>');
|
||||
$template.change(function() {
|
||||
$.get('zones.php?action=gettemplatenameservers&template='+$template.val()+'&prisec=pri', function(getdata) {
|
||||
$.get('zones.php?action=getformnameservers&template='+$template.val(), function(getdata) {
|
||||
if (getdata != "") {
|
||||
$elem.val(getdata);
|
||||
$elem.attr('readonly', true);
|
||||
$("#nameservers").html(getdata);
|
||||
} else {
|
||||
$elem.val(<?php echo "'".$defaults['primaryns']."'"; ?>);
|
||||
$elem.attr('readonly', false);
|
||||
$("#nameservers").html(ns_form);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -477,30 +475,6 @@ $(document).ready(function () {
|
|||
},
|
||||
inputClass: 'nameserver nameserver1'
|
||||
},
|
||||
nameserver2: {
|
||||
title: 'Sec. Nameserver',
|
||||
create: true,
|
||||
list: false,
|
||||
edit: false,
|
||||
input: function(data) {
|
||||
var $template = data.form.find('#Edit-template');
|
||||
var $elem = $('<input type="text" name="nameserver2" />');
|
||||
$elem.val(<?php echo "'".$defaults['secondaryns']."'"; ?>);
|
||||
$template.change(function() {
|
||||
$.get('zones.php?action=gettemplatenameservers&template='+$template.val()+'&prisec=sec', function(getdata) {
|
||||
if (getdata != "") {
|
||||
$elem.val(getdata);
|
||||
$elem.attr('readonly', true);
|
||||
} else {
|
||||
$elem.val(<?php echo "'".$defaults['secondaryns']."'"; ?>);
|
||||
$elem.attr('readonly', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
return $elem;
|
||||
},
|
||||
inputClass: 'nameserver nameserver2'
|
||||
},
|
||||
serial: {
|
||||
title: 'Serial',
|
||||
width: '10%',
|
||||
|
@ -679,22 +653,18 @@ $(document).ready(function () {
|
|||
defaultValue: 1,
|
||||
inputClass: 'overwrite_namerserver'
|
||||
},
|
||||
nameserver1: {
|
||||
title: 'Pri. Nameserver',
|
||||
nameserver: {
|
||||
title: 'Nameservers',
|
||||
create: true,
|
||||
list: false,
|
||||
edit: false,
|
||||
defaultValue: '<?php echo $defaults['primaryns']; ?>',
|
||||
input: function(data) {
|
||||
var ns_form = '<?php foreach($defaults['ns'] as $ns) echo '<input type="text" name="nameserver[]" value="'.$ns.'" /><br />'; ?>';
|
||||
var $elem = $('<div id="nameservers">' + ns_form + '</div>');
|
||||
return $elem;
|
||||
},
|
||||
inputClass: 'nameserver nameserver1'
|
||||
},
|
||||
nameserver2: {
|
||||
title: 'Sec. Nameserver',
|
||||
create: true,
|
||||
list: false,
|
||||
edit: false,
|
||||
defaultValue: '<?php echo $defaults['secondaryns']; ?>',
|
||||
inputClass: 'nameserver nameserver2'
|
||||
},
|
||||
},
|
||||
recordAdded: function() {
|
||||
$("#MasterZones").jtable('load');
|
||||
|
|
21
zones.php
21
zones.php
|
@ -452,11 +452,10 @@ case "create":
|
|||
);
|
||||
|
||||
$nameservers = array();
|
||||
if (isset($_POST['nameserver1']) && $_POST['nameserver1'] != null) {
|
||||
array_push($nameservers, $_POST['nameserver1']);
|
||||
}
|
||||
if (isset($_POST['nameserver2']) && $_POST['nameserver2'] != null) {
|
||||
array_push($nameservers, $_POST['nameserver2']);
|
||||
foreach($_POST['nameserver'] as $ns) {
|
||||
if (isset($ns) && !empty($ns)) {
|
||||
array_push($nameservers, $ns);
|
||||
}
|
||||
}
|
||||
|
||||
if ($zonekind != "Slave") {
|
||||
|
@ -655,6 +654,18 @@ case "gettemplatenameservers":
|
|||
echo "";
|
||||
}
|
||||
break;
|
||||
case "getformnameservers":
|
||||
$inputs = array();
|
||||
foreach (user_template_list() as $template) {
|
||||
if ($template['name'] !== $_GET['template']) continue;
|
||||
foreach ($template['records'] as $record) {
|
||||
if ($record['type'] == "NS" and array_search($record['content'], $inputs) === false) {
|
||||
array_push($inputs, $record['content']);
|
||||
echo '<input type="text" name="nameserver[]" value="'.$record['content'].'" readonly /><br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
jtable_respond(null, 'error', 'No such action');
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue