From 813a79d6e734f1b46fec6b09c892d19aa1f8dcdc Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 22 Oct 2010 10:06:39 -0400
Subject: [PATCH] Fixed: FS#1382 - Doubling of ftp usernames while changing passwords only

---
 server/mods-available/remoteaction_core_module.inc.php |   68 ++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 19 deletions(-)

diff --git a/server/mods-available/remoteaction_core_module.inc.php b/server/mods-available/remoteaction_core_module.inc.php
index 81aa277..a613b83 100644
--- a/server/mods-available/remoteaction_core_module.inc.php
+++ b/server/mods-available/remoteaction_core_module.inc.php
@@ -110,20 +110,22 @@
 		/*
 		 * process all actions
 		*/
-		foreach ($actions as $action) {
-			if ($action['action_type'] == 'os_update') {
-				/* do the update */
-				$this->_doOsUpdate($action);
-				/* this action takes so much time,
-				  * we stop executing the actions not to waste more time */
-				return;
-			}
-			if ($action['action_type'] == 'ispc_update') {
-				/* do the update */
-				$this->_doIspCUpdate($action);
-				/* this action takes so much time,
-				  * we stop executing the actions not to waste more time */
-				return;
+		if(is_array($actions)) {
+			foreach ($actions as $action) {
+				if ($action['action_type'] == 'os_update') {
+					/* do the update */
+					$this->_doOsUpdate($action);
+					/* this action takes so much time,
+					* we stop executing the actions not to waste more time */
+					return;
+				}
+				if ($action['action_type'] == 'ispc_update') {
+					/* do the update */
+					$this->_doIspCUpdate($action);
+					/* this action takes so much time,
+					* we stop executing the actions not to waste more time */
+					return;
+				}
 			}
 		}
 	}
@@ -142,24 +144,52 @@
 	}
 
 	private function _doIspCUpdate($action) {
+		/*
+		 * Get the version-number of the newest version 
+		 */
 		$new_version = @file_get_contents('http://www.ispconfig.org/downloads/ispconfig3_version.txt');
 		$new_version = trim($new_version);
+
 		/*
 		 * Do the update
 		 */
-		exec("cd /tmp");
-		exec("wget http://www.ispconfig.org/downloads/ISPConfig-" . $new_version . ".tar.gz");
-		exec("tar xvfz ISPConfig-" . $new_version . ".tar.gz");
-		exec("cd ispconfig3_install/install");
 
+		/* jump into the temporary dir */
+		$oldDir = getcwd();
+		chdir("/tmp");
+
+		/* delete the old files (if there are any...) */
+		exec("rm /tmp/ISPConfig-" . $new_version . ".tar.gz");
+		exec("rm /tmp/ispconfig3_install -R");
+		
+		/* get the newest version */
+		exec("wget http://www.ispconfig.org/downloads/ISPConfig-" . $new_version . ".tar.gz");
+		
+		/* extract the files */
+		exec("tar xvfz ISPConfig-" . $new_version . ".tar.gz");
+
+		/*
+		 * Start the automated update
+		 */
+		chdir("/tmp/ispconfig3_install/install");
 		exec("touch autoupdate");
 		exec("php -q autoupdate.php");
+
+		/*
+		 * do some clean-up
+		 */
+		exec("rm /tmp/ISPConfig-" . $new_version . ".tar.gz");
+		exec("rm /tmp/ispconfig3_install -R");
+
+		/*
+		 * go back to the "old path"
+		 */
+		chdir($oldDir);
 
 		/*
 		 * All well done!
 		 */
 		$this->_actionDone($action['action_id'], 'ok');
 	}
-
 }
 ?>
\ No newline at end of file

--
Gitblit v1.9.1