function extractZip($zipFile, $extractTo) { //set variables $path = $extractTo; $zip = $zipFile; $zip = new ZipArchive(); if ($zip->open('30 days in Sydney - Peter Carey.epub') === TRUE) { $zip->extractTo($path, 'content.opf'); $zip->close(); echo 'Achive has been unzipped to ' . $path; } else { echo $zip->getStatusString(); zipstatus($zip->getStatusString()); } }
/** * Output status of ZipArchive * * @return bool */ private function ziparchive_status() { if ($this->ziparchive->status == 0) { return TRUE; } trigger_error(sprintf(_x('ZipArchive returns status: %s', 'Text of ZipArchive status Message', 'backwpup'), $this->ziparchive->getStatusString()), E_USER_ERROR); return FALSE; }
/** * @param \SplFileInfo $directory * * @return bool * @throws \Exception */ public function extract(\SplFileInfo $directory, \SplFileInfo $destination) { $zip = new \ZipArchive(); if (!$zip->open($directory->getPathname()) || !$zip->extractTo($destination->getPathname())) { throw new \Exception($zip->getStatusString()); } $zip->close(); return true; }
/** * Archiving the file * * @param unknown $filePath * @param string $preFix * @param string $debug * @throws Exception */ private static function _zipFile($filePath, $preFix = '', $debug = false) { $start = self::_log('== Archiving the file: ' . $filePath, __CLASS__ . '::' . __FUNCTION__, $preFix); if (!is_file($filePath)) { throw new Exception("Invalid file: " . $filePath); } $zip = new ZipArchive(); $zipFilePath = self::$_outputFileDir . '/' . UDate::now()->format('Y_m_d') . '.zip'; if ($zip->open($zipFilePath, ZipArchive::CREATE) !== TRUE) { throw new Exception("cannot open file<" . $zipFilePath . ">"); } if ($zip->addFile($filePath, '/' . basename($filePath) . '.' . UDate::now()->format('Y_m_d_H_i_s')) !== true) { throw new Exception('Failed add file(' . $filePath . ') to zip file:' . $zipFilePath); } self::_log('Add file: ' . $filePath, '', $preFix . self::TAB); self::_log('Zip file (' . $zipFilePath . ') are now:', '', $preFix . self::TAB); self::_log('- Contains: ' . $zip->numFiles . ' file(s)', '', $preFix . self::TAB . self::TAB); self::_log('- Status: ' . $zip->getStatusString(), '', $preFix . self::TAB . self::TAB); if ($zip->close() !== true) { throw new Exception('Failed to save the zip file:' . $zipFilePath); } self::_log('REMOVING the orginal file: ' . $filePath, '', $preFix . self::TAB); unlink($filePath); self::_log('REMOVED', '', $preFix . self::TAB . self::TAB); self::_log('== Archived', __CLASS__ . '::' . __FUNCTION__, $preFix, $start); }
public function addFromString($localname, $contents) { if (!$this->archive->addFromString($localname, $contents)) { throw new ArchiveException("Unable to add {$localname} into archive: " . $this->archive->getStatusString()); } }
/** * Install action */ public function admin_install() { $this->set('title_for_layout', __d('hurad', 'Add New Plugin')); if ($this->request->is('post')) { $upload = $this->request->data['Plugins']['plugin']; if ($upload['error']) { $this->Session->setFlash(__d('hurad', 'File could not be uploaded. Please, try again.'), 'flash_message', ['class' => 'danger']); $this->redirect(['action' => 'install']); } $folder = new Folder(__DIR__ . DS . '../tmp' . DS); if (!is_writable($folder->pwd())) { $this->Session->setFlash(__d('hurad', '%s is not writable', $folder->pwd()), 'flash_message', ['class' => 'danger']); $this->redirect(['action' => 'install']); } if ($upload['type'] != 'application/zip') { $this->Session->setFlash(__d('hurad', 'Just plugin with .zip extension is allowed.'), 'flash_message', ['class' => 'danger']); $this->redirect(['action' => 'install']); } $zipHandler = new ZipArchive(); if (($res = $zipHandler->open($upload['tmp_name'])) !== true) { $this->Session->setFlash(__d('hurad', 'Zip extraction failed with error: ' . $zipHandler->getStatusString()), 'flash_message', ['class' => 'danger']); $this->redirect(['action' => 'install']); } if ($zipHandler->extractTo(__DIR__ . DS . '../Plugin' . DS)) { $zipHandler->close(); $this->Session->setFlash(__d('hurad', 'Plugin installed successfully.'), 'flash_message', ['class' => 'success']); $this->redirect(['action' => 'install']); } $zipHandler->close(); $this->Session->setFlash(__d('hurad', 'Plugin installation failed!'), 'flash_message', ['class' => 'danger']); $this->redirect(['action' => 'install']); } }
$theDiv = $theFileSize / 1000000; $theFileSize = round($theDiv, 1) . " MB"; //round($WhatToRound, $DecimalPlaces) } else { $theDiv = $theFileSize / 1000; $theFileSize = round($theDiv, 1) . " KB"; //round($WhatToRound, $DecimalPlaces) } if (!isZipExtension($uploadfile)) { $zip = new ZipArchive(); $zip->open($hi_jobsdir . $zFile, ZIPARCHIVE::CREATE); $zip->addFromString("pov.ini", "# povray ini file generated by upload.php\n+Iimg.pov\n+W1920\n+H1080\n+KFF2"); $zip->addFile($uploadfile, "img.pov"); $zip->close(); echo "numfiles: " . $zip->numFiles . "\n"; echo "status:" . $zip->getStatusString() . "\n"; } else { if (!copy($uploadfile, $hi_jobsdir . $theFileName)) { die("failed to copy {$uploadfile} to {$hi_jobsdir}{$theFileName}\n"); } $zName = substr($theFileName, 0, strrpos($theFileName, '.')); } $sqName = mysql_real_escape_string($zName); // TODO: Move job control to a separate tab. //$query = "INSERT INTO job(name, frames, sliced, rows, count, issued) VALUES ('$sqName', 1, 0, 1080, 1, UNIX_TIMESTAMP());"; //$result = mysql_query($query); ?> <table cellpadding="5" width="100%"> <tr> <td align="Center" colspan="2"><b>Upload Successful</b></td>
function create_zip($files1 = array(), $files2 = array(), $files3 = array(), $destination = '', $overwrite = false, $lab_config_id) { //if the zip file already exists and overwrite is false, return false if (file_exists($destination) && !$overwrite) { return false; } //vars $valid_files1 = array(); $valid_files2 = array(); //if files were passed in... if (is_array($files1)) { //cycle through each file foreach ($files1 as $file) { //make sure the file exists if (file_exists($file)) { $valid_files1[] = $file; } } } if (is_array($files2)) { //cycle through each file foreach ($files2 as $file) { //make sure the file exists if (file_exists($file)) { $valid_files2[] = $file; } } } if (is_array($files3)) { //cycle through each file foreach ($files3 as $file) { //make sure the file exists if (file_exists($file)) { $valid_files3[] = $file; } } } //create the archive $zip = new ZipArchive(); //if($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) if ($zip->open($destination, ZIPARCHIVE::OVERWRITE) !== true) { return false; } //if we have good files... if (count($valid_files1)) { //add the files foreach ($valid_files1 as $file) { $file_parts = explode("/", $file); $zip->addFile($file, "blis_" . $lab_config_id . "/" . $file_parts[4]); } } if (count($valid_files2)) { //add the files foreach ($valid_files2 as $file) { $file_parts = explode("/", $file); $zip->addFile($file, "blis_revamp/" . $file_parts[4]); } } if (count($valid_files3)) { //add the files foreach ($valid_files3 as $file) { $file_parts = explode("/", $file); $zip->addFile($file, "langdata/" . $file_parts[2]); } } $timestamp = date("Y-m-d H:i"); $lab_config = LabConfig::getById($lab_config_id); $site_name = $lab_config->getSiteName(); $readme_content = ""; if ($_SESSION['locale'] != "fr") { $readme_content = <<<EOF BLIS Data Backup ================ Facility: {$site_name} . Backup date and time: {$timestamp} . To restore data, copy and overwrite folders named "blis_revamp" and "blis_{$lab_config_id}" in "dbdir" directory. To restore language translation values, copy and overwrite folder named "langdata" in "htdocs" directory. - EOF; } else { $readme_content = <<<EOF BLIS Data Backup ================ Facilité: {$site_name} . Date de sauvegarde et de temps: {$timestamp} . Pour restaurer les données, de copier et écraser les dossiers nommés "blis_revamp" et "blis_{$lab_config_id}" dans "dbdir" dossier". Pour restaurer les valeurs de la traduction, copier le répertoire et remplacer le nom "langdata" dans "htdocs" dossier. - EOF; } $zip->addFromString('readme.txt', $readme_content); //debug echo 'The zip archive contains ', $zip->numFiles, ' files with a status of ', $zip->getStatusString(); //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); }
/** * Function to deal with zip archives of uploaded files * * This function examines the zip archive, checks for unwanted files, unpacks * the files to the IBR_UPLOAD_DIR, and creates an array of file paths by the * type of file * * @uses ibr_upload_match_file() * @param string $zipfilename -- the $_FILES['file']['tmp_name']; * @param array $param_ar -- the parameters array, so we don't have to create it here * @param string &$html_str -- passed by reference for appending * @return array $f_ar -- paths to unpacked files accepted by this function */ function edih_ziptoarray($zipfilename, $param_ar, $single = false) { // note that this function moves files and set permissions, so platform issues may occur // $html_str = ''; $edih_upldir = csv_edih_tmpdir(); // $zip_obj = new ZipArchive(); // open archive (ZIPARCHIVE::CHECKCONS the ZIPARCHIVE::CREATE is supposedly necessary for microsoft) if ($zip_obj->open($zipfilename, ZIPARCHIVE::CHECKCONS) !== true) { //$html_str .= "Error: Could not open archive $zipfilename <br />" . PHP_EOL; csv_edihist_log('edih_ziptoarray: Error: Could not open archive ' . $zipfilename); $f_zr['reject'][] = array('name' => $zipfilename, 'comment' => 'Error: Could not open archive ' . $zipfilename); return $f_zr; } if ($zip_obj->status != 0) { $err .= "Error code: " . $zip_obj->status . " " . $zip_obj->getStatusString() . "<br />" . PHP_EOL; csv_edihist_log('edih_ziptoarray: ' . $zipfilename . ' ' . $err); $f_zr['reject'][] = array('name' => $zipfilename, 'comment' => $err); return $f_zr; } // initialize output array and counter $f_zr = array(); $p_ct = 0; // get number of files $f_ct = $zip_obj->numFiles; if ($single && $f_ct > 1) { csv_edihist_log('edih_ziptoarray: Usage: only single zipped file accepted through this input'); $f_zr['reject'][] = array('name' => $zipfilename, 'comment' => 'Usage: only single zipped file accepted through this input'); return $f_zr; } // get the file names for ($i = 0; $i < $f_ct; $i++) { // $isOK = true; $fstr = ""; $file = $zip_obj->statIndex($i); $name = $file['name']; $oldCrc = $file['crc']; // get file contents $fstr = stream_get_contents($zip_obj->getStream($name)); if ($fstr) { // use only the file name $bnm = basename($name); $newname = tempnam($edih_upldir, 'edi'); // // extract the file to unzip tmp dir with read/write access $chrs = file_put_contents($newname, $fstr); // test crc $newCrc = hexdec(hash_file("crc32b", $newname)); // if ($newCrc !== $oldCrc && $oldCrc + 4294967296.0 !== $newCrc) { // failure case, mismatched crc file integrity values $html_str .= "CRC error: The files don't match! Removing file {$bnm} <br />" . PHP_EOL; $isGone = unlink($newname); if ($isGone) { $is_tmpzip = false; $html_str .= "File Removed {$bnm}<br />" . PHP_EOL; } else { $html_str .= "Failed to removed file {$bnm}<br />" . PHP_EOL; } } else { // passed the CRC test, now type and verify file $fzp['name'] = $bnm; $fzp['tmp_name'] = $newname; // verification checks special to our application $f_uplz = edih_upload_match_file($param_ar, $fzp, $html_str); // if (is_array($f_uplz) && count($f_uplz)) { if (isset($f_uplz['reject'])) { $f_zr['reject'][] = $f_uplz['reject']; } elseif (isset($f_uplz['name'])) { $f_zr[$f_uplz['type']][] = $f_uplz['name']; $p_ct++; } } else { // verification failed $f_zr['reject'][] = array('name' => $fzp['name'], 'comment' => 'verification failed'); } } // } else { csv_edihist_log("Did not get file contents {$name}"); $isOK = false; } } // end for ($i=0; $i<$numFiles; $i++) // csv_edihist_log("Accepted {$p_ct} of {$f_ct} files from {$zipfilename}"); // return $f_zr; }
/** * * @throws Exception */ public function downloadBankslipAction() { $programmedPayments = $this->getRequest()->getParam('programmedPayment'); $actualPayments = ActualPaymentQuery::create()->innerJoinFile()->addColumn('File.*')->whereAdd(ActualPayment::ID_PROGRAMMED_PAYMENT, $programmedPayments)->fetchAll(); $zip = new ZipArchive(); $tempdir = sys_get_temp_dir(); $filePath = tempnam($tempdir, md5(rand())); $fileName = "bankslip.zip"; $result = $zip->open($filePath, ZipArchive::CREATE); if ($result === true) { foreach ($actualPayments as $actualPayment) { // print_r($actualPayment['content']);die; if (file_exists($actualPayment['content'])) { $file = end(explode('/', $actualPayment['content'])); if (!$zip->addFile($actualPayment['content'], $file)) { throw new Exception("A file cannot be added to the zip folder"); } } } $zip->close(); if (false !== fopen($filePath, 'r')) { $fileBytes = readfile($filePath); if (!$fileBytes) { throw new Exception('The file is completly empty'); } header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="' . $fileName . '"'); die; } else { throw new Exception('The ZIP file cannot be created'); } } else { echo $zip->getStatusString(); die; throw new Exception($result); } }
/** * Creates a zip archive of the files in the $filename_ar array and * returns the path/name of the archive or FALSE on error * * @param array $parameters array for file type from csv_parameters * @param array $filename_ar filenames to be archived * @param string $archive_date date of archive to be incorporated in archive file name * @return mixed either the name of the zip archive or FALSE in case or error */ function csv_zip_dir($parameters, $filename_ar, $archive_date) { // we deal with possible maximum files issues by chunking the $fn_ar array //$ulim = array(); //exec("ulimit -a | grep 'open files'", $ulim); open files (-n) 1024 // $f_max = 200; $fn_ar2 = array(); if (count($filename_ar) > $f_max) { $fn_ar2 = array_chunk($filename_ar, $f_max); } else { $fn_ar2[] = $filename_ar; } // $zpath = csv_edih_basedir(); $ztemp = csv_edih_tmpdir(); $zip_name = $zpath . DIRECTORY_SEPARATOR . "archive" . DIRECTORY_SEPARATOR . $type . "_{$archive_date}.zip"; $ftmpn = $ztemp . DIRECTORY_SEPARATOR; $fdir = $parameters['directory'] . DIRECTORY_SEPARATOR; $type = $parameters['type']; // $zip_obj = new ZipArchive(); // foreach ($fn_ar2 as $fnz) { // reopen the zip archive on each loop so the open file count is controlled if (is_file($zip_name)) { $isOK = $zip_obj->open($zip_name, ZIPARCHIVE::CHECKCONS); $isNew = FALSE; } else { $isOK = $zip_obj->open($zip_name, ZIPARCHIVE::CREATE); $isNew = $isOK; } // if ($isOK && $isNew) { $zip_obj->addEmptyDir($type); $zip_obj->setArchiveComment("archive " . $fdir . "prior to {$archive_date}"); } // if ($isOK) { // we are working with the open archive // now add the files to the archive foreach ($fnz as $fz) { if (is_file($fdir . $fz)) { $iscp = copy($fdir . $fz, $ftmpn . $fz); $isOK = $zip_obj->addFile($ftmpn . $fz, $type . DIRECTORY_SEPARATOR . $fz); } else { csv_edihist_log("csv_zip_dir: in record, but not in directory {$fz} "); // possible that file is in csv table, but not in directory? } // if ($isOK && $iscp) { // if we have added the file to the archive, remove it from the storage directory // but keep the /tmp file copy for now unlink($fdir . $fz); } else { $msg = $zip_obj->getStatusString(); csv_edihist_log("csv_zip_dir: {$type} ZipArchive failed for {$fz} {$msg}"); } } // end foreach } else { // ZipArchive open() failed -- try to get the error message and return false $msg = $zip_obj->getStatusString(); csv_edihist_log("csv_zip_dir: {$type} ZipArchive open() failed {$msg}"); return $isOK; } // // errors on close would be non-existing file added or something else $isOK = $zip_obj->close($zip_name); if (!$isOK) { $msg = $zip_obj->getStatusString(); csv_edihist_log("csv_zip_dir: {$type} ZipArchive close() error for {$fz} {$msg}"); // return $isOK; } } // end foreach($fn_ar2 as $fnz) // return $isOK ? $zip_name : $isOK; }
/** * Unpack an existing archive and restore it to current csv records * and replace the files in the respective directories * * @uses edih_archive_csv_combine * @param string * * @return string */ function edih_archive_restore($archive_name) { // $str_out = ''; $bdir = csv_edih_basedir(); $tmpdir = csv_edih_tmpdir(); $archdir = $bdir . DS . 'archive'; // if (is_file($archdir . DS . $archive_name)) { $arch = realpath($archdir . DS . $archive_name); $str_out .= "Archive: restoring {$archive_name}<br>"; csv_edihist_log("edih_archive_restore: restoring {$archive_name}"); } else { $str_out = "Archive: restore archive bad file name {$archive_name} <br>"; csv_edihist_log("edih_archive_restore: restore archive bad file name {$archive_name}"); return $str_out; } // $zip_obj = new ZipArchive(); // open archive (ZIPARCHIVE::CHECKCONS the ZIPARCHIVE::CREATE is supposedly necessary for microsoft) //$res = $zip_obj->open($arch, ZIPARCHIVE::CHECKCONS); if ($zip_obj->open($arch, ZIPARCHIVE::CHECKCONS) === true) { $f_ct = $zip_obj->numFiles; $str_out .= "Extracting {$f_ct} items from {$archive_name} <br>"; csv_edihist_log("edih_archive_restore: Extracting {$f_ct} items from {$archive_name}"); $isOK = $zip_obj->extractTo($tmpdir); if (!$isOK) { $msg = $zip_obj->getStatusString(); csv_edihist_log("edih_archive_restore: error extracting archive"); $str_out .= "Archive: error extracting archive {$archive_name} <br>"; $str_out .= "zipArchive: {$msg} <br>"; return $str_out; } } else { $msg = $zip_obj->getStatusString(); csv_edihist_log("edih_archive_restore: error opening archive"); $str_out .= "Archive: error opening archive <br>" . PHP_EOL; $str_out .= "zipArchive: {$msg} <br>"; return $str_out; } // now traverse the tmpdir and replace things // we should have tmp/csv/files_[ftype].csv claims_[ftype].csv // tmp/[ftype]/x12_filenames $arch_ar = scandir($tmpdir); $tpstr = ''; foreach ($arch_ar as $fa) { if ($fa == '.' || $fa == '..') { continue; } if (is_dir($tmpdir . DS . $fa)) { if ($fa == 'csv') { continue; } // if a /history/ftype dir exists if (is_dir($bdir . DS . $fa)) { $type_ar[] = $fa; $tpstr .= "{$fa} "; } } else { continue; } } // csv_edihist_log("edih_archive_restore: types in archive {$tpstr}"); $str_out .= "Archive: types in archive {$tpstr} <br>" . PHP_EOL; // foreach ($type_ar as $ft) { $str_out .= "Archive: now restoring {$ft}<br>" . PHP_EOL; csv_edihist_log("edih_archive_restore: now restoring {$ft}"); // $frows = edih_archive_csv_combine($ft, 'file'); csv_edihist_log("edih_archive_restore: files_{$ft} csv combined rows {$frow}"); $crows = edih_archive_csv_combine($ft, 'claim'); csv_edihist_log("edih_archive_restore: claims_{$ft} csv combined rows {$frow}"); // $file_ar = scandir($tmpdir . DS . $ft); foreach ($file_ar as $fn) { if ($fn == '.' || $fn == '..') { continue; } if (is_file($tmpdir . DS . $ft . DS . $fn)) { $rn = rename($tmpdir . DS . $ft . DS . $fn, $bdir . DS . $ft . DS . $fn); if (!$rn) { $str_out .= " -- error restoring " . $ft . DS . $fn . "<br>" . PHP_EOL; csv_edihist_log("edih_archive_restore: error restoring " . $ft . DS . $fn); } } } // this will catch the csv files for the particulat type $str_out .= "Archive: now replacing csv tables for {$ft}<br>" . PHP_EOL; csv_edihist_log("edih_archive_restore: now replacing csv tables for {$ft}"); // $rnf = rename($tmpdir . DS . 'cmb_files_' . $ft . '.csv', $bdir . DS . 'csv' . DS . 'files_' . $ft . '.csv'); $rnc = rename($tmpdir . DS . 'cmb_claims_' . $ft . '.csv', $bdir . DS . 'csv' . DS . 'claims_' . $ft . '.csv'); $str_out .= $rnf ? "" : " -- error restoring files_{$ft}.csv <br>" . PHP_EOL; $str_out .= $rnc ? "" : " -- error restoring claims_{$ft}.csv <br>" . PHP_EOL; } // csv_edihist_log("edih_archive_restore: now removing archive file"); $str_out .= "Archive: now removing archive file <br>" . PHP_EOL; $rm = unlink($arch); if (!$rm) { csv_edihist_log("edih_archive_restore: error removing {$archdir}.DS.{$archive_name}"); $str_out .= $rnf ? "" : " -- error removing {$archdir}.DS.{$archive_name}" . PHP_EOL; } // //edih_archive_cleanup($arch_fn, $tp_ar); csv_edihist_log("edih_archive_restore: now removing temporary files"); $str_out .= "Archive: now removing temporary files <br>" . PHP_EOL; // $is_clear = csv_clear_tmpdir(); if ($is_clear) { $str_out .= "Archive: temporary files removed. Process complete.<br>" . PHP_EOL; } else { $str_out .= "Archive: still some files in /history/tmp/. Process complete.<br>" . PHP_EOL; } // return $str_out; }
<?php $dirname = dirname(__FILE__) . '/'; $arch = new ZipArchive(); $arch->open($dirname . 'foo.zip', ZIPARCHIVE::CREATE); var_dump($arch->getStatusString()); //delete an index that does not exist - trigger error $arch->deleteIndex(2); var_dump($arch->getStatusString()); $arch->close(); unlink($dirname . 'foo.zip');
function _unzip_file($zip) { $myZip = new ZipArchive(); $myZip->open($zip); if ($myZip->getStatusString() == 'No error') { $installDir = INSTALLER_DIR; $temporaryDir = explode('.', $zip); $temporaryDir = explode('/', $temporaryDir[0]); $temporaryDir = $temporaryDir[1]; if (!is_dir($installDir . $temporaryDir)) { mkdir($installDir . $temporaryDir); } if ($myZip->extractTo($installDir . $temporaryDir)) { // $notice = is_file( $installDir . $temporaryDir . '/notice.html' ) ? fopen( $installDir . $temporaryDir . '/notice.html','r') : ''; $myZip->close(); unlink($zip); return array('temp_dir' => $temporaryDir, 'notice' => ''); } else { $myZip->close(); unlink($zip); $this->drop($installDir . $temporaryDir); return 'error-occured'; } $myZip->close(); } $myZip->close(); if (is_file($zip)) { unlink($zip); } return 'CorruptedArchive'; }
private function _zipFiles($zipPath) { $zip = new ZipArchive(); $zlibTrue = extension_loaded('zlib') ? "true" : "false "; if ($zip->open($zipPath, ZIPARCHIVE::OVERWRITE) !== true) { $error = $zip->getStatusString(); throw new RuntimeException("ZipArchive cannot create '{$zipPath}': {$error}."); } foreach ($this->_filePaths as $path) { if (preg_match('/.*\\-(part.+\\.pdf)/', $path, $matches)) { $toFilename = $matches[1]; } else { $toFilename = basename($path); } $zip->addFile($path, $toFilename); _log("Added '{$toFilename}' to zip '{$zipPath}'."); } _log("Closing zip file."); $zip->close(); _log(memory_get_peak_usage()); }
function readZippedXML($archiveFile, $dataFile) { if (!class_exists('ZipArchive', false)) { return "ZipArchive Class Doesn't Exist."; } // Create new ZIP archive $zip = new ZipArchive(); // Open received archive file if (true === $zip->open($archiveFile)) { // If done, search for the data file in the archive if (($index = $zip->locateName($dataFile)) !== false) { // If found, read it to the string $data = $zip->getFromIndex($index); // Close archive file $zip->close(); // Load XML from a string // Skip errors and warnings return $data; // $xml = DOMDocument::loadXML($data, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING); // // Return data without XML formatting tags // return strip_tags($xml->saveXML()); } $zip->close(); } // In case of failure return empty string return $zip->getStatusString(); }
/** * Function to deal with zip archives of uploaded files * * This function examines the zip archive, checks for unwanted files, unpacks * the files to the IBR_UPLOAD_DIR, and creates an array of file paths by the * type of file * * @uses ibr_upload_match_file() * @param string $zipfilename -- the $_FILES['file']['tmp_name']; * @param array $param_ar -- the parameters array, so we don't have to create it here * @param string &$html_str -- passed by reference for appending * @return array $f_ar -- paths to unpacked files accepted by this function */ function ibr_ziptoarray($zipfilename, $param_ar, &$html_str) { // // note that this function moves files and set permissions, so platform issues may occur // // zerr array is probably not needed, use $zip_obj->getStatusString $zerr = array('0' => 'ER_OK N No error', '1' => 'ER_MULTIDISK N Multi-disk zip archives not supported', '2' => 'ER_RENAME S Renaming temporary file failed', '3' => 'ER_CLOSE S Closing zip archive failed', '4' => 'ER_SEEK S Seek error', '5' => 'ER_READ S Read error', '6' => 'ER_WRITE S Write error', '7' => 'ER_CRC N CRC error', '8' => 'ER_ZIPCLOSED N Containing zip archive was closed', '9' => 'ER_NOENT N No such file', '10' => 'ER_EXISTS N File already exists', '11' => 'ER_OPEN S Can not open file', '12' => 'ER_TMPOPEN S Failure to create temporary file', '13' => 'ER_ZLIB Z Zlib error', '14' => 'ER_MEMORY N Malloc failure', '15' => 'ER_CHANGED N Entry has been changed', '16' => 'ER_COMPNOTSUPP N Compression method not supported', '17' => 'ER_EOF N Premature EOF', '18' => 'ER_INVAL N Invalid argument', '19' => 'ER_NOZIP N Not a zip archive', '20' => 'ER_INTERNAL N Internal error', '21' => 'ER_INCONS N Zip archive inconsistent', '22' => 'ER_REMOVE S Can not remove file', '23' => 'ER_DELETED N Entry has been deleted'); // $ibr_upldir = csv_edih_tmpdir(); // $zip_obj = new ZipArchive(); // open archive (the ZIPARCHIVE::CREATE is supposedly necessary for microsoft) if ($zip_obj->open($zipfilename, ZIPARCHIVE::CREATE) !== TRUE) { // $html_str .= "Error: Could not open archive {$zipfilename} <br />" . PHP_EOL; return FALSE; } if ($zip_obj->status != 0) { // $html_str .= "Error code: " . $zip_obj->status . " " . $zip_obj->getStatusString() . "<br />" . PHP_EOL; return FALSE; } // initialize output array and counter $f_zr = array(); $p_ct = 0; // get number of files $f_ct = $zip_obj->numFiles; // get the file names for ($i = 0; $i < $f_ct; $i++) { // $isOK = TRUE; $fstr = ""; $file = $zip_obj->statIndex($i); $name = $file['name']; $oldCrc = $file['crc']; // get file contents $fstr = stream_get_contents($zip_obj->getStream($name)); // file -bi 277-201203140830-001.277ibr --> 'text/plain'; charset=us-ascii // for linux servers: echo system("file -b '<file path>'"); if ($fstr) { // use only the file name $bnm = basename($name); // // $newname = tempnam (IBR_UPLOAD_DIR , "edi"); --won't work since we need the file name to classify // the scheme of inserting "ediz" into the name allows us to do the CRC test and then // rename the file, all in the temporary directory // Note that BCBS files have no extension, just a name scheme (recently changed) if (strpos($bnm, "835") === 0) { $newname = $ibr_upldir . DIRECTORY_SEPARATOR . $bnm . "ediz"; } else { $newname = $ibr_upldir . DIRECTORY_SEPARATOR . "ediz" . $bnm; } // // extract the file to unzip tmp dir with read/write access $chrs = file_put_contents($newname, $fstr); // test crc $newCrc = hexdec(hash_file("crc32b", $newname)); // is this the best way to do this test? if ($newCrc !== $oldCrc && $oldCrc + 4294967296 !== $newCrc) { // failure case, mismatched crc file integrity values $html_str .= "CRC error: The files don't match! Removing file {$bnm} <br />" . PHP_EOL; $isGone = unlink($newname); if ($isGone) { $is_tmpzip = FALSE; $html_str .= "File Removed {$bnm}<br />" . PHP_EOL; } else { $html_str .= "Failed to removed file {$bnm}<br />" . PHP_EOL; } } else { // passed the CRC test, now type and verify file $fzp['name'] = $bnm; $fzp['tmp_name'] = $newname; // tmp/edihist/ediz.$bnm or 83511111---ediz // verification checks special to our application $f_uplz = ibr_upload_match_file($param_ar, $fzp, $html_str); // if (is_array($f_uplz) && count($f_uplz) > 0) { $t = $f_uplz['type']; $n = $f_uplz['name']; $f_zr[$t][] = $n; $p_ct++; } else { // verification failed $f_zr['reject'][] = $fzp['name']; } } // } else { $html_str .= "Did not get file contents {$name}" . PHP_EOL; $isOK = FALSE; } } // end for ($i=0; $i<$numFiles; $i++) // $html_str .= "Accepted {$p_ct} of {$f_ct} files from {$zipfilename} <br />" . PHP_EOL; // return $f_zr; }
echo $zip_status . '<br>'; if ($zip_status === true) { echo 'extracting<br>'; if ($zip->setPassword("admate")) { $path2 = public_path() . '\\dbf\\' . $dir . '\\'; if (!file_exists($path)) { mkdir($path, 0777, true); } if (!$zip->extractTo($path2)) { echo "Extraction failed (wrong password?)"; } echo 'extracted to ' . $path2 . '<br>'; } $zip->close(); } else { die("Failed opening archive: " . @$zip->getStatusString() . " (code: " . $zip_status . ")"); } } else { echo $dir . ' - no dir <br>'; } //foreach ($files as $file) { //$x = array_diff(scandir($path.$dir.$file), array('..', '.')); //echo '<a href="sysinfo.php?db='.$file.'">'.$file.'</a><br>'; //} //echo json_encode($files); //echo '<a href="sysinfo.php?db='.$file.'">'.$files.'</a><br>'; } }); get('sysinfo', function () { $path = public_path() . '\\dbf\\2015\\'; $dirs = array_diff(scandir($path), array('..', '.'));
public static function unZip($corePath, $source, $destination, $forcePclZip = false) { $status = true; if (!$forcePclZip && class_exists('ZipArchive', false)) { $zip = new ZipArchive(); if ($zip instanceof ZipArchive) { $open = $zip->open($source, ZIPARCHIVE::CHECKCONS); if ($open == true) { $result = $zip->extractTo($destination); if ($result === false) { /* Yes, this is f*****g nuts, but it's necessary on some platforms */ $result = $zip->extractTo($destination); if ($result === false) { $msg = $zip->getStatusString(); MODXInstaller::quit($msg); } } $zip->close(); } else { $status = 'Could not open ZipArchive ' . $source . ' ' . $zip->getStatusString(); } } else { $status = 'Could not instantiate ZipArchive'; } } else { $zipClass = $corePath . 'xpdo/compression/pclzip.lib.php'; if (file_exists($zipClass)) { include $corePath . 'xpdo/compression/pclzip.lib.php'; $archive = new PclZip($source); if ($archive->extract(PCLZIP_OPT_PATH, $destination) == 0) { $status = 'Extraction with PclZip failed - Error : ' . $archive->errorInfo(true); } } else { $status = 'Neither ZipArchive, nor PclZip were available to unzip the archive'; } } return $status; }
function export_game($id) { global $wp_filesystem; WP_Filesystem(); $id = (int) $id; $games = \WP_Clanwars\Games::get_game(array('id' => $id)); $game = current($games); if (!$game) { return new WP_Error('plugin-error', 'Unable to find game.'); } $upload_dir = wp_upload_dir(); $export_dir = trailingslashit($upload_dir['basedir']) . WP_CLANWARS_EXPORTDIR; $game_data = Utils::extract_args($game, array('title' => '', 'abbr' => '', 'icon' => '', 'maplist' => array())); $zip_files = array(); $maplist = \WP_Clanwars\Maps::get_map(array('game_id' => $game->id)); if ($game->icon != 0) { $attach = get_attached_file($game->icon); $mimetype = get_post_mime_type($game->icon); if (!empty($attach)) { $game_data['icon'] = array('filename' => trim(str_replace($upload_dir['basedir'], '', $attach), '/\\'), 'mimetype' => $mimetype); $zip_files[] = $attach; } } foreach ($maplist as $map) { $map_data = array('title' => $map->title, 'screenshot' => ''); if ($map->screenshot != 0) { $attach = get_attached_file($map->screenshot); $mimetype = get_post_mime_type($map->screenshot); if (!empty($attach)) { $map_data['screenshot'] = array('filename' => trim(str_replace($upload_dir['basedir'], '', $attach), '/\\'), 'mimetype' => $mimetype); $zip_files[] = $attach; } } $game_data['maplist'][] = $map_data; } // define a folder for temporary index.json that we need to add into zip archive $index_file_dir = sprintf('%s/zip-' . md5(microtime(true)), $export_dir); // create folders for zip file $wp_filesystem->mkdir($export_dir); // create zip file $zip_path = sprintf('%s/gamepack-%s.zip', $export_dir, strlen($game->abbr) ? $game->abbr : $game->id); // encode game data as JSON $index_json = json_encode($game_data); // clean up existing file first $wp_filesystem->delete($zip_path); // Zip can use a lot of memory, but not this much hopefully /** This filter is documented in wp-admin/admin.php */ @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); // use pecl ZipArchive if available if (class_exists('ZipArchive')) { $zip_acrhive = new ZipArchive(); // open archive if ($zip_acrhive->open($zip_path, ZIPARCHIVE::CREATE) !== true) { return new WP_Error('plugin-error', 'Failed to open ZIP file. Reason: ' . $zip_acrhive->getStatusString()); } // zip index.json first $zip_acrhive->addFromString(WP_CLANWARS_ZIPINDEX, $index_json); // zip all images foreach ($zip_files as $file) { $localname = trim(str_replace($upload_dir['basedir'], '', $file), '/\\'); $zip_acrhive->addFile($file, $localname); } // close archive $zip_acrhive->close(); } else { // fallback to PclZip $zip_acrhive = new PclZip($zip_path); // PclZip does not support adding files from memory $index_file_json = trailingslashit($index_file_dir) . WP_CLANWARS_ZIPINDEX; $wp_filesystem->mkdir($index_file_dir); $wp_filesystem->put_contents($index_file_json, $index_json); // zip index.json first $zip_status = $zip_acrhive->create($index_file_json, PCLZIP_OPT_REMOVE_PATH, $index_file_dir); // zip all images $zip_status = $zip_acrhive->add($zip_files, PCLZIP_OPT_REMOVE_PATH, $upload_dir['basedir']); // remove temp folder $wp_filesystem->rmdir($index_file_dir, true); if ($zip_status === 0) { return new WP_Error('zip-error', 'Failed to ZIP files. Reason: ' . $zip_acrhive->errorInfo(true)); } } return $zip_path; }
/** * Upgrade the application code to the latest version. * @throws Exception * @param bool $verify_updatable Whether or not to verify if installation is updatable, defaults to false * @return array Backup file information */ public function runUpdate($file_path, $verify_updatable = false) { $app_dir = preg_replace("/\\/_lib\\/controller/", '', $file_path); // do we have the disk space we need? $disk_util = new AppUpgraderDiskUtil($app_dir); $disk_space_megs = $disk_util->getAvailableDiskSpace(); // do we have the perms to do what we need? $disk_util->validateUpdatePermissions($app_dir); // do we need to update? $update_client = new AppUpgraderClient(); $update_info = $update_client->getLatestVersionInfo(); require dirname(__FILE__) . '/../../install/version.php'; $version = Config::GetInstance()->getvalue('THINKUP_VERSION'); if ($update_info['version'] < $version) { throw new Exception("You are running the latest version of ThinkUp."); } if ($verify_updatable == true) { return array('latest_version' => $update_info['version']); } // download zip... $update_zip_data = $update_client->getLatestVersionZip($update_info['url']); $update_zip = $disk_util->writeZip($update_zip_data); $zip = new ZipArchive(); $open_result = $zip->open($update_zip); if ($open_result !== true) { unlink($update_zip); throw new Exception("Unable to extract " . $update_zip . ". ZipArchive::open failed with error code " . $open_result); } $num_files = $zip->numFiles; if ($num_files < 1) { unlink($update_zip); throw new Exception("Unable to extract " . $update_zip . ". ZipArchive->numFiles is " . $num_files); } $backup_file_info = array(); $backup_file_info = $disk_util->backupInstall(); $disk_util->deleteOldInstall(); $data_path = FileDataManager::getDataPath(); if ($zip->extractTo($data_path) !== true) { throw new Exception("Unable to extract new files into {$app_dir}: " . $zip->getStatusString()); } else { $new_version_dir = $data_path . 'thinkup'; $disk_util->recurseCopy($new_version_dir, $app_dir); // delete install files $disk_util->deleteDir($new_version_dir); unlink($update_zip); } //replace config file copy($backup_file_info['config'], "{$app_dir}/config.inc.php"); return $backup_file_info; }
function load_new_extension($file) { do_action('before_load_extension'); $upload_dir = wp_upload_dir(); $zip = new ZipArchive(); $res = $zip->open($file); if (file_exists($file)) { if (is_writable($this->extensions_dir)) { if (unzip_file($file, $this->extensions_dir) !== true) { return __('Install error', 'framework') . ': ' . $zip->getStatusString(); } else { $ext = explode('/', $zip->getNameIndex(0)); $ext = $ext[0] . '/load.php'; $ext_info = $this->get_extension_data($this->extensions_dir . $ext); if ($zip->status == 0) { do_action('after_load_extension'); return __('Extension', 'framework') . ' <b>' . $ext_info['Name'] . '</b> ' . __('has been installed. Do you want to activate it? ', 'framework') . ' <a href="admin.php?page=extensions&navigation=extension-activate&ext=' . $ext . '">' . __('Activate it', 'framework') . '</a>?'; } else { return __('Install error', 'framework') . ': ' . $zip->getStatusString(); } } } else { return __('Extensions directory must be writable', 'framework'); } } $overrides = array('test_form' => false, 'test_type' => false); $ext_file = wp_handle_upload($file, $overrides); if (isset($ext_file['error'])) { return '<b>' . __('ERROR', 'framework') . ':</b>' . $ext_file['error']; } else { if (is_writable($this->extensions_dir)) { $exploded = $exploded = explode('.', $file['name']); $ext = $exploded[0] . '/load.php'; if (!file_exists($this->extensions_dir . $ext)) { unzip_file($ext_file['file'], $this->extensions_dir); $ext_info = $this->get_extension_data($this->extensions_dir . $ext); unlink($ext_file['file']); } else { unlink($ext_file['file']); return __('Extension has already installed', 'framework'); } if ($zip->status == 0) { do_action('after_load_extension'); return __('The extension', 'framework') . ' <b>' . $ext_info['Name'] . '</b> ' . __('installed successfully. Would you like to', 'framework') . ' <a href="admin.php?page=extensions&navigation=extension-activate&ext=' . $ext . '">' . __('activate it now', 'framework') . '</a>?'; } else { return __('Install error', 'framework') . ': ' . $zip->getStatusString(); } } } }
/** * Creates a transport file for easily transferring Yaga configurations across * installs * * @param array An array containing the config areas to transfer * @param string Where to save the transport file * @return mixed False on failure, the path to the transport file on success */ protected function _ExportData($Include = array(), $Path = NULL) { $StartTime = microtime(TRUE); $Info = new stdClass(); $Info->Version = C('Yaga.Version', '?.?'); $Info->StartDate = date('Y-m-d H:i:s'); if (is_null($Path)) { $Path = PATH_UPLOADS . DS . 'export' . date('Y-m-d-His') . '.yaga.zip'; } $FH = new ZipArchive(); $Images = array(); $Hashes = array(); if ($FH->open($Path, ZipArchive::CREATE) !== TRUE) { $this->Form->AddError(sprintf(T('Yaga.Error.ArchiveCreate'), $FH->getStatusString())); return FALSE; } // Add configuration items $Info->Config = 'configs.yaga'; $Configs = Gdn::Config('Yaga', array()); unset($Configs['Version']); $ConfigData = serialize($Configs); $FH->addFromString('configs.yaga', $ConfigData); $Hashes[] = md5($ConfigData); // Add actions if ($Include['Action']) { $Info->Action = 'actions.yaga'; $Actions = Yaga::ActionModel()->Get('Sort', 'asc'); $this->SetData('ActionCount', count($Actions)); $ActionData = serialize($Actions); $FH->addFromString('actions.yaga', $ActionData); $Hashes[] = md5($ActionData); } // Add ranks and associated image if ($Include['Rank']) { $Info->Rank = 'ranks.yaga'; $Ranks = Yaga::RankModel()->Get('Level', 'asc'); $this->SetData('RankCount', count($Ranks)); $RankData = serialize($Ranks); $FH->addFromString('ranks.yaga', $RankData); array_push($Images, C('Yaga.Ranks.Photo'), NULL); $Hashes[] = md5($RankData); } // Add badges and associated images if ($Include['Badge']) { $Info->Badge = 'badges.yaga'; $Badges = Yaga::BadgeModel()->Get(); $this->SetData('BadgeCount', count($Badges)); $BadgeData = serialize($Badges); $FH->addFromString('badges.yaga', $BadgeData); $Hashes[] = md5($BadgeData); foreach ($Badges as $Badge) { array_push($Images, $Badge->Photo); } } // Add in any images $FilteredImages = array_filter($Images); $ImageCount = count($FilteredImages); $this->SetData('ImageCount', $ImageCount); if ($ImageCount > 0) { $FH->addEmptyDir('images'); } foreach ($FilteredImages as $Image) { if ($FH->addFile('.' . $Image, 'images/' . $Image) === FALSE) { $this->Form->AddError(sprintf(T('Yaga.Error.AddFile'), $FH->getStatusString())); //return FALSE; } $Hashes[] = md5_file('.' . $Image); } // Save all the hashes sort($Hashes); $Info->MD5 = md5(implode(',', $Hashes)); $Info->EndDate = date('Y-m-d H:i:s'); $EndTime = microtime(TRUE); $TotalTime = $EndTime - $StartTime; $m = floor($TotalTime / 60); $s = $TotalTime - $m * 60; $Info->ElapsedTime = sprintf('%02d:%02.2f', $m, $s); $FH->setArchiveComment(serialize($Info)); if ($FH->close()) { return $Path; } else { $this->Form->AddError(sprintf(T('Yaga.Error.ArchiveSave'), $FH->getStatusString())); return FALSE; } }
function wpa_wpc_get_db($zipfile, $zipmode) { $ret = array(); if ($zipmode || (!in_array('ZipArchive', get_declared_classes()) || !class_exists('ZipArchive'))) { wpa_wpc_log('extracting database using pclzip'); if (ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding')) { $previous_encoding = mb_internal_encoding(); mb_internal_encoding('ISO-8859-1'); } require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $z = new PclZip($zipfile); $database = $z->extract(PCLZIP_OPT_BY_NAME, 'wpclone_backup/database.sql', PCLZIP_OPT_EXTRACT_AS_STRING); $prefix = $z->extract(PCLZIP_OPT_BY_NAME, 'wpclone_backup/prefix.txt', PCLZIP_OPT_EXTRACT_AS_STRING); if (isset($previous_encoding)) { mb_internal_encoding($previous_encoding); } if ('ok' === $database[0]['status'] && 'ok' === $prefix[0]['status']) { $ret['database'] = $database[0]['content']; $ret['prefix'] = $prefix[0]['content']; } else { wpa_backup_error('pclunzip', $z->errorInfo(true), true); } return $ret; } else { $z = new ZipArchive(); if (true === $z->open($zipfile)) { wpa_wpc_log('extracting database using ziparchive'); $ret['database'] = $z->getFromName('wpclone_backup/database.sql'); $ret['prefix'] = $z->getFromName('wpclone_backup/prefix.txt'); if (false === $ret['database'] || false === $ret['prefix']) { wpa_backup_error('unzip', $z->getStatusString(), true); } $z->close(); return $ret; } else { wpa_backup_error('unzip', $z->getStatusString(), true); } } }
private function unpackArchive() { //Extract archive $status = true; $zip = new ZipArchive(); $targetPath = $this->uploadTargetPath . $this->baseFolderName; $zip->open($targetPath . 'dwca.zip'); if ($zip->extractTo($targetPath)) { //Get list of files $this->locateBaseFolder($targetPath); } else { $err = $zip->getStatusString(); if (!$err) { $err = 'target path is likely not a valid zip file'; } $this->outputMsg('<li>ERROR unpacking archive file: ' . $err . '</li>'); $this->errorStr = 'ERROR unpacking archive file: ' . $err; $status = false; } $zip->close(); return $status; }
private function unzipWithZipArchive($backupFile) { mwp_logger()->info('Falling back to ZipArchive Module'); $result = false; /** @handled class */ $zipArchive = new ZipArchive(); $zipOpened = $zipArchive->open($backupFile); if ($zipOpened === true) { $result = $zipArchive->extractTo(ABSPATH); $zipArchive->close(); } if ($result === false) { throw new Exception('Failed to unzip files with ZipArchive. Message: ' . $zipArchive->getStatusString()); } }
function zip($files, $archive) { $status = false; if (!extension_loaded('zip')) { return $status; } if (class_exists("ZipArchive")) { $zip = new ZipArchive(); if (!$zip->open($archive, 1)) { return $status; } if (!is_array($files)) { $files = array($files); } foreach ($files as $file) { $file = str_replace(get_cwd(), '', $file); $file = str_replace('\\', '/', $file); if (is_dir($file)) { $filesIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($file), 1); foreach ($filesIterator as $iterator) { $iterator = str_replace('\\', '/', $iterator); if (in_array(substr($iterator, strrpos($iterator, '/') + 1), array('.', '..'))) { continue; } if (is_dir($iterator)) { $zip->addEmptyDir(str_replace($file . '/', '', $iterator . '/')); } else { if (is_file($iterator)) { $zip->addFromString(str_replace($file . '/', '', $iterator), read_file($iterator)); } } } } elseif (is_file($file)) { $zip->addFromString(basename($file), read_file($file)); } } if ($zip->getStatusString() !== false) { $status = true; } $zip->close(); } return $status; }
/** * Throws an exception if the ZipArchive status is not OK. * * @param ZipArchive $zip * * @throws Oxygen_Exception */ private function checkStatus(ZipArchive $zip) { if ($zip->status !== ZipArchive::ER_OK) { throw new Oxygen_Exception(Oxygen_Exception::ARCHIVE_ZIP_EXTENSION_ERROR, array('code' => $zip->status, 'message' => $zip->getStatusString())); } }
private static function extractZip($file, $destDir) { $za = new ZipArchive(); $za->open($file); $entries = array(); for ($i = 0, $max = $za->numFiles; $i < $max; $i++) { $stat = $za->statIndex($i); // Skip files not at the top level if ($stat['name'] != basename($stat['name'])) { continue; } // Skip dot files or ztmp (which we use as temp dir) if ($stat['name'][0] == '.' || $stat['name'] == 'ztmp') { continue; } if (preg_match("/%ZB64\$/", $stat['name'])) { $filename = Z_Base64::decode(substr($stat['name'], 0, -5)); $filename = self::decodeRelativeDescriptorString($filename); $za->renameIndex($i, $filename); } else { $filename = $stat['name']; } $entries[] = $filename; } $success = $za->extractTo($destDir, $entries); $za->close(); if (!$success) { Z_Core::logError($za->getStatusString()); } return $success; }
private function uncompress($packages) { $zip = new ZipArchive(); foreach ($packages as $package) { if (!file_exists($package)) { continue; } echo sprintf($this->txt['uncompressing'], $package), "\n"; $zip->open($package); if ($zip->status != 0) { echo "\t", sprintf($this->txt['uncompress_error'], $zip->getStatusString()), "\n"; continue; } $zip->extractTo('.'); } }