mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-20 20:13:40 +03:00
Implement zone-import in NSedit
This commit is contained in:
parent
1772629c75
commit
6f16859a8e
2 changed files with 107 additions and 7 deletions
77
index.php
77
index.php
|
@ -116,6 +116,7 @@ if (isset($templatelist)) {
|
||||||
</div>
|
</div>
|
||||||
<div class="tables" id="SlaveZones"></div>
|
<div class="tables" id="SlaveZones"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="visibility: hidden;" id="ImportZone"></div>
|
||||||
<? if (is_adminuser()) { ?>
|
<? if (is_adminuser()) { ?>
|
||||||
<div id="users">
|
<div id="users">
|
||||||
<div class="tables" id="Users"></div>
|
<div class="tables" id="Users"></div>
|
||||||
|
@ -193,7 +194,7 @@ $(document).ready(function () {
|
||||||
display: function (zone) {
|
display: function (zone) {
|
||||||
var $img = $('<img class="list" src="img/list.png" title="Records" />');
|
var $img = $('<img class="list" src="img/list.png" title="Records" />');
|
||||||
$img.click(function () {
|
$img.click(function () {
|
||||||
$('#MasterZones').jtable('openChildTable',
|
$('#SlaveZones').jtable('openChildTable',
|
||||||
$img.closest('tr'), {
|
$img.closest('tr'), {
|
||||||
title: 'Records in ' + zone.record.name,
|
title: 'Records in ' + zone.record.name,
|
||||||
openChildAsAccordion: true,
|
openChildAsAccordion: true,
|
||||||
|
@ -237,6 +238,18 @@ $(document).ready(function () {
|
||||||
addNewRecord: 'Add new zone',
|
addNewRecord: 'Add new zone',
|
||||||
noDataAvailable: 'No zones found'
|
noDataAvailable: 'No zones found'
|
||||||
},
|
},
|
||||||
|
toolbar: {
|
||||||
|
hoverAnimation: true,
|
||||||
|
hoverAnimationDuration: 60,
|
||||||
|
hoverAnimationEasing: undefined,
|
||||||
|
items: [{
|
||||||
|
icon: 'jtable/lib/themes/metro/add.png',
|
||||||
|
text: 'Import a new zone',
|
||||||
|
click: function() {
|
||||||
|
$('#ImportZone').jtable('showCreateForm');
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
},
|
||||||
sorting: false,
|
sorting: false,
|
||||||
openChildAsAccordion: true,
|
openChildAsAccordion: true,
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -427,6 +440,67 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('#ImportZone').jtable({
|
||||||
|
title: 'Import zone',
|
||||||
|
actions: {
|
||||||
|
createAction: 'zones.php?action=create',
|
||||||
|
listAction: 'zones.php?action=list',
|
||||||
|
},
|
||||||
|
fields: {
|
||||||
|
id: {
|
||||||
|
key: true,
|
||||||
|
type: 'hidden'
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
title: 'Domain'
|
||||||
|
},
|
||||||
|
<? if (is_adminuser()) { ?>
|
||||||
|
owner: {
|
||||||
|
title: 'Owner',
|
||||||
|
options: function(data) {
|
||||||
|
data.clearCache();
|
||||||
|
return 'users.php?action=listoptions';
|
||||||
|
},
|
||||||
|
defaultValue: 'admin'
|
||||||
|
},
|
||||||
|
<? } ?>
|
||||||
|
kind: {
|
||||||
|
title: 'Type',
|
||||||
|
options: {'Native': 'Native', 'Master': 'Master'},
|
||||||
|
defaultValue: '<? echo $defaults['defaulttype']; ?>',
|
||||||
|
edit: false
|
||||||
|
},
|
||||||
|
zone: {
|
||||||
|
title: 'Zonedata',
|
||||||
|
type: 'textarea'
|
||||||
|
},
|
||||||
|
owns: {
|
||||||
|
title: 'Overwrite Nameservers',
|
||||||
|
type: 'checkbox',
|
||||||
|
values: {'0': 'No', '1': 'Yes'},
|
||||||
|
defaultValue: 1
|
||||||
|
},
|
||||||
|
nameserver1: {
|
||||||
|
title: 'Pri. Nameserver',
|
||||||
|
create: true,
|
||||||
|
list: false,
|
||||||
|
edit: false,
|
||||||
|
defaultValue: '<? echo $defaults['primaryns']; ?>'
|
||||||
|
},
|
||||||
|
nameserver2: {
|
||||||
|
title: 'Sec. Nameserver',
|
||||||
|
create: true,
|
||||||
|
list: false,
|
||||||
|
edit: false,
|
||||||
|
defaultValue: '<? echo $defaults['secondaryns']; ?>'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
recordAdded: function() {
|
||||||
|
$("#MasterZones").jtable('load');
|
||||||
|
$("#SlaveZones").jtable('load');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
$('#domsearch').addClear({
|
$('#domsearch').addClear({
|
||||||
onClear: function() { $('#MasterZones').jtable('load'); }
|
onClear: function() { $('#MasterZones').jtable('load'); }
|
||||||
});
|
});
|
||||||
|
@ -493,6 +567,7 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#Users').jtable('load');
|
$('#Users').jtable('load');
|
||||||
|
$('#ImportZone').jtable('load');
|
||||||
<? } ?>
|
<? } ?>
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
29
zones.php
29
zones.php
|
@ -241,7 +241,12 @@ if ($action == "list" or $action== "listslaves") {
|
||||||
}
|
}
|
||||||
$vars['name'] = $_POST['name'];
|
$vars['name'] = $_POST['name'];
|
||||||
$vars['kind'] = $_POST['kind'];
|
$vars['kind'] = $_POST['kind'];
|
||||||
|
if (isset($_POST['zone'])) {
|
||||||
|
$vars['zone'] = $_POST['zone'];
|
||||||
|
$vars['nameservers'] = array();
|
||||||
|
} else {
|
||||||
$vars['nameservers'] = $nameservers;
|
$vars['nameservers'] = $nameservers;
|
||||||
|
}
|
||||||
_do_curl('/servers/:serverid:/zones', $vars);
|
_do_curl('/servers/:serverid:/zones', $vars);
|
||||||
if (isset($_POST['owner']) and $_POST['owner'] != 'admin') {
|
if (isset($_POST['owner']) and $_POST['owner'] != 'admin') {
|
||||||
add_db_zone($vars['name'], $_POST['owner']);
|
add_db_zone($vars['name'], $_POST['owner']);
|
||||||
|
@ -264,10 +269,32 @@ if ($action == "list" or $action== "listslaves") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($_POST['zone'])) {
|
||||||
$vars = $_POST;
|
$vars = $_POST;
|
||||||
$vars['serial'] = 0;
|
$vars['serial'] = 0;
|
||||||
$vars['records'] = array();
|
$vars['records'] = array();
|
||||||
jtable_respond($vars, 'single');
|
jtable_respond($vars, 'single');
|
||||||
|
}
|
||||||
|
$zoneurl = '/servers/:serverid:/zones/'.$vars['name'].'.';
|
||||||
|
if (isset($_POST['owns'])) {
|
||||||
|
$patch = array();
|
||||||
|
$patch['rrsets'] = array();
|
||||||
|
array_push($patch['rrsets'], array(
|
||||||
|
'comments' => array(),
|
||||||
|
'records' => array(),
|
||||||
|
'changetype'=> "REPLACE",
|
||||||
|
'type' => 'NS',
|
||||||
|
'name' => $vars['name']));
|
||||||
|
_do_curl($zoneurl, $patch, 'patch');
|
||||||
|
foreach ($nameservers as $ns) {
|
||||||
|
$records = getrecords_by_name_type($zoneurl, $vars['name'], 'NS');
|
||||||
|
$records = _create_record($vars['name'], $records, array('type' => 'NS', 'name' => '', 'content' => $ns), $zoneurl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$vars = _do_curl($zoneurl);
|
||||||
|
jtable_respond($vars, 'single');
|
||||||
} else {
|
} else {
|
||||||
jtable_respond(null, 'error', "Not enough data: ".print_r($_POST, 1));
|
jtable_respond(null, 'error', "Not enough data: ".print_r($_POST, 1));
|
||||||
}
|
}
|
||||||
|
@ -286,8 +313,6 @@ if ($action == "list" or $action== "listslaves") {
|
||||||
else {
|
else {
|
||||||
array_push($any, $rows['records'][$idx]);
|
array_push($any, $rows['records'][$idx]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
usort($any, "zonesort");
|
usort($any, "zonesort");
|
||||||
$ret = array_merge($soa, $ns, $mx, $any);
|
$ret = array_merge($soa, $ns, $mx, $any);
|
||||||
|
|
Loading…
Add table
Reference in a new issue