Example #1
0
 protected function _updateFromZip($from)
 {
     $files = File::getZipItemsList($from);
     if (empty($files)) {
         $this->_errorStatus = self::ERROR_EMPTY_BACKUP;
         return false;
     }
     $filesWLocalRoot = array();
     foreach ($files as $key => $file) {
         $filesWLocalRoot[] = $this->_docRoot . $file;
         if ($this->sql) {
             if (strrchr($file, '.') === '.sql') {
                 $this->_sqlPaths[] = $file;
                 unset($files[$key]);
             }
         }
     }
     $permCheck = File::checkWritePermission($filesWLocalRoot);
     if ($permCheck !== true) {
         $this->_errorStatus = self::ERROR_CANT_WRITE;
         $this->_errors = array_unique($permCheck);
         return false;
     }
     if ($this->execSql && !empty($this->_sqlPaths)) {
         if (!File::unzipFiles($from, $this->_docRoot, $this->_sqlPaths)) {
             $this->_errorStatus = self::ERROR_CANT_EXTRACT_ZIP;
             return false;
         }
         foreach ($this->_sqlPaths as $path) {
             $curPath = $this->_docRoot . $path;
             if (!$this->_restoreSql($curPath)) {
                 $this->_errorStatus = self::ERROR_SQL_FAIL;
                 return false;
             }
             if (file_exists($curPath)) {
                 unlink($curPath);
             }
         }
     }
     if (!File::unzipFiles($from, $this->_docRoot, $files)) {
         $this->_errorStatus = self::ERROR_CANT_EXTRACT_ZIP;
         return false;
     }
     return true;
 }