get('tmp_path'); // instantiate archive class $archive = new Joomla\Archive\Archive(array('tmp_path' => $tmp_path)); // extract the archive return $archive->extract($source, $destination); } // backward compatibility return JArchive::extract($source, $destination); } /** * Downloads the specified archive. * * @param string $source The path of the folder to compress. * * @return void * * @throws Exception */ public function download($source) { if (!JFile::exists($source)) { // the selected archive doesn't exist throw new Exception(sprintf('Archive [%s] not found', $source), 404); } $app = JFactory::getApplication(); // prepare headers $app->setHeader('Content-Disposition', 'attachment; filename=' . basename($source)); $app->setHeader('Content-Length', filesize($source)); // send headers $app->sendHeaders(); // use fopen to properly download large files $handle = fopen($source, 'rb'); // read 1MB per cycle $chunk_size = 1024 * 1024; while (!feof($handle)) { echo fread($handle, $chunk_size); ob_flush(); flush(); } fclose($handle); } /** * Compresses the specified folder into an archive. * * @param string $source The path of the folder to compress. * @param string $destination The path of the resulting archive. * * @return bool True on success, false otherwise. */ abstract public function compress($source, $destination); }