diff --git a/module/backup/control.php b/module/backup/control.php index 0983b9b572..c563babf83 100644 --- a/module/backup/control.php +++ b/module/backup/control.php @@ -105,12 +105,9 @@ class backup extends control } if(!$nosafe) $this->backup->addFileHeader($backFileName); - if((extension_loaded('zlib') or $nozip) and !$nofile) + if(!$nofile) { - $backFileName = "{$this->backupPath}{$fileName}.file"; - if(!$nozip) $backFileName .= '.zip'; - if(!$nozip and !$nosafe) $backFileName .= '.php'; $result = $this->backup->backFile($backFileName); if(!$result->result) @@ -125,11 +122,8 @@ class backup extends control printf($this->lang->backup->error->backupFile, $result->error); } } - if(!$nozip and !$nosafe) $this->backup->addFileHeader($backFileName); $backFileName = "{$this->backupPath}{$fileName}.code"; - if(!$nozip) $backFileName .= '.zip'; - if(!$nozip and !$nosafe) $backFileName .= '.php'; $result = $this->backup->backCode($backFileName); if(!$result->result) @@ -144,7 +138,6 @@ class backup extends control printf($this->lang->backup->error->backupCode, $result->error); } } - if(!$nozip and !$nosafe) $this->backup->addFileHeader($backFileName); } /* Delete expired backup. */ diff --git a/module/backup/model.php b/module/backup/model.php index f275209f1c..1ba7f9446e 100644 --- a/module/backup/model.php +++ b/module/backup/model.php @@ -37,27 +37,9 @@ class backupModel extends model $return->result = true; $return->error = ''; - $nozip = strpos($this->config->backup->setting, 'nozip') !== false; - if(!$nozip) - { - $oldDir = getcwd(); - chdir($this->app->getTmpRoot()); - $this->app->loadClass('pclzip', true); - $zip = new pclzip($backupFile); - $zip->create($this->app->getAppRoot() . 'www/data/', PCLZIP_OPT_REMOVE_PATH, $this->app->getAppRoot() . 'www/data/', PCLZIP_OPT_TEMP_FILE_ON); - if($zip->errorCode() != 0) - { - $return->result = false; - $return->error = $zip->errorInfo(); - } - chdir($oldDir); - } - else - { - if(!is_dir($backupFile)) mkdir($backupFile, 0777, true); - $zfile = $this->app->loadClass('zfile'); - $zfile->copyDir($this->app->getAppRoot() . 'www/data/', $backupFile); - } + if(!is_dir($backupFile)) mkdir($backupFile, 0777, true); + $zfile = $this->app->loadClass('zfile'); + $zfile->copyDir($this->app->getAppRoot() . 'www/data/', $backupFile); return $return; } @@ -88,39 +70,21 @@ class backupModel extends model $fileList = array_merge($fileList, $wwwFileList); - $nozip = strpos($this->config->backup->setting, 'nozip') !== false; - if(!$nozip) + if(!is_dir($backupFile)) mkdir($backupFile, 0777, true); + $zfile = $this->app->loadClass('zfile'); + foreach($fileList as $codeFile) { - $oldDir = getcwd(); - chdir($this->app->getTmpRoot()); - $this->app->loadClass('pclzip', true); - $zip = new pclzip($backupFile); - $zip->create($fileList, PCLZIP_OPT_REMOVE_PATH, $appRoot, PCLZIP_OPT_TEMP_FILE_ON); - if($zip->errorCode() != 0) + $file = trim(str_replace($appRoot, '', $codeFile), DS); + if(is_dir($codeFile)) { - $return->result = false; - $return->error = $zip->errorInfo(); + if(!is_dir($backupFile . DS . $flle)) mkdir($backupFile . DS . $flle, 0777, true); + $zfile->copyDir($codeFile, $backupFile . DS . $file); } - chdir($oldDir); - } - else - { - if(!is_dir($backupFile)) mkdir($backupFile, 0777, true); - $zfile = $this->app->loadClass('zfile'); - foreach($fileList as $codeFile) + else { - $file = trim(str_replace($appRoot, '', $codeFile), DS); - if(is_dir($codeFile)) - { - if(!is_dir($backupFile . DS . $flle)) mkdir($backupFile . DS . $flle, 0777, true); - $zfile->copyDir($codeFile, $backupFile . DS . $file); - } - else - { - $dirName = dirname($file); - if(!is_dir($backupFile . DS . $dirName)) mkdir($backupFile . DS . $dirName, 0777, true); - $zfile->copyFile($codeFile, $backupFile . DS . $file); - } + $dirName = dirname($file); + if(!is_dir($backupFile . DS . $dirName)) mkdir($backupFile . DS . $dirName, 0777, true); + $zfile->copyFile($codeFile, $backupFile . DS . $file); } } @@ -153,8 +117,7 @@ class backupModel extends model $return->result = true; $return->error = ''; - $nozip = strpos($this->config->backup->setting, 'nozip') !== false; - if(!$nozip) + if(is_file($backupFile)) { $oldDir = getcwd(); chdir($this->app->getTmpRoot()); @@ -167,7 +130,7 @@ class backupModel extends model } chdir($oldDir); } - else + elseif(is_dir($backupFile)) { $zfile = $this->app->loadClass('zfile'); $zfile->copyDir($backupFile, $this->app->getAppRoot() . 'www/data/');