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


PHP Zip::addLargeFile方法代码示例

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


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

示例1: getArchive

 /**
  * Creates a new archive with the specified name and files
  * @param string $name Path to the archive with name and extension
  * @param array $files A numeric array of files
  * @param string $replace
  * @return int How many files has been successfully handled
  */
 public function getArchive($name, array $files, $replace = ABSPATH)
 {
     set_time_limit(300);
     if (!class_exists('Zip', false)) {
         /** @var backupBup $backup */
         $backup = $this->getModule();
         $backup->loadLibrary('zip');
     }
     $zip = new Zip();
     $zip->setZipFile($name);
     foreach ($files as $file) {
         $filename = str_replace($replace, '', $file);
         if (file_exists($file) && is_readable($file) && (substr(basename($file), 0, 3) != 'pcl' && substr($file, -2) != 'gz')) {
             $stream = @fopen($file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, $filename);
             }
         }
     }
     $zip->finalize();
     /* backward */
     return rand(100, 1000);
 }
开发者ID:VSVS,项目名称:vs_wp_4.0,代码行数:30,代码来源:filesystem.php

示例2: ZipArchive

     $flush_me .= hesk_date() . " | {$hesklang['cZIP']}<br />\n";
     // Preferrably use the zip extension
     if (extension_loaded('zip')) {
         $save_to_zip = $export_dir . $export_name . '.zip';
         $zip = new ZipArchive();
         $res = $zip->open($save_to_zip, ZipArchive::CREATE);
         if ($res === TRUE) {
             $zip->addFile($save_to, "{$export_name}.xml");
             $zip->close();
         } else {
             die("{$hesklang['eZIP']} <{$save_to_zip}>\n");
         }
     } elseif (class_exists('ZipArchive')) {
         require HESK_PATH . 'inc/zip/Zip.php';
         $zip = new Zip();
         $zip->addLargeFile($save_to, "{$export_name}.xml");
         $zip->finalize();
         $zip->setZipFile($save_to_zip);
     } else {
         require HESK_PATH . 'inc/zip/pclzip.lib.php';
         $zip = new PclZip($save_to_zip);
         $zip->add($save_to, PCLZIP_OPT_REMOVE_ALL_PATH);
     }
     // Delete XML, just leave the Zip archive
     hesk_unlink($save_to);
     // Echo memory peak usage
     $flush_me .= hesk_date() . " | " . sprintf($hesklang['pmem'], @memory_get_peak_usage(true) / 1048576) . "<br />\r\n";
     // We're done!
     $flush_me .= hesk_date() . " | {$hesklang['fZIP']}<br /><br />";
     $flush_me .= '<a href="' . $save_to_zip . '">' . $hesklang['ch2d'] . "</a>\n";
 } else {
开发者ID:riansopian,项目名称:hesk,代码行数:31,代码来源:export.php

示例3: backup_items

 public function backup_items($items)
 {
     $dir = SNS_BACKUPS_PATH . $this->filename;
     if (!class_exists('Zip', false)) {
         require_once SNS_LIB_PATH . 'Zip.php';
     }
     $warns = array('not_readable' => array());
     $zip = new Zip();
     $zip->setZipFile($dir . '.zip');
     self::$zipFile = $zip;
     foreach ($items as $name => $path) {
         if ($name == Sns_Option::DB) {
             $sql_file = SNS_BACKUPS_PATH . 'wp_dump.sql';
             Sns_Log::log_action('Exporting DB');
             Sns_Backup::export_db($sql_file);
             Sns_Log::log_action('Exporting DB', SNS_LOG_END);
             $stream = @fopen($sql_file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, 'wp_dump.sql');
             }
             @unlink($sql_file);
             continue;
         }
         Sns_Log::log_action('Backup item - ' . $name);
         $itemZip = new Zip();
         $itemZip->setZipFile(SNS_BACKUPS_PATH . $name . '.zip');
         $path = realpath($path);
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS));
         $exclude = array(realpath(SNS_BACKUP_ROOT), realpath(SNS_BACKUPS_PATH), realpath(WP_CONTENT_DIR . SNS_DS . 'debug.log'));
         for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
             $file = $iterator->current();
             $continue = false;
             foreach ($exclude as $excludeFile) {
                 if (strpos($file, $excludeFile) !== false) {
                     $continue = true;
                 }
             }
             if ($continue) {
                 continue;
             }
             if (file_exists($file) && is_readable($file)) {
                 $stream = @fopen($file, 'rb');
                 if ($stream) {
                     $file = substr($file, strlen($path));
                     $itemZip->addLargeFile($stream, $file);
                 }
             } else {
                 $warns['not_readable'][] = $file;
             }
         }
         $itemZip->finalize();
         $stream = @fopen(SNS_BACKUPS_PATH . $name . '.zip', 'rb');
         if ($stream) {
             $zip->addLargeFile($stream, $name . '.zip');
         }
         @unlink(SNS_BACKUPS_PATH . $name . '.zip');
         Sns_Log::log_action('Backup item - ' . $name, SNS_LOG_END);
     }
     Sns_Log::log_action('Summarize item backups');
     $zip->finalize();
     Sns_Log::log_action('Summarize item backups', SNS_LOG_END);
     $this->hash;
     $this->filename;
     $this->save();
     return $warns;
 }
开发者ID:eugenehiggins,项目名称:wordpress-intermediate,代码行数:66,代码来源:Sns_Backup.php

示例4: getArchive

 /**
  * Creates a new archive with the specified name and files
  * @param string $name Path to the archive with name and extension
  * @param array $files A numeric array of files
  * @param string $replace
  * @param string $fullPath
  * @return int How many files has been successfully handled
  */
 public function getArchive($name, array $files, $replace = ABSPATH, $fullPath = false)
 {
     set_time_limit(300);
     if (!class_exists('Zip', false)) {
         /** @var backupBup $backup */
         $backup = $this->getModule();
         $backup->loadLibrary('zip');
     }
     $zip = new Zip();
     $zip->setZipFile($name);
     if ($fullPath) {
         $absPath = null;
     } else {
         $absPath = str_replace('/', DS, ABSPATH);
     }
     foreach ($files as $filename) {
         $file = $absPath . $filename;
         if ($fullPath) {
             $file = str_replace('\\\\', DS, $filename);
         }
         if (file_exists($file) && is_readable($file) && (substr(basename($file), 0, 3) != 'pcl' && substr($file, -2) != 'gz')) {
             $stream = @fopen($file, 'rb');
             if ($stream) {
                 $zip->addLargeFile($stream, $filename);
             }
         }
     }
     $zip->finalize();
     if (false !== strpos($name, 'backup_')) {
         // if backup created - remove all temporary files from tmp directory
         $this->clearTmpDirectory();
     }
     /* backward */
     return rand(100, 1000);
 }
开发者ID:carlyns,项目名称:RESUSblog,代码行数:43,代码来源:filesystem.php

示例5: createDownloadPackage


//.........这里部分代码省略.........
				$fileIdArrayInTmpZip = array();
				foreach ($documentIdArray AS $documentId)
				{
					$documentObject = JUDownloadHelper::getDocumentById($documentId);
					$documentTitle  = $this->filterFileFolderName($documentObject->title);
					$documentTitle  = trim($documentTitle);
					$fileObjectList = $this->getAllFilesOfDocument($documentId);
					// If document has file, add document title as a folder contains files
					if (count($fileObjectList))
					{
						$zip->addDirectory($documentTitle);
					}

					// File id array in document to log document.download
					$fileIdArray  = array();
					$documentSize = 0;
					foreach ($fileObjectList AS $fileObject)
					{
						$physicalFilePath = $this->getPhysicalFilePath($fileObject->id);

						if (JFile::exists($physicalFilePath))
						{
							$filePathInZip = $documentTitle . '/' . $this->filterFileFolderName($fileObject->rename);

							// Add file extension to file path, if the extension is not the same original file
							$fileExtOri   = JFile::getExt($physicalFilePath);
							$fileExtInZip = JFile::getExt($filePathInZip);
							if ($fileExtInZip != $fileExtOri)
							{
								$filePathInZip = $filePathInZip . '.' . $fileExtOri;
							}
							$filePathInZip = trim($filePathInZip);

							$zip->addLargeFile($physicalFilePath, $filePathInZip);
							$documentSize += $fileObject->size;
							if (!in_array($storeId, $storeIdArray))
							{
								$this->updateFileDownloadCounter($fileObject->id);
							}
						}
						$fileIdArray[]         = $fileObject->id;
						$fileIdArrayInTmpZip[] = $fileObject->id;
					}

					if (!in_array($storeId, $storeIdArray))
					{
						$this->updateDocumentDownloadCounter($documentId);

						$dispatcher->trigger('onAfterDownloadDocument', array($documentId, $fileIdArray, $documentSize));

						// Add log when download
						$logData = array(
							'user_id'   => $user->id,
							'event'     => 'document.download',
							'item_id'   => $documentId,
							'doc_id'    => $documentId,
							'value'     => $documentSize,
							'reference' => implode(',', $fileIdArray)
						);

						JUDownloadFrontHelperLog::addLog($logData);
					}
				}
				// End - Zip file

				$categoryObject = JUDownloadHelper::getCategoryById($categoryId);
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:67,代码来源:download.php


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