当前位置: 首页>>代码示例>>PHP>>正文


PHP ZipArchive::close方法代码示例

本文整理汇总了PHP中ZipArchive::close方法的典型用法代码示例。如果您正苦于以下问题:PHP ZipArchive::close方法的具体用法?PHP ZipArchive::close怎么用?PHP ZipArchive::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZipArchive的用法示例。


在下文中一共展示了ZipArchive::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload

 /**
  * Upload component
  *
  * @requires component package file,
  *
  * @return bool;
  */
 public function upload()
 {
     $archive = new ZipArchive();
     $data_dir = ossn_get_userdata('tmp/components');
     if (!is_dir($data_dir)) {
         mkdir($data_dir, 0755, true);
     }
     $zip = $_FILES['com_file'];
     $newfile = "{$data_dir}/{$zip['name']}";
     if (move_uploaded_file($zip['tmp_name'], $newfile)) {
         if ($archive->open($newfile) === TRUE) {
             $archive->extractTo($data_dir);
             $archive->close();
             $validate = pathinfo($zip['name'], PATHINFO_FILENAME);
             if (is_file("{$data_dir}/{$validate}/ossn_com.php") && is_file("{$data_dir}/{$validate}/ossn_com.xml")) {
                 $archive->open($newfile);
                 $archive->extractTo(ossn_route()->com);
                 $archive->close();
                 $this->newCom($validate);
                 OssnFile::DeleteDir($data_dir);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:alibasli,项目名称:Social-Network-PHP-Joomla,代码行数:33,代码来源:OssnComponents.php

示例2: unzip_content

function unzip_content()
{
    $zip = new ZipArchive();
    if (file_exists('application.zip')) {
        $res = $zip->open('application.zip');
        if ($res === TRUE) {
            echo '<p>Unzipped Application <i class="fa fa-check-circle-o"></i></p>';
            $zip->extractTo('./');
            $zip->close();
            unlink('application.zip');
        } else {
            echo '<p>Could not unzip application.zip <i class="fa fa-times-circle-o"></i></p>';
        }
    } else {
        echo '<p>Application already unzipped <i class="fa fa-check-circle-o"></i></p>';
    }
    new_line();
    if (file_exists('content.zip')) {
        $res = $zip->open('content.zip');
        if ($res === TRUE) {
            echo '<p>Unzipped Content <i class="fa fa-check-circle-o"></i></p>';
            $zip->extractTo('./');
            $zip->close();
            unlink('content.zip');
        } else {
            echo '<p>Could not unzip content.zip <i class="fa fa-times-circle-o"></i></p>';
        }
    } else {
        echo '<p>Content already unzipped <i class="fa fa-check-circle-o"></i></p>';
    }
    new_line();
}
开发者ID:nvq247,项目名称:Kxexnxh,代码行数:32,代码来源:install.php

示例3: extract

 /**
  * @param string $to - path where the archive should be extracted to
  * @return bool
  */
 public function extract($to)
 {
     $r = false;
     $ext = SPFs::getExt($this->_filename);
     switch ($ext) {
         case 'zip':
             $zip = new ZipArchive();
             if ($zip->open($this->_filename) === true) {
                 SPException::catchErrors(SPC::WARNING);
                 try {
                     $zip->extractTo($to);
                     $zip->close();
                     $r = true;
                 } catch (SPException $x) {
                     $t = Sobi::FixPath(Sobi::Cfg('fs.temp') . DS . md5(microtime()));
                     SPFs::mkdir($t, 0777);
                     $dir = SPFactory::Instance('base.fs.directory', $t);
                     if ($zip->extractTo($t)) {
                         $zip->close();
                         $dir->moveFiles($to);
                         $r = true;
                     }
                     SPFs::delete($dir->getPathname());
                 }
                 SPException::catchErrors(0);
             }
             break;
     }
     return $r;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:34,代码来源:archive.php

示例4: upload

 /**
  * Upload component
  *
  * @requires component package file,
  *
  * @return bool;
  */
 public function upload()
 {
     $archive = new ZipArchive();
     $data_dir = ossn_get_userdata('tmp/components');
     if (!is_dir($data_dir)) {
         mkdir($data_dir, 0755, true);
     }
     $zip = $_FILES['com_file'];
     $newfile = "{$data_dir}/{$zip['name']}";
     if (move_uploaded_file($zip['tmp_name'], $newfile)) {
         if ($archive->open($newfile) === TRUE) {
             $archive->extractTo($data_dir);
             //make community components works on installer #394
             $validate = $archive->statIndex(0);
             $validate = str_replace('/', '', $validate['name']);
             $archive->close();
             if (is_dir("{$data_dir}/{$validate}") && is_file("{$data_dir}/{$validate}/ossn_com.php") && is_file("{$data_dir}/{$validate}/ossn_com.xml")) {
                 $archive->open($newfile);
                 $archive->extractTo(ossn_route()->com);
                 $archive->close();
                 $this->newCom($validate);
                 OssnFile::DeleteDir($data_dir);
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:aidovoga,项目名称:opensource-socialnetwork,代码行数:35,代码来源:OssnComponents.php

示例5: extractArchive

 private function extractArchive()
 {
     $this->archive->close();
     $this->archive->open($this->archive_path);
     $this->archive->extractTo($this->extraction_path);
     $this->archive->close();
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:ArtifactAttachmentExporterTest.php

示例6: fileValid

 /**
  * Validate file
  *
  * @param array $file
  * @param int $max_file_size MB
  * @param string $allowed_file_extension
  * @return bool TRUE if valid ot FALSE if else
  */
 public static function fileValid($file, $max_file_size, $allowed_file_extension)
 {
     // Dependencies test
     if (!isset($file['tmp_name']) || !isset($file['name'])) {
         return false;
     } else {
         if (empty($file['tmp_name']) || empty($file['name'])) {
             return false;
         } else {
             // Common test
             if (mb_strtolower($allowed_file_extension) != @pathinfo(self::_extensionPrepare($file['name']), PATHINFO_EXTENSION)) {
                 return false;
             } else {
                 if ($max_file_size < @filesize($file['tmp_name']) / 1000000) {
                     return false;
                 }
             }
             // Extension test
             if (mb_strtolower($allowed_file_extension) == 'zip') {
                 $zip = new ZipArchive();
                 if (true !== $zip->open($file['tmp_name'], ZipArchive::CHECKCONS)) {
                     $zip->close();
                     return false;
                 }
                 $zip->close();
             }
         }
     }
     return true;
 }
开发者ID:RustyNomad,项目名称:bitsybay,代码行数:38,代码来源:upload.php

示例7: downloaded

 public function downloaded()
 {
     $messagebox = new QMessageBox();
     if ($this->progressBar->value != $this->progressBar->maximum) {
         $this->hide();
         $messagebox->critical(0, tr('PQCreator error'), tr('Error download PQPack! :-( Please, try later...'), tr('Quit'));
         qApp::quit();
     }
     $this->textEdit->html .= "\n" . tr('Writing in file...');
     file_put_contents($this->tempFilePath, $this->downloader->downloadedData());
     $this->textEdit->html .= "\n" . sprintf(tr('Unzip data in `%s`'), $this->destinationDir);
     $zip = new ZipArchive();
     if ($zip->open($this->tempFilePath) === TRUE) {
         if (!mkdir($this->destinationDir)) {
             $this->hide();
             $messagebox->critical(0, tr('PQCreator error'), sprintf(tr('Error creating directory `%s`!'), $this->destinationDir), tr('Quit'));
             $zip->close();
             qApp::quit();
         }
         $zip->extractTo($this->destinationDir);
         $zip->close();
         $this->textEdit->html .= "\n<b>" . tr('Done!') . '</b>';
         $this->button->enabled = true;
         $messagebox->free();
         unset($messagebox);
         qApp::beep();
         return;
     }
     $this->hide();
     $messagebox->critical(0, tr('PQCreator error'), sprintf(tr('Error unzip PQPack package `%s`!'), $this->tempFilePath), tr('Quit'));
     qApp::quit();
 }
开发者ID:ArtMares,项目名称:pqstudio,代码行数:32,代码来源:PQDownloader.php

示例8: closeArchive

 /**
  * Closes the archive
  */
 protected function closeArchive()
 {
     if ($this->zip) {
         $this->zip->close();
         $this->zip = null;
     }
 }
开发者ID:stof,项目名称:spreadsheet-parser,代码行数:10,代码来源:Archive.php

示例9: tearDown

 public function tearDown()
 {
     $this->zip->close();
     $this->archive->cleanUp();
     //`rm -rf $this->tmp_dir/import_project_*`;
     parent::tearDown();
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:7,代码来源:XMLImportZipArchiveTest.php

示例10: closeReader

 /**
  * Closes the reader. To be used after reading the file.
  *
  * @return void
  */
 protected function closeReader()
 {
     if ($this->zip) {
         $this->zip->close();
     }
     if ($this->sharedStringsHelper) {
         $this->sharedStringsHelper->cleanup();
     }
 }
开发者ID:cheaterBY,项目名称:spout,代码行数:14,代码来源:Reader.php

示例11: finalize

 /**
  * Finalize the xlsx file.
  *
  * @param resource $output
  */
 public function finalize($output)
 {
     $zipFileUrl = sys_get_temp_dir() . '/' . uniqid();
     $this->fillZipWithFileContents($zipFileUrl);
     if (!$this->zip->close()) {
         throw new \RuntimeException('Failed to close zip file!');
     }
     $this->copyToOutputAndCleanup($output, $zipFileUrl);
 }
开发者ID:nimmneun,项目名称:onesheet,代码行数:14,代码来源:Finalizer.php

示例12: finishAndGetDocument

 /**
  * @return string
  */
 public function finishAndGetDocument()
 {
     $content = $this->create();
     $this->zip->deleteName('content.xml');
     $this->zip->addFromString('content.xml', $content);
     $this->zip->close();
     $content = file_get_contents($this->tmpZipFile);
     unlink($this->tmpZipFile);
     return $content;
 }
开发者ID:CatoTH,项目名称:html2opendocument,代码行数:13,代码来源:Base.php

示例13: save

 /**
  * Saves file
  *
  * @param $filename
  *
  * @throws \Exception
  */
 public function save($filename)
 {
     if (isset($this->contents)) {
         $this->zip->addFromString('word/document.xml', $this->contents);
     }
     $this->zip->close();
     $res = @rename($this->tempFilename, $filename);
     if (!$res) {
         throw new \Exception("Unable to save file");
     }
 }
开发者ID:silverslice,项目名称:docx-template,代码行数:18,代码来源:Template.php

示例14: setUp

 protected function setUp()
 {
     if (!extension_loaded('zip')) {
         $this->markTestSkipped('The zip extension is not available');
     }
     $this->zipFile = new \ZipArchive();
     $this->zipFile->open($this->zipFilename, \ZipArchive::CREATE);
     $this->zipFile->addFromString($this->filename, $this->fileContents);
     $this->zipFile->close();
     $this->collection = new ResourceCollection([new FileResource(FileTransport::create($this->zipFilename))]);
 }
开发者ID:treehouselabs,项目名称:feeder,代码行数:11,代码来源:UnzipTransformerTest.php

示例15: load

 private function load($file)
 {
     if (file_exists($file)) {
         $zip = new ZipArchive();
         if ($zip->open($file) === true) {
             //attempt to load styles:
             if (($styleIndex = $zip->locateName('word/styles.xml')) !== false) {
                 $stylesXml = $zip->getFromIndex($styleIndex);
                 $xml = simplexml_load_string($stylesXml);
                 $namespaces = $xml->getNamespaces(true);
                 $children = $xml->children($namespaces['w']);
                 foreach ($children->style as $s) {
                     $attr = $s->attributes('w', true);
                     if (isset($attr['styleId'])) {
                         $tags = array();
                         $attrs = array();
                         foreach (get_object_vars($s->rPr) as $tag => $style) {
                             $att = $style->attributes('w', true);
                             switch ($tag) {
                                 case "b":
                                     $tags[] = 'strong';
                                     break;
                                 case "i":
                                     $tags[] = 'em';
                                     break;
                                 case "color":
                                     //echo (String) $att['val'];
                                     $attrs[] = 'color:#' . $att['val'];
                                     break;
                                 case "sz":
                                     $attrs[] = 'font-size:' . $att['val'] . 'px';
                                     break;
                             }
                         }
                         $styles[(string) $attr['styleId']] = array('tags' => $tags, 'attrs' => $attrs);
                     }
                 }
                 $this->styles = $styles;
             }
             if (($index = $zip->locateName('word/document.xml')) !== false) {
                 // If found, read it to the string
                 $data = $zip->getFromIndex($index);
                 // Close archive file
                 $zip->close();
                 return $data;
             }
             $zip->close();
         } else {
             $this->errors[] = 'Could not open file.';
         }
     } else {
         $this->errors[] = 'File does not exist.';
     }
 }
开发者ID:rinteresting,项目名称:Docx-to-HTML,代码行数:54,代码来源:docx_reader.php


注:本文中的ZipArchive::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。