From e631410a14d68c6c54242cf833c0de9c79bc09dd Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 21 Jul 2010 11:41:48 -0400
Subject: [PATCH] Fixed: FS#1220 - /var/vmail/(domain)/(user) directories and files not delete when mail_user is deleted via remote.

---
 server/mods-available/remoteaction_core_module.inc.php |   38 +++++++++++++++++++++++++++++++++-----
 1 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/server/mods-available/remoteaction_core_module.inc.php b/server/mods-available/remoteaction_core_module.inc.php
index 81aa277..e5e8868 100644
--- a/server/mods-available/remoteaction_core_module.inc.php
+++ b/server/mods-available/remoteaction_core_module.inc.php
@@ -142,24 +142,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