/** * Build tar gzip archive file. * * @return true|false Whether successful or not. */ public function build() { // Patch config file first $this->patchConfigFile(); // Patch package.xml file $files = $this->patchPackageFile(); // Create tgz archive $archiver = new Archiver($this->name . '-' . $this->version . '.tgz'); // add all files defined in package.xml file foreach ($files as $file) { $archiver->addFile($file, str_replace($this->packageDir, '', $file)); } // add package.xml $archiver->addFile($this->packageFile, str_replace($this->packageDir, '', $this->packageFile)); $archiver->compress(); $this->log[] = $this->name . '-' . $this->version . '.tgz created'; return implode($this->log, "\n"); }
private function getPackedArchive() { global $projectTmpDir; $logFilename = $projectTmpDir . '/scan_log.xml'; $packedLogFilename = $logFilename . '.zip'; if (!is_file($logFilename)) { die(PS_ERR_NO_DOWNLOAD_LOG_FILE); } $xml_data = file_get_contents($logFilename); $archiver = new Archiver($packedLogFilename, 'a'); $archiver->createFile(basename($logFilename), $xml_data); $quarantineFilepathFilepath = $projectTmpDir . '/malware_quarantine_filepath.tmp.txt'; if (file_exists($quarantineFilepathFilepath)) { $quarantineFilepath = file_get_contents($quarantineFilepathFilepath); $archiver->addFile($quarantineFilepath, basename($quarantineFilepath)); unlink($quarantineFilepathFilepath); } $archiver->close(); $this->streamFileContent($packedLogFilename, true); unlink($logFilename); }