Create option to not allow a normal user to add zones

This commit is contained in:
Mark Schouten 2014-10-01 09:46:44 +02:00
parent 4881858d68
commit 00c40c047e
3 changed files with 15 additions and 6 deletions

View file

@ -1,15 +1,15 @@
<?php <?php
$apiuser = ''; # The PowerDNS API username $apiuser = ''; # The PowerDNS API username
$apipass = ''; # The PowerDNS API-user password $apipass = ''; # The PowerDNS API-user password
$apiip = ''; # The IP of the PowerDNS API $apiip = ''; # The IP of the PowerDNS API
$apiport = '8081'; # The port of the PowerDNS API $apiport = '8081'; # The port of the PowerDNS API
$apisid = ''; # PowerDNS's :server_id $apisid = ''; # PowerDNS's :server_id
$allowzoneadd = FALSE; # Allow normal users to add zones
# If you configure this, nsedit will try to authenticate via WeFact too. # If you configure this, nsedit will try to authenticate via WeFact too.
# Debtors will be added to the sqlitedatabase with their crypted password. # Debtors will be added to the sqlitedatabase with their crypted password.
#$wefactapiurl = 'https://yourdomain/Pro/apiv2/api.php'; #$wefactapiurl = 'https://yourdomain/Pro/apiv2/api.php';
#$wefactapikey = 'xyz'; #$wefactapikey = 'xyz';

View file

@ -109,7 +109,9 @@ if (isset($templatelist)) {
</ul> </ul>
</div> </div>
<div id="zones"> <div id="zones">
<? if (is_adminuser() or $allowzoneadd === TRUE) { ?>
<div style="visibility: hidden;" id="ImportZone"></div> <div style="visibility: hidden;" id="ImportZone"></div>
<? } ?>
<div class="tables" id="MasterZones"> <div class="tables" id="MasterZones">
<div class="searchbar" id="searchbar"> <div class="searchbar" id="searchbar">
<input type="text" id="domsearch" name="domsearch" placeholder="Search...."/> <input type="text" id="domsearch" name="domsearch" placeholder="Search...."/>
@ -153,8 +155,10 @@ $(document).ready(function () {
openChildAsAccordion: true, openChildAsAccordion: true,
actions: { actions: {
listAction: 'zones.php?action=listslaves', listAction: 'zones.php?action=listslaves',
<? if (is_adminuser() or $allowzoneadd === TRUE) { ?>
createAction: 'zones.php?action=create', createAction: 'zones.php?action=create',
deleteAction: 'zones.php?action=delete' deleteAction: 'zones.php?action=delete'
<? } ?>
}, },
fields: { fields: {
id: { id: {
@ -253,8 +257,10 @@ $(document).ready(function () {
openChildAsAccordion: true, openChildAsAccordion: true,
actions: { actions: {
listAction: 'zones.php?action=list', listAction: 'zones.php?action=list',
<? if (is_adminuser() or $allowzoneadd === TRUE) { ?>
createAction: 'zones.php?action=create', createAction: 'zones.php?action=create',
deleteAction: 'zones.php?action=delete', deleteAction: 'zones.php?action=delete',
<? } ?>
<? if (is_adminuser()) { ?> <? if (is_adminuser()) { ?>
updateAction: 'zones.php?action=update' updateAction: 'zones.php?action=update'
<? } ?> <? } ?>

View file

@ -227,6 +227,9 @@ if ($action == "list" or $action== "listslaves") {
usort($return, "zonesort"); usort($return, "zonesort");
jtable_respond($return); jtable_respond($return);
} elseif ($action == "create") { } elseif ($action == "create") {
if (is_adminuser() !== TRUE or ($allowzoneadd !== TRUE)) {
jtable_respond(null, 'error', "You are not allowed to add zones");
}
if (_valid_label($_POST['name']) === FALSE) { if (_valid_label($_POST['name']) === FALSE) {
jtable_respond(null, 'error', "Please only use [a-z0-9_/.-]"); jtable_respond(null, 'error', "Please only use [a-z0-9_/.-]");
} }