From b77400a961f82a57c634a794f94ae459bafcc1b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?A=2E=20T=C3=A4ffner?= <darkalex@firesplash.de>
Date: Thu, 1 Sep 2016 15:39:33 +0200
Subject: [PATCH] updater: db-query working, requests working. This will be my
 MR and hopefully fixes ispconfig/ispconfig3#4163 and hopefully also fixes
 ispconfig/ispconfig3#4050

---
 install/lib/update.lib.php | 17 ++++-------------
 install/update.php         |  4 +++-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index d785caf2c5..a4df4d8328 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -425,22 +425,13 @@ function setDefaultServers(){
  *	@param $detected_value boolean The result of service detection
  */
 function check_service_config_state($servicename, $detected_value) {
-	global $current_svc_config, $inst;
+	global $current_svc_config, $inst, $conf;
 	
-	if ($current_svc_config[$servicename] == 1) $current_state = true;
-	else $current_state = false;
+	if ($current_svc_config[$servicename] == 1) $current_state = 1;
+	else $current_state = 0;
 	
 	if ($detected_value != $current_state) {
-		if ($detected_value) {
-			$svcdetect_state1 = 'has been';
-			$svcdetect_state2 = 'configure';
-			$svcdetect_defaultanswer = 'no';
-		} else {
-			$svcdetect_state1 = 'has not been';
-			$svcdetect_state2 = '(strongly recommended) disable';
-			$svcdetect_defaultanswer = 'yes';
-		}
-		if ($inst->simple_query('Service \''.$servicename.'\' '.$svcdetect_state1.' detected do you want to '.$svcdetect_state2.' it? ', array('yes', 'no'), $svcdetect_defaultanswer, 'svc_detect_change_'.$servicename) == 'yes') return $detected_value;
+		if ($inst->simple_query('Service \''.$servicename.'\' '.($detected_value ? 'has been' : 'has not been').' detected ('.($current_state ? 'strongly recommended, currently enabled' : 'currently disabled').') do you want to '.($detected_value ? 'enable and configure' : 'disable').' it? ', array('yes', 'no'), ($current_state ? 'yes' : 'no'), 'svc_detect_change_'.$servicename) == 'yes') return $detected_value;
 		else return $current_state;
 	} else return $current_state;
 }
diff --git a/install/update.php b/install/update.php
index 49953c35d7..466f9faac7 100644
--- a/install/update.php
+++ b/install/update.php
@@ -305,7 +305,8 @@ if($reconfigure_master_database_rights_answer == 'yes') {
 $inst->find_installed_apps();
 
 //** Check for current service config state and compare to our results
-$current_svc_config = $inst->dbmaster->queryOneRecord("SELECT * FROM `server` WHERE server_id=?", $conf['server_id']);
+if ($conf['mysql']['master_slave_setup'] == 'y') $current_svc_config = $inst->dbmaster->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf['mysql']['master_database'] . '.server', $conf['server_id']);
+else $current_svc_config = $inst->db->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf["mysql"]["database"] . '.server', $conf['server_id']);
 $conf['postfix']['installed'] = check_service_config_state('mail_server', $conf['postfix']['installed']);
 $conf['services']['dns'] = check_service_config_state('dns_server', ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']));
 $conf['services']['web'] = check_service_config_state('web_server', ($conf['apache']['installed'] || $conf['nginx']['installed']));
@@ -314,6 +315,7 @@ $conf['services']['firewall'] = check_service_config_state('firewall_server', ($
 $conf['services']['vserver'] = check_service_config_state('vserver_server', $conf['services']['vserver']);
 //** vv is this intended??? If you want to check adapt the lines above... vv
 $conf['services']['db'] = true;
+unset($current_svc_config);
 
 
 //** Shall the services be reconfigured during update
-- 
GitLab