From dbdfea2ae1c02564ee1cef1e93cfcd975ca41d4c Mon Sep 17 00:00:00 2001 From: Richard Underwood Date: Mon, 13 Nov 2017 11:59:53 +0000 Subject: [PATCH] Create sqlite zone entries for zones created outside of nsedit. Note that this will create users if they don't exist also. --- zones.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zones.php b/zones.php index 40b57d9..deb16ca 100644 --- a/zones.php +++ b/zones.php @@ -97,7 +97,7 @@ function record_compare_content($a, $b) { return 0; } -function add_db_zone($zonename, $accountname) { +function add_db_zone($zonename, $accountname, $createuser = false) { if (valid_user($accountname) === false) { jtable_respond(null, 'error', "$accountname is not a valid username"); } @@ -105,7 +105,7 @@ function add_db_zone($zonename, $accountname) { jtable_respond(null, 'error', "$zonename is not a valid zonename"); } - if (is_apiuser() && !user_exists($accountname)) { + if ((is_apiuser() || $createuser) && !user_exists($accountname)) { add_user($accountname); } @@ -174,6 +174,10 @@ case "listslaves": $zone->setAccount(get_zone_account($zone->name, 'admin')); } + if(is_null(get_zone_id($zone->name))) { + add_db_zone($zone->name, $zone->account, true); + } + if (!check_permissions($zone->id,PERM_VIEW)) continue;