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


PHP ZipArchive::unchangeAll方法代码示例

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


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

示例1: undo

 /**
  * Undo the last actions on the open zip file.
  * @param string $mixed
  * @return boolean @params mixed $mixed : undo changes to an archive by index(int), name(string), all ('all' | '*' | blank) usage : $this->Zip->undo(1); $this->Zip->undo('myText.txt'); $this->Zip->undo('*'); $this->Zip->undo('myText.txt, myText1.txt'); $this->Zip->undo(array(1, 'myText.txt'));
  */
 function undo($mixed = '*')
 {
     if (is_array($mixed)) {
         foreach ($mixed as $value) {
             $constant = is_string($value) ? 'Name' : 'Index';
             if (!$this->zip->{'unchange' . $constant}($value)) {
                 return false;
             }
         }
     } else {
         $mixed = explode(',', $mixed);
         if (in_array($mixed[0], ['*', 'all'])) {
             if (!$this->zip->unchangeAll()) {
                 return false;
             }
         } else {
             foreach ($mixed as $name) {
                 if (!$this->zip->unchangeName($name)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:amitpatelsufalamtech,项目名称:cakephp-zip-component,代码行数:30,代码来源:ZipComponent.php

示例2: fopen

         $input = fopen($url, 'r');
         if (!file_put_contents($uploadfilename, $input)) {
             $smarty->assign("MODULEIMPORT_FAILED", "true");
             $uploadfilename = null;
         }
     }
 }
 if ($uploadfilename) {
     // Check ZIP file contents for extra directory at the top
     $za = new ZipArchive();
     $za->open($uploadfilename);
     for ($i = 0; $i < $za->numFiles; $i++) {
         $entryName = $za->getNameIndex($i);
         $firstSlash = strpos($entryName, '/');
         if ($entryName === 'manifest.xml' || $entryName === './manifest.xml' || $firstSlash === false) {
             $za->unchangeAll();
             break;
         }
         $newEntryName = substr($entryName, $firstSlash + 1);
         if ($newEntryName !== false) {
             $za->renameIndex($i, $newEntryName);
         } else {
             $za->deleteIndex($i);
         }
     }
     $za->close();
     $package = new Vtiger_Package();
     $moduleimport_name = $package->getModuleNameFromZip($uploadfilename);
     if ($moduleimport_name == null) {
         $smarty->assign("MODULEIMPORT_FAILED", "true");
         $smarty->assign("MODULEIMPORT_FILE_INVALID", "true");
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:31,代码来源:Import.php

示例3: addEmptyDir

 /**
  * @info is public for PHP 5.3 compatibility, should be private
  */
 public function addEmptyDir(\ZipArchive $zip, $dir)
 {
     if (!$zip->addEmptyDir($dir)) {
         $zip->unchangeAll();
         $zip->close();
         throw new RuntimeException(sprintf('unable to add %s to the zip file', $dir));
     }
 }
开发者ID:JimmDiGrizli,项目名称:Zippy,代码行数:11,代码来源:ZipExtensionAdapter.php

示例4: array

 /**
  * Create a zip archive using the ZipArchive class
  *
  * You should not use this function directly. Use the 'zip' function above.
  *
  * @param  array  $sources     List of paths to files and directories to be archived.
  * @param  string $destination Destination file where the archive will be stored.
  * @param  array  $exclude     Directories and/or files to exclude from archive, defaults to empty array.
  * @return mixed               Returns TRUE on success or an instance of WP_Error on failure.
  */
 function _zip_create_ziparchive($sources, $destination, $exclude = array())
 {
     $zip = new ZipArchive();
     if ($res = $zip->open($destination, ZIPARCHIVE::CREATE) != true) {
         return new WP_Error('ziparchive', $res);
     }
     foreach ($sources as $source) {
         if (!@is_readable($source)) {
             continue;
         }
         if (@is_dir($source)) {
             $files = directory_list($source, true, $exclude);
             if (is_wp_error($files)) {
                 $zip->unchangeAll();
                 if (file_exists($destination)) {
                     delete_path($destination);
                 }
                 return $files;
             }
             foreach ($files as $file) {
                 if (!@is_readable($file)) {
                     continue;
                 }
                 if (@is_dir($file)) {
                     $zip->addEmptyDir(str_replace(parent_dir($source) . '/', '', $file . '/'));
                 } elseif (@is_file($file)) {
                     $zip->addFile($file, str_replace(parent_dir($source) . '/', '', $file));
                 }
             }
         } elseif (@is_file($source)) {
             $zip->addFile($source, basename($source));
         }
     }
     $num_files = $zip->numFiles;
     $zip_result = $zip->close();
     if (!$zip_result) {
         return new WP_Error('zip', "Could not properly close archive '" . $destination . "'.");
     }
     return $num_files;
 }
开发者ID:DylanGroenewoud,项目名称:PVNG,代码行数:50,代码来源:functions.php


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