From ad955792a8ade5c0015aa3d68f86b1035c1acc31 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 22 Jan 2014 11:30:52 -0500
Subject: [PATCH] Fixed bug from previous commit

---
 server/scripts/ispconfig_update.php |   99 ++++++++++++++++++++++++++++---------------------
 1 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/server/scripts/ispconfig_update.php b/server/scripts/ispconfig_update.php
index bd9b2aa..6843e7b 100644
--- a/server/scripts/ispconfig_update.php
+++ b/server/scripts/ispconfig_update.php
@@ -28,67 +28,82 @@
 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-function simple_query($query, $answers, $default)
-{		
-		$finished = false;
-		do {
-			$answers_str = implode(',', $answers);
-			swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
-			$input = sread();
-			
-			//* Stop the installation
-			if($input == 'quit') {
-				swriteln($this->lng("Installation terminated by user.\n"));
-				die();
-			}
-			
-			//* Select the default
-			if($input == '') {
-				$answer = $default;
-				$finished = true;
-			}
-			
-            //* Set answer id valid
-			if(in_array($input, $answers)) {
-				$answer = $input;
-				$finished = true;
-			}
-			
-		} while ($finished == false);
-		swriteln();
-		return $answer;
+function sread() {
+	$input = fgets(STDIN);
+	return rtrim($input);
 }
 
-require_once('/usr/local/ispconfig/server/lib/config.inc.php');
+function swrite($text = '') {
+	echo $text;
+}
+
+function swriteln($text = '') {
+	echo $text."\n";
+}
+
+function simple_query($query, $answers, $default)
+{
+	$finished = false;
+	do {
+		$answers_str = implode(',', $answers);
+		swrite($query.' ('.$answers_str.') ['.$default.']: ');
+		$input = sread();
+
+		//* Stop the installation
+		if($input == 'quit') {
+			swriteln("Installation terminated by user.\n");
+			die();
+		}
+
+		//* Select the default
+		if($input == '') {
+			$answer = $default;
+			$finished = true;
+		}
+
+		//* Set answer id valid
+		if(in_array($input, $answers)) {
+			$answer = $input;
+			$finished = true;
+		}
+
+	} while ($finished == false);
+	swriteln();
+	return $answer;
+}
+
+require_once '/usr/local/ispconfig/server/lib/config.inc.php';
 
 
-echo "\n\n".str_repeat('-',80)."\n";
-echo " _____ ___________   _____              __ _       
-|_   _/  ___| ___ \ /  __ \            / _(_)      
-  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _ 
+echo "\n\n".str_repeat('-', 80)."\n";
+echo " _____ ___________   _____              __ _
+|_   _/  ___| ___ \ /  __ \            / _(_)
+  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _
   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |
  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| |
  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, |
                                               __/ |
                                              |___/ ";
-echo "\n".str_repeat('-',80)."\n";
+echo "\n".str_repeat('-', 80)."\n";
 echo "\n\n>> Update  \n\n";
-echo "Please choose the update method. For production systems select 'stable'. \nThe update from svn is only for development systems and may break your current setup.\n\n";
+echo "Please choose the update method. For production systems select 'stable'. \nThe update from svn is only for development systems and may break your current setup.\nNote: Update all slave server, before you update master server.\n\n";
 
-$method = $inst->simple_query('Select update method', array('stable','svn'), 'stable');
+$method = simple_query('Select update method', array('stable', 'svn'), 'stable');
 
 if($method == 'stable') {
-	$new_version = file_get_contents('http://www.ispconfig.org/downloads/ispconfig3_version.txt') or die('Unable to retrieve version file.');
+	$new_version = @file_get_contents('http://www.ispconfig.org/downloads/ispconfig3_version.txt') or die('Unable to retrieve version file.');
 	$new_version = trim($new_version);
 	if($new_version != ISPC_APP_VERSION) {
-		exec('/usr/local/ispconfig/server/scripts/update_from_tgz.sh')
+		passthru('/usr/local/ispconfig/server/scripts/update_from_tgz.sh');
+		exit;
 	} else {
-		echo "There are no updates available.\n";
+		echo "There are no updates available for ISPConfig ".ISPC_APP_VERSION."\n";
 	}
 } else {
-	exec('/usr/local/ispconfig/server/scripts/update_from_svn.sh');
+	passthru('/usr/local/ispconfig/server/scripts/update_from_svn.sh');
+	exit;
 }
 
 
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1