setError('Unable to create directory for archive'); return false; } } // Check if archive exists // $archiveFilePath = $path . $destination; if (file_exists($destination)) { // If overwrite flag is set if ($overwrite) { // Delete archive Pagebuilderck\CKFile::delete($destination); } else { // Set error and return $this->setError('Archive exists'); return false; } } // Prepare files for the zip archiver $filesToZip = array(); $path = $this->cleanPath($path); foreach ($files as $file) { if (file_exists($file)) { $file = $this->cleanPath($file); $filename = str_replace($path . '/', '', $file); $filesToZip[] = array( 'data' => file_get_contents($file), 'name' => $filename ); } } // Create ZIP archiver $archiver = new CKArchiveZip(); // Create Archive $isSuccess = $archiver->create($destination, $filesToZip); // Check of operation was successful if (!$isSuccess) { // Set Error $this->setError('Unable to create archive'); } // return $isSuccess; } protected function cleanPath($path) { // $ds = DIRECTORY_SEPARATOR; // $path = str_replace("/", $ds, $path); $path = str_replace("\\", '/', $path); return $path; } }