From 3fc28c0142bf8ab4e2cfae44931e2a51aadc4d51 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Mon, 25 Feb 2013 13:51:37 -0500
Subject: [PATCH] - Added: remoting queries with a lot of results (e.g. email addresses or alias domains or dns rr) lead to non-functioning soap requests   - added '#OFFSET#' AND '#LIMIT#' handling to the query   - added automatic 'WHERE 1' if an empty array was given as query   example: $result = $api->sites_web_domain_get('type' => 'vhost', '#OFFSET#' => 25, '#LIMIT#' => 50); to get the websites 26 to 75

---
 server/lib/classes/aps_installer.inc.php |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/server/lib/classes/aps_installer.inc.php b/server/lib/classes/aps_installer.inc.php
index f5b661c..5951698 100644
--- a/server/lib/classes/aps_installer.inc.php
+++ b/server/lib/classes/aps_installer.inc.php
@@ -294,7 +294,8 @@
         $db_id = parent::getXPathValue($sxe, '//db:id');
         if(empty($db_id)) return; // No database needed
         
-		/*
+		/* WARNING: if this will ever be uncommented please check the updated prefix handling for user and db names!!!
+         * 
         // Set the database owner to the domain owner
         // ISPConfig identifies the owner by the sys_groupid (not sys_userid!)
         // so sys_userid can be set to any value
@@ -396,8 +397,28 @@
 
             // Now delete an existing folder (affects install and removal in the same way)
             @chdir($this->local_installpath);
-            if(file_exists($this->local_installpath)) exec("rm -Rf ".escapeshellarg($this->local_installpath).'*');
-            else mkdir($this->local_installpath, 0777, true);
+            if(file_exists($this->local_installpath)){
+				// make sure we don't delete error and stats folders
+				if($this->local_installpath == $this->document_root.'/'){
+					if(is_dir($this->document_root)){
+						$files = array_diff(scandir($this->document_root), array('.','..','error','stats'));
+						foreach($files as $file){
+							if(is_dir($this->document_root.'/'.$file)){
+								$app->file->removeDirectory($this->document_root.'/'.$file);
+							} else {
+								@unlink($this->document_root.'/'.$file);
+							}
+						}
+					} else {
+						@unlink($this->document_root);
+						mkdir($this->document_root, 0777, true);
+					}
+				} else {
+					exec("rm -Rf ".escapeshellarg($this->local_installpath).'*');
+				}
+			} else {
+				mkdir($this->local_installpath, 0777, true);
+			}
 
             if($this->handle_type == 'install')
             {            
@@ -613,7 +634,7 @@
         if(!isset($task['instance_id'])) $task['instance_id'] = $instanceid;
 		
 		// Download aps package
-		if(!file_exists($this->packages_dir.'/'.$task['path'])) {
+		if(!file_exists($this->packages_dir.'/'.$task['path']) || filesize($this->packages_dir.'/'.$task['path']) == 0) {
 			$ch = curl_init();
 			$fh = fopen($this->packages_dir.'/'.$task['path'], 'wb');
 			curl_setopt($ch, CURLOPT_FILE, $fh); 

--
Gitblit v1.9.1