From d1b62a663dd5b11b192d9b78511a8d9cf294c11f Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Sat, 20 Aug 2016 14:37:37 +0200
Subject: [PATCH] use prior dns-zone if the new zone fails (# 4107)

---
 interface/web/dns/dns_soa_edit.php           |  9 +++++++++
 interface/web/dns/lib/lang/ar_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/bg_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/br_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/ca_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/cz_dns_soa.lng    |  4 +---
 interface/web/dns/lib/lang/de_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/dk_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/el_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/en_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/es_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/fi_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/fr_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/hr_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/hu_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/id_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/it_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/ja_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/nl_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/pl_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/pt_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/ro_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/ru_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/se_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/sk_dns_soa.lng    |  1 +
 interface/web/dns/lib/lang/tr_dns_soa.lng    |  1 +
 interface/web/dns/templates/dns_soa_edit.htm |  6 ++++++
 server/plugins-available/bind_plugin.inc.php | 17 +++++++++++++----
 28 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php
index 172a04140f..8997146bb6 100644
--- a/interface/web/dns/dns_soa_edit.php
+++ b/interface/web/dns/dns_soa_edit.php
@@ -215,6 +215,15 @@ class page_action extends tform_actions {
 		//* we are editing a existing record
 		$app->tpl->setVar("edit_disabled", 1);
 		$app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
+
+		$datalog = $app->db->queryOneRecord("SELECT sys_datalog.error, sys_log.tstamp FROM sys_datalog, sys_log WHERE sys_datalog.dbtable = 'dns_soa' AND sys_datalog.dbidx = ? AND sys_datalog.datalog_id = sys_log.datalog_id AND sys_log.message = CONCAT('Processed datalog_id ',sys_log.datalog_id) ORDER BY sys_datalog.tstamp DESC", 'id:' . $this->id);
+		if(is_array($datalog) && !empty($datalog)){
+			if(trim($datalog['error']) != ''){
+				$app->tpl->setVar("config_error_msg", nl2br(htmlentities($datalog['error'])));
+				$app->tpl->setVar("config_error_tstamp", date($app->lng('conf_format_datetime'), $datalog['tstamp']));
+			}
+		}
+
 	} else {
 		$app->tpl->setVar("edit_disabled", 0);
 	}
diff --git a/interface/web/dns/lib/lang/ar_dns_soa.lng b/interface/web/dns/lib/lang/ar_dns_soa.lng
index 572349d085..98b79d5861 100644
--- a/interface/web/dns/lib/lang/ar_dns_soa.lng
+++ b/interface/web/dns/lib/lang/ar_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/bg_dns_soa.lng b/interface/web/dns/lib/lang/bg_dns_soa.lng
index 0838d133bd..fa08521196 100644
--- a/interface/web/dns/lib/lang/bg_dns_soa.lng
+++ b/interface/web/dns/lib/lang/bg_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/br_dns_soa.lng b/interface/web/dns/lib/lang/br_dns_soa.lng
index 6149be5fe4..cf3bd7c6ae 100644
--- a/interface/web/dns/lib/lang/br_dns_soa.lng
+++ b/interface/web/dns/lib/lang/br_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/ca_dns_soa.lng b/interface/web/dns/lib/lang/ca_dns_soa.lng
index 277948a297..6ecc2762a3 100644
--- a/interface/web/dns/lib/lang/ca_dns_soa.lng
+++ b/interface/web/dns/lib/lang/ca_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/cz_dns_soa.lng b/interface/web/dns/lib/lang/cz_dns_soa.lng
index 39fc5a0c4f..af93a3e1b3 100644
--- a/interface/web/dns/lib/lang/cz_dns_soa.lng
+++ b/interface/web/dns/lib/lang/cz_dns_soa.lng
@@ -40,7 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Podepsat zónu (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
-
-
-
diff --git a/interface/web/dns/lib/lang/de_dns_soa.lng b/interface/web/dns/lib/lang/de_dns_soa.lng
index 76d825be05..719162e201 100644
--- a/interface/web/dns/lib/lang/de_dns_soa.lng
+++ b/interface/web/dns/lib/lang/de_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['ttl_range_error'] = 'Min. TTL ist 60 Sekunden.';
 $wb['xfer_error_regex'] = 'Zonentransfer: Verwenden Sie eine oder mehrere durch Komma getrennte IP Adressen oder das Wort: any.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/dk_dns_soa.lng b/interface/web/dns/lib/lang/dk_dns_soa.lng
index 78d8441900..193dc9f4a2 100644
--- a/interface/web/dns/lib/lang/dk_dns_soa.lng
+++ b/interface/web/dns/lib/lang/dk_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'The Zone (SOA) can not be changed. Please contact your administrator to change the zone.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/el_dns_soa.lng b/interface/web/dns/lib/lang/el_dns_soa.lng
index f5f008f089..773d25ab66 100644
--- a/interface/web/dns/lib/lang/el_dns_soa.lng
+++ b/interface/web/dns/lib/lang/el_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/en_dns_soa.lng b/interface/web/dns/lib/lang/en_dns_soa.lng
index 9dae178002..af1f3db565 100644
--- a/interface/web/dns/lib/lang/en_dns_soa.lng
+++ b/interface/web/dns/lib/lang/en_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
 $wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'The Zone (SOA) can not be changed. Please contact your administrator to change the zone.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/es_dns_soa.lng b/interface/web/dns/lib/lang/es_dns_soa.lng
index 2e1cf6dcfa..189f8f5adf 100755
--- a/interface/web/dns/lib/lang/es_dns_soa.lng
+++ b/interface/web/dns/lib/lang/es_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['ttl_txt'] = 'TTL';
 $wb['update_acl_txt'] = 'Actualizar ACL';
 $wb['xfer_error_regex'] = 'Notificar también a: Por favor, usa una dirección IP.';
 $wb['xfer_txt'] = 'Permitir transferencia de zonas a<br />estas IP (lista separada por comas)';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/fi_dns_soa.lng b/interface/web/dns/lib/lang/fi_dns_soa.lng
index 1c75c596f1..a33b593e91 100755
--- a/interface/web/dns/lib/lang/fi_dns_soa.lng
+++ b/interface/web/dns/lib/lang/fi_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/fr_dns_soa.lng b/interface/web/dns/lib/lang/fr_dns_soa.lng
index b7e302704d..c20afd3731 100644
--- a/interface/web/dns/lib/lang/fr_dns_soa.lng
+++ b/interface/web/dns/lib/lang/fr_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/hr_dns_soa.lng b/interface/web/dns/lib/lang/hr_dns_soa.lng
index 9c9e060bed..5789ace310 100644
--- a/interface/web/dns/lib/lang/hr_dns_soa.lng
+++ b/interface/web/dns/lib/lang/hr_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/hu_dns_soa.lng b/interface/web/dns/lib/lang/hu_dns_soa.lng
index 881d7622fc..8de33c83a4 100644
--- a/interface/web/dns/lib/lang/hu_dns_soa.lng
+++ b/interface/web/dns/lib/lang/hu_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/id_dns_soa.lng b/interface/web/dns/lib/lang/id_dns_soa.lng
index 7efedb9e13..d1eee1c5f8 100644
--- a/interface/web/dns/lib/lang/id_dns_soa.lng
+++ b/interface/web/dns/lib/lang/id_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/it_dns_soa.lng b/interface/web/dns/lib/lang/it_dns_soa.lng
index 2dda695f14..9fd7a5aa01 100644
--- a/interface/web/dns/lib/lang/it_dns_soa.lng
+++ b/interface/web/dns/lib/lang/it_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/ja_dns_soa.lng b/interface/web/dns/lib/lang/ja_dns_soa.lng
index 07a43b2d33..f03be582f6 100644
--- a/interface/web/dns/lib/lang/ja_dns_soa.lng
+++ b/interface/web/dns/lib/lang/ja_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/nl_dns_soa.lng b/interface/web/dns/lib/lang/nl_dns_soa.lng
index d9f0fc0d6c..1acf7bd456 100644
--- a/interface/web/dns/lib/lang/nl_dns_soa.lng
+++ b/interface/web/dns/lib/lang/nl_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/pl_dns_soa.lng b/interface/web/dns/lib/lang/pl_dns_soa.lng
index c5788160d6..dc2780f618 100644
--- a/interface/web/dns/lib/lang/pl_dns_soa.lng
+++ b/interface/web/dns/lib/lang/pl_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/pt_dns_soa.lng b/interface/web/dns/lib/lang/pt_dns_soa.lng
index f73fd86007..dd443444de 100644
--- a/interface/web/dns/lib/lang/pt_dns_soa.lng
+++ b/interface/web/dns/lib/lang/pt_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/ro_dns_soa.lng b/interface/web/dns/lib/lang/ro_dns_soa.lng
index c38dc3ba61..625281f268 100644
--- a/interface/web/dns/lib/lang/ro_dns_soa.lng
+++ b/interface/web/dns/lib/lang/ro_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/ru_dns_soa.lng b/interface/web/dns/lib/lang/ru_dns_soa.lng
index 5536cd8bb3..0a64dd60a0 100644
--- a/interface/web/dns/lib/lang/ru_dns_soa.lng
+++ b/interface/web/dns/lib/lang/ru_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/se_dns_soa.lng b/interface/web/dns/lib/lang/se_dns_soa.lng
index 2aa8af9721..944c9c38f3 100644
--- a/interface/web/dns/lib/lang/se_dns_soa.lng
+++ b/interface/web/dns/lib/lang/se_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/sk_dns_soa.lng b/interface/web/dns/lib/lang/sk_dns_soa.lng
index b0654a4320..176f001395 100644
--- a/interface/web/dns/lib/lang/sk_dns_soa.lng
+++ b/interface/web/dns/lib/lang/sk_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'Die Zone (SOA) kann nicht verändert werden. Bitte kontaktieren Sie ihren Administrator, um die Zone zu ändern.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/lib/lang/tr_dns_soa.lng b/interface/web/dns/lib/lang/tr_dns_soa.lng
index e80ece2ba0..b406e274c5 100644
--- a/interface/web/dns/lib/lang/tr_dns_soa.lng
+++ b/interface/web/dns/lib/lang/tr_dns_soa.lng
@@ -40,4 +40,5 @@ $wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
 $wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delievered in signed format afterwards.';
 $wb['error_not_allowed_server_id'] = 'The selected server is not allowed for this account.';
 $wb['soa_cannot_be_changed_txt'] = 'The Zone (SOA) can not be changed. Please contact your administrator to change the zone.';
+$wb['configuration_error_txt'] = 'CONFIGURATION ERROR';
 ?>
diff --git a/interface/web/dns/templates/dns_soa_edit.htm b/interface/web/dns/templates/dns_soa_edit.htm
index 157e2a03aa..87853d1ede 100644
--- a/interface/web/dns/templates/dns_soa_edit.htm
+++ b/interface/web/dns/templates/dns_soa_edit.htm
@@ -3,6 +3,12 @@
 </div>
 <p><tmpl_var name="list_desc_txt"></p>
 
+<tmpl_if name="config_error_msg">
+<div style="background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; margin: 1.5em 0 1.5em 0; padding: 7px;">
+	<p style="font-face:bold">{tmpl_var name='configuration_error_txt'}</p>
+	<div><div style="float:left;width:150px;">{tmpl_var name='config_error_tstamp'} :&nbsp;</div><div style="padding-left:150px;">{tmpl_var name='config_error_msg'}</div></div>
+</div>
+</tmpl_if>
 
         <legend>DNS Zone</legend>
             <tmpl_if name="is_admin">
diff --git a/server/plugins-available/bind_plugin.inc.php b/server/plugins-available/bind_plugin.inc.php
index 3b3179b143..4088882c1b 100644
--- a/server/plugins-available/bind_plugin.inc.php
+++ b/server/plugins-available/bind_plugin.inc.php
@@ -265,6 +265,7 @@ class bind_plugin {
 				$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.str_replace("/", "_", substr($zone['origin'], 0, -1)));
 			}
 
+			$old_zonefile = @file_get_contents($filename);
 			file_put_contents($filename, $tpl->grab());
 			chown($filename, escapeshellcmd($dns_config['bind_user']));
 			chgrp($filename, escapeshellcmd($dns_config['bind_group']));
@@ -275,12 +276,20 @@ class bind_plugin {
 			if($return_status === 0) {
 				$app->log("Writing BIND domain file: ".$filename, LOGLEVEL_DEBUG);
 			} else {
-				if($dns_config['disable_bind_log'] === 'y') {
-					$app->log("Writing BIND domain file failed: ".$filename." ".implode(' ', $out), LOGLEVEL_DEBUG);
+				$loglevel = @($dns_config['disable_bind_log'] === 'y')?:'LOGLEVEL_DEBUG':'LOGLEVEL_WARN';
+				$app->log("Writing BIND domain file failed: ".$filename." ".implode(' ', $out), $loglevel);
+				if(is_array($out) && !empty($out)){
+					$app->log('Reason for Bind restart failure: '.implode("\n", $out), $loglevel);
+					$app->dbmaster->datalogError(implode("\n", $out));
+				}
+				if ($old_zonefile != '') {
+					rename($filename, $filename.'.err');
+					file_put_contents($filename, $old_zonefile);
+					chown($filename, escapeshellcmd($dns_config['bind_user']));
+					chgrp($filename, escapeshellcmd($dns_config['bind_group']));
 				} else {
-					$app->log("Writing BIND domain file failed: ".$filename." ".implode(' ', $out), LOGLEVEL_WARN);
+					rename($filename, $filename.'.err');
 				}
-				rename($filename, $filename.'.err');
 			}
 			unset($tpl);
 			unset($records);
-- 
GitLab