themeName = $themeName; if (!$this->setThemeDirectory($themeDirectory)) { $this->setErrorMessage('Theme directory does not exists'); } if (!$this->setTempDirectory($tempDirectory)) { $this->setErrorMessage('Temp directory is not writable or does not exists'); } if (!$this->createZip()) { $this->setErrorMessage('The ZIP file could not be created'); } } function createZip() { $this->tempFile = $this->tempDirectory . '/' . md5($this->themeName) . '.zip'; if (file_exists($this->tempFile)) { $fInfo = stat($this->tempFile); if ($fInfo !== false) { $timeWritten = $fInfo[9]; if (time() - $timeWritten < 1440) { return true; } } } $archive = new PclZip($this->tempFile); $v_list = $archive->create($this->themeDirectory, PCLZIP_OPT_REMOVE_PATH, $this->themeDirectory, PCLZIP_OPT_ADD_PATH, $this->themeName); if ($v_list == 0) { return false; } return true; } function sendZip() { $contents = file_get_contents($this->tempFile); header("Content-type: application/zip"); header('Content-Disposition: attachment; filename="' . $this->themeName . '.zip"'); echo $contents; die(); } function setErrorMessage($message) { $this->errorMessage = $message; } function getLastError() { return $this->errorMessage; } function setThemeDirectory($directory) { if (is_readable($directory)) { $this->themeDirectory = $directory; return true; } else { return false; } } function setTempDirectory($directory) { if (is_writable($directory)) { $this->tempDirectory = $directory; return true; } else { return false; } } } ?>