- added dynamic NS-entry config parameter and field generation

- added protocol config-parameter
This commit is contained in:
bfbones 2015-02-26 00:23:46 +01:00
parent 20eb8afa2b
commit daa4de4d2b
3 changed files with 23 additions and 23 deletions

View file

@ -6,6 +6,7 @@ $apiip = ''; # The IP of the PowerDNS API
$apiport = '8081'; # The port of the PowerDNS API $apiport = '8081'; # The port of the PowerDNS API
$apisid = 'localhost'; # PowerDNS's :server_id $apisid = 'localhost'; # PowerDNS's :server_id
$allowzoneadd = FALSE; # Allow normal users to add zones $allowzoneadd = FALSE; # Allow normal users to add zones
$apiprotocol = 'http://'; # protocol used to connect with trailing slashs
### AUTHENTICATION ### ### AUTHENTICATION ###
# The first versions of the PowerDNS API used the standard webserver password # The first versions of the PowerDNS API used the standard webserver password
@ -48,7 +49,7 @@ $templates[] = array(
$defaults['soa_edit'] = 'INCEPTION-INCREMENT'; $defaults['soa_edit'] = 'INCEPTION-INCREMENT';
$defaults['soa_edit_api'] = 'INCEPTION-INCREMENT'; $defaults['soa_edit_api'] = 'INCEPTION-INCREMENT';
$defaults['defaulttype'] = 'Master'; # Choose between 'Native' or 'Master' $defaults['defaulttype'] = 'Master'; # Choose between 'Native' or 'Master'
$defaults['primaryns'] = 'unconfigured.primaryns'; # The value of the first NS-record $defaults['ns'][0] = 'unconfigured.primaryns'; # The value of the first NS-record
$defaults['secondaryns'] = 'unconfigured.secondaryns'; # The value of the second NS-record $defaults['ns'][1] = 'unconfigured.secondaryns'; # The value of the second NS-record
$defaults['ttl'] = 3600; # Default TTL for records $defaults['ttl'] = 3600; # Default TTL for records
$defaults['priority'] = 0; # Default for priority in records $defaults['priority'] = 0; # Default for priority in records

View file

@ -443,22 +443,20 @@ $(document).ready(function () {
edit: false, edit: false,
inputClass: 'template' inputClass: 'template'
}, },
nameserver1: { <?php
title: 'Pri. Nameserver', $i = 1;
foreach($defaults['ns'] as $ns) {
echo "nameserver".$i.": {
title: '".($i == 1 ? 'Pri.' : 'Sec.')." Nameserver',
create: true, create: true,
list: false, list: false,
edit: false, edit: false,
defaultValue: '<?php echo $defaults['primaryns']; ?>', defaultValue: '".$ns."',
inputClass: 'nameserver nameserver1' inputClass: 'nameserver nameserver".$i."'
}, },\n\t\t\t";
nameserver2: { $i++;
title: 'Sec. Nameserver', }
create: true, ?>
list: false,
edit: false,
defaultValue: '<?php echo $defaults['secondaryns']; ?>',
inputClass: 'nameserver nameserver2'
},
serial: { serial: {
title: 'Serial', title: 'Serial',
width: '10%', width: '10%',

View file

@ -11,14 +11,14 @@ if (!is_csrf_safe()) {
} }
function api_request($path, $opts = null, $type = null) { function api_request($path, $opts = null, $type = null) {
global $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod; global $apisid, $apiuser, $apipass, $apiip, $apiport, $authmethod, $apiprotocol;
$url = "http://$apiip:$apiport${path}"; $url = $apiprotocol."$apiip:$apiport${path}";
if ($authmethod == "auto") { if ($authmethod == "auto") {
$ad = curl_init(); $ad = curl_init();
curl_setopt($ad, CURLOPT_HTTPHEADER, array('X-API-Key: '.$apipass)); curl_setopt($ad, CURLOPT_HTTPHEADER, array('X-API-Key: '.$apipass));
curl_setopt($ad, CURLOPT_URL, "http://$apiip:$apiport/servers/localhost/statistics"); curl_setopt($ad, CURLOPT_URL, $apiprotocol."$apiip:$apiport/servers/localhost/statistics");
curl_setopt($ad, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ad, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ad); curl_exec($ad);
if (curl_getinfo($ad, CURLINFO_HTTP_CODE) == 401) { if (curl_getinfo($ad, CURLINFO_HTTP_CODE) == 401) {
@ -452,11 +452,12 @@ case "create":
); );
$nameservers = array(); $nameservers = array();
if (isset($_POST['nameserver1']) && $_POST['nameserver1'] != null) { $i = 1;
array_push($nameservers, $_POST['nameserver1']); while(isset($_POST['nameserver'.$i])) {
} if(!empty($_POST['nameserver'.$i])) {
if (isset($_POST['nameserver2']) && $_POST['nameserver2'] != null) { array_push($nameservers, $_POST['nameserver'.$i]);
array_push($nameservers, $_POST['nameserver2']); }
$i++;
} }
if ($zonekind != "Slave") { if ($zonekind != "Slave") {