From 7a38df483b6ea65ee2aa17fb25a8518d74d36f06 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Sun, 07 Apr 2013 16:08:02 -0400 Subject: [PATCH] SQL error in mail/mail_domain_del.php --- server/lib/classes/aps_installer.inc.php | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-) diff --git a/server/lib/classes/aps_installer.inc.php b/server/lib/classes/aps_installer.inc.php index 9bb8db4..6cb922f 100644 --- a/server/lib/classes/aps_installer.inc.php +++ b/server/lib/classes/aps_installer.inc.php @@ -397,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') { @@ -425,6 +445,11 @@ $this->file_owner_user = $owner_res['system_user']; $this->file_owner_group = $owner_res['system_group']; exec('chown -R '.$this->file_owner_user.':'.$this->file_owner_group.' '.escapeshellarg($this->local_installpath)); + + //* Chown stats directory back + if(is_dir($this->local_installpath.'stats')) { + exec('chown -R root:root '.escapeshellarg($this->local_installpath.'stats')); + } } } catch(Exception $e) @@ -558,6 +583,11 @@ { // The install succeeded, chown newly created files too exec('chown -R '.$this->file_owner_user.':'.$this->file_owner_group.' '.escapeshellarg($this->local_installpath)); + + //* Chown stats directory back + if(is_dir($this->local_installpath.'stats')) { + exec('chown -R root:root '.escapeshellarg($this->local_installpath.'stats')); + } $app->dbmaster->query('UPDATE aps_instances SET instance_status = "'.INSTANCE_SUCCESS.'" WHERE id = "'.$app->db->quote($task['instance_id']).'";'); @@ -614,7 +644,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