diff --git a/index.php b/index.php
index e28f6f2..edef63c 100644
--- a/index.php
+++ b/index.php
@@ -116,6 +116,7 @@ if (isset($templatelist)) {
@@ -193,7 +194,7 @@ $(document).ready(function () {
display: function (zone) {
var $img = $('

');
$img.click(function () {
- $('#MasterZones').jtable('openChildTable',
+ $('#SlaveZones').jtable('openChildTable',
$img.closest('tr'), {
title: 'Records in ' + zone.record.name,
openChildAsAccordion: true,
@@ -237,6 +238,18 @@ $(document).ready(function () {
addNewRecord: 'Add new zone',
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,
openChildAsAccordion: true,
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({
onClear: function() { $('#MasterZones').jtable('load'); }
});
@@ -493,6 +567,7 @@ $(document).ready(function () {
}
});
$('#Users').jtable('load');
+ $('#ImportZone').jtable('load');
} ?>
});
diff --git a/zones.php b/zones.php
index cd500cc..4b561af 100644
--- a/zones.php
+++ b/zones.php
@@ -241,7 +241,12 @@ if ($action == "list" or $action== "listslaves") {
}
$vars['name'] = $_POST['name'];
$vars['kind'] = $_POST['kind'];
- $vars['nameservers'] = $nameservers;
+ if (isset($_POST['zone'])) {
+ $vars['zone'] = $_POST['zone'];
+ $vars['nameservers'] = array();
+ } else {
+ $vars['nameservers'] = $nameservers;
+ }
_do_curl('/servers/:serverid:/zones', $vars);
if (isset($_POST['owner']) and $_POST['owner'] != 'admin') {
add_db_zone($vars['name'], $_POST['owner']);
@@ -264,9 +269,31 @@ if ($action == "list" or $action== "listslaves") {
}
}
}
- $vars = $_POST;
- $vars['serial'] = 0;
- $vars['records'] = array();
+
+ if (!isset($_POST['zone'])) {
+ $vars = $_POST;
+ $vars['serial'] = 0;
+ $vars['records'] = array();
+ 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 {
jtable_respond(null, 'error', "Not enough data: ".print_r($_POST, 1));
@@ -286,8 +313,6 @@ if ($action == "list" or $action== "listslaves") {
else {
array_push($any, $rows['records'][$idx]);
};
-
-
}
usort($any, "zonesort");
$ret = array_merge($soa, $ns, $mx, $any);