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


PHP Zip::setComment方法代码示例

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


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

示例1: date

<?php
// Example. Zip all .html files in the current directory and send the file for Download.
$fileDir = './';

include_once("Zip.php");
$fileTime = date("D, d M Y H:i:s T");

$zip = new Zip();
$zip->setComment("Example Zip file.\nCreated on " . date('l jS \of F Y h:i:s A'));
$zip->addFile("Hello World!", "hello.txt");

if ($handle = opendir($fileDir)) {
	/* This is the correct way to loop over the directory. */
	while (false !== ($file = readdir($handle))) {
		if (strpos($file, ".html") !== false) {
			$pathData = pathinfo($fileDir . $file);
			$fileName = $pathData['filename'];

			$zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file));
		}
	}
}

$zip->sendZip("ZipExample1a.zip");
?>
开发者ID:sg4r3z,项目名称:umvc,代码行数:25,代码来源:Zip.Example1a.php

示例2: date

<?php
// Example. Zip all .html files in the current directory and send the file for Download.
// Also adds a static text "Hello World!" to the file Hello.txt
$fileDir = './';
ob_start(); // This is only to show that ob_start can be called, however the buffer must be empty when sending.

include_once("Zip.php");
$fileTime = date("D, d M Y H:i:s T");

$zip = new Zip();
// Archive comments don't really support utf-8. Some tools detect and read it though.
$zip->setComment("Example Zip file.\nАрхив Комментарий\nCreated on " . date('l jS \of F Y h:i:s A'));
// A bit of russian (I hope), to test UTF-8 file names.
$zip->addFile("Привет мир!", "Кириллица имя файла.txt");
$zip->addFile("Привет мир!", "Привет мир. С комментарий к файлу.txt", 0, "Кириллица файл комментарий");
$zip->addFile("Hello World!", "hello.txt");

@$handle = opendir($fileDir);
if ($handle) {
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        if (strpos($file, ".php") !== false) {
            $pathData = pathinfo($fileDir . $file);
            $fileName = $pathData['filename'];

            $zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file), NULL, TRUE, Zip::getFileExtAttr($file));
        }
    }
}

// Add a directory, first recursively, then the same directory, but without recursion.
开发者ID:sg4r3z,项目名称:umvc,代码行数:31,代码来源:Zip.Example1.php

示例3: createDownloadPackage


//.........这里部分代码省略.........
						'item_id'   => $documentId,
						'doc_id'    => $documentId,
						'value'     => $fileObject->size,
						'reference' => $fileId . ($version ? ':' . $version : '')
					);

					JUDownloadFrontHelperLog::addLog($logData);
				}
			}
		}
		// Only support download file/document, invalid type -> return false
		else
		{
			return false;
		}

		$serverTime      = JFactory::getDate()->toSql();
		$serverTimeStamp = strtotime($serverTime);

		// Store ID of download file(s) into session
		if ($noCountingDownloadSecond > 0)
		{
			$storeIdArray                   = (array) $app->getUserState('com_judownload.download.storeid');
			$storeIdArray[$serverTimeStamp] = $storeId;
			$storeIdArray                   = array_unique($storeIdArray);
			$app->setUserState('com_judownload.download.storeid', $storeIdArray);
		}

		// Last download time to calculate download interval
		$session = JFactory::getSession();
		$session->set('judl-last-download-time', $serverTime);

		// If use zip class to zip files, set comment then close the archive
		if ($zipFile)
		{
			// Set comment for zip file
			$zip->setComment($zipComment);

			// Close the archive
			$zip->finalize();
		}

		// Send email by event for each document when download
		$docIdArray = array();
		if ($type == 'file')
		{
			$docIdArray[] = $parentId;
		}
		else
		{
			$docIdArray = $itemIdArray;
		}

		$docIdArray = array_unique($docIdArray);
		//Send mail by event
		foreach ($docIdArray AS $docId)
		{
			JUDownloadFrontHelperMail::sendEmailByEvent('document.download', $docId);
		}

		// Download ZIPPED file
		if ($zipFile)
		{
			// Directly download(from zip resource by PHP)
			$resourceFilePath   = $zip->getZipFile();
			$transport          = 'php';
			$speed              = (int) $params->get('max_download_speed', 200);
			$resume             = $params->get('resume_download', 1);
			$downloadMultiParts = $params->get('download_multi_parts', 1);

			$downloadResult = JUDownloadHelper::downloadFile($resourceFilePath, $zipFileName, $transport, $speed, $resume, $downloadMultiParts);

			if ($downloadResult !== true)
			{
				$this->setError($downloadResult);

				return false;
			}
		}
		// Download ONE NO ZIPPED file, in this case $zipFileName is the download file name, file can be zip file or not
		else
		{
			// Directly download
			$transport          = $downloadOneFileNoZippedMode;
			$speed              = (int) $params->get('max_download_speed', 200);
			$resume             = $params->get('resume_download', 1);
			$downloadMultiParts = $params->get('download_multi_parts', 1);

			$downloadResult = JUDownloadHelper::downloadFile($physicalFilePath, $zipFileName, $transport, $speed, $resume, $downloadMultiParts);

			if ($downloadResult !== true)
			{
				$this->setError($downloadResult);

				return false;
			}
		}

		return true;
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:download.php


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