本文整理汇总了PHP中Zip::addDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::addDirectory方法的具体用法?PHP Zip::addDirectory怎么用?PHP Zip::addDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::addDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDownloadPackage
public function createDownloadPackage($type, $itemIdArray, $parentId, $version)
{
$app = JFactory::getApplication();
// If set no_counting_download_time, storeId will be used to check if download file in "no counting download" period
sort($itemIdArray);
$storeId = md5($type . serialize($itemIdArray) . $version);
if ($type == 'document')
{
$params = JUDownloadHelper::getParams($parentId);
}
else
{
$params = JUDownloadHelper::getParams(null, $parentId);
}
$noCountingDownloadSecond = (int) $params->get('no_counting_download_time', 300);
if ($noCountingDownloadSecond > 0)
{
$storeIdArray = (array) $app->getUserState('com_judownload.download.storeid');
}
else
{
$storeIdArray = array();
}
$user = JFactory::getUser();
$downloadZippedFileMode = $params->get('download_zipped_file_mode', 'temp');
$downloadOneFileNoZippedMode = $params->get('download_one_file_no_zipped_mode', 'temp');
// Min download speed.
$minDownloadSpeed = (int) $params->get('min_download_speed', 10);
$minDownloadSpeed = $minDownloadSpeed > 0 ? $minDownloadSpeed : 10;
$minDownloadSpeed = $minDownloadSpeed * 1024; //KBps
// Min live time of download package.
$adjustFileLiveTime = (int) $params->get('adjust_file_live_time', 60);
$adjustFileLiveTime = $adjustFileLiveTime >= 0 ? $adjustFileLiveTime : 60;
// Time download package created.
$createdTimeDate = JFactory::getDate()->toSql();
$createdTimeStamp = strtotime($createdTimeDate);
// Trigger JU Download after download
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('judownload');
// Physical file path to download, to be used in temp folder mode
$downloadFilePath = '';
// True if file is zipped by zip class
$zipFile = false;
// Get comment for zip package.
$zipCommentConfig = $params->get('zip_comment', '');
// Zip comment parsed from $zipCommentConfig case by case
$zipComment = '';
if ($type == 'document')
{
// Get category id.
$categoryId = $parentId;
$documentIdArray = $itemIdArray;
// Download multi documents in the same cat
if (count($documentIdArray) > 1)
{
// In this case : user downloading category.
// Sort array document id.
sort($documentIdArray);
// Create zip package.
$zip = new Zip();
$zipFile = true;
// Parse zip comment
$zipComment = $this->parseCommentTxt($zipCommentConfig, $categoryId);
// File id array in all download documents to reference in tmp file table
$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);
//.........这里部分代码省略.........
示例2: die
function export_and_download_layouts()
{
if (isset($_POST['export_and_download'])) {
$nonce = $_POST["wp_nonce_export_layouts"];
if (WPDD_Utils::user_not_admin()) {
die(__("You don't have permission to perform this action!", 'ddl-layouts'));
}
if (wp_verify_nonce($nonce, 'wp_nonce_export_layouts')) {
$results = $this->export_for_download();
$sitename = sanitize_key(get_bloginfo('name'));
if (!empty($sitename)) {
$sitename .= '.';
}
require_once WPDDL_TOOLSET_COMMON_ABSPATH . '/Zip.php';
if (class_exists('Zip')) {
$dirname = $sitename . 'dd-layouts.' . date('Y-m-d');
$zipName = $dirname . '.zip';
$zip = new Zip();
$zip->addDirectory($dirname);
foreach ($results as $file_data) {
$zip->addFile($file_data['file_data'], $dirname . '/' . $file_data['file_name']);
}
$zip->sendZip($zipName);
}
}
die;
}
}
示例3: define
function download_project()
{
define('WP_MEMORY_LIMIT', '1024M');
ini_set('memory_limit', '1024M');
global $wpdb, $current_user;
if (!is_user_logged_in()) {
exit;
}
$pid = $_GET['id'];
$zip = new Zip();
$folders = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id = %d", $pid), ARRAY_A);
$zip_dir = "" . SP_CDM_UPLOADS_DIR . "" . AUTH_KEY . "/";
$zip_path = '' . SP_CDM_UPLOADS_DIR_URL . '' . AUTH_KEY . '/';
if (!is_dir($zip_dir)) {
mkdir($zip_dir, 0777);
}
$return_file = "" . preg_replace('/[^\\w\\d_ -]/si', '', sanitize_title($folders[0]['name'])) . "-" . time() . ".zip";
#echo "SELECT * FROM " . $wpdb->prefix . "sp_cu_project where id IN(".$folders_id.") order by name ";
#print_r($folders);
for ($j = 0; $j < count($folders); $j++) {
$zip->addDirectory($this->folder_name($folders[$j]['id']));
$r = $this->folder_files($folders[$j]['id']);
for ($i = 0; $i < count($r); $i++) {
$dir = '' . SP_CDM_UPLOADS_DIR . '' . $r[$i]['uid'] . '/';
$zip->addFile($this->get_file($dir . $r[$i]['file']), $this->folder_name($folders[$j]['id']) . '/' . $r[$i]['file'], filectime($dir . $r[$i]['file']));
unset($dir);
}
$this->sub_folders($folders[$j]['id'], $this->folder_name($folders[$j]['id']), $zip);
}
$zip->finalize();
// as we are not using getZipData or getZipFile, we need to call finalize ourselves.
$zip->setZipFile($zip_dir . $return_file);
header("Location: " . $zip_path . $return_file . "");
}