本文整理汇总了PHP中File_Archive::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP File_Archive::setOption方法的具体用法?PHP File_Archive::setOption怎么用?PHP File_Archive::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File_Archive
的用法示例。
在下文中一共展示了File_Archive::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportUploadedFiles
function exportUploadedFiles($gid)
{
require_once "File/Archive.php";
File_Archive::setOption('zipCompressionLevel', 0);
$baseDir = CUSTOMER_IMAGE_DIR . $gid;
$files = list_files_dir($baseDir);
File_Archive::extract($files, File_Archive::toArchive("campaign_" . $gid . "_uploadedfiles_" . date('dFY') . ".zip", File_Archive::toOutput()));
}
示例2: catch
<?php
/**
* FIXME ... just fixme, like 99% of it. Count this as a draft or something.
*
*
*
* @package test
*
* Trying out File_Archive
*/
require_once '../../autoload.php';
try {
Module::require('File_Archive');
} catch (Exception $e) {
die('Script requires PEAR File_Archive to work.');
}
// Set cache dir for Cache Lite
$options = array('cacheDir' => 'tmp');
if (Module::isLoaded('Cache_Lite')) {
File_Archive::setOption('cache', new Cache_Lite($options));
}
File_Archive::setOption('zipCompressionLevel', 0);
// $files is an array of path to the files that must be added to the archive
File_Archive::extract($files, File_Archive::toArchive('myFiles.zip', File_Archive::toOutput()));
示例3: _fullBackUp
//.........这里部分代码省略.........
$webappDirHandle = opendir(WEBAPP_DIR);
while (false !== ($file = readdir($webappDirHandle))) {
if ($file == '.' || $file == '..' || $file == 'config' || $file == 'style' || $file == 'uploads' || $file == 'templates_c') {
continue;
}
$filePath = WEBAPP_DIR . '/' . $file;
$source[] = File_Archive::read($filePath, $archiveDir . basename(WEBAPP_DIR) . '/' . $file);
}
closedir($webappDirHandle);
$configDirHandle = opendir(WEBAPP_DIR . '/config');
while (false !== ($file = readdir($configDirHandle))) {
if ($file == '.' || $file == '..') {
continue;
}
if ($file == 'install.inc.php') {
$filePath = WEBAPP_DIR . '/config/install.inc.dist.php';
$source[] = File_Archive::read($filePath, $archiveDir . basename(WEBAPP_DIR) . '/config/install.inc.php');
continue;
}
$filePath = WEBAPP_DIR . '/config/' . $file;
$source[] = File_Archive::read($filePath, $archiveDir . basename(WEBAPP_DIR) . '/config/' . $file);
}
closedir($configDirHandle);
}
$archiveDir = $archiveBaseDir . implode('/', $installIncDirs) . '/';
$source[] = File_Archive::read(INSTALL_INC_DIR . '/install.inc.php', $archiveDir . '/install.inc.php');
$archiveDir = $archiveBaseDir . implode('/', $styleDirs);
$source[] = File_Archive::read(STYLE_DIR, $archiveDir);
$archiveDir = $archiveBaseDir . implode('/', $uploadDirs);
$uploadDirHandle = opendir(FILEUPLOADS_DIR);
$upload_dir_flag = false;
while (false !== ($file = readdir($uploadDirHandle))) {
if ($file == '.' || $file == '..' || $file == 'backup') {
continue;
}
$filePath = FILEUPLOADS_DIR . $file;
$source[] = File_Archive::read($filePath, $archiveDir . $file);
$upload_dir_flag = true;
}
closedir($uploadDirHandle);
$backupDir = FILEUPLOADS_DIR . 'backup';
if (is_dir($backupDir)) {
$uploadIDs = array();
$params = array(_OFF);
$sql = "SELECT upload_id " . "FROM {backup_uploads} " . "WHERE space_type = ?";
$uploadIDs = $this->db->execute($sql, $params);
if ($uploadIDs === false) {
$this->db->addError();
return false;
}
$backupDirHandle = opendir($backupDir);
while (false !== ($file = readdir($backupDirHandle))) {
if ($file == '.' || $file == '..') {
continue;
}
$uploadID = str_replace('.' . BACKUP_COMPRESS_EXT, '', $file);
$needle = array('upload_id' => $uploadID);
if (in_array($needle, $uploadIDs)) {
continue;
}
$filePath = $backupDir . '/' . $file;
$source[] = File_Archive::read($filePath, $archiveDir . basename($backupDir) . '/' . $file);
$upload_dir_flag = true;
}
closedir($backupDirHandle);
}
File_Archive::setOption("tmpDirectory", $temporary_file_path);
$target_file = FILEUPLOADS_DIR . "backup/" . $upload_id . "." . $extension;
$dest = File_Archive::toArchive($target_file, File_Archive::toFiles());
if ($upload_dir_flag === false) {
// uploadsされたものが1件も無い場合
$archiveDir = $archiveBaseDir . implode('/', $uploadDirs);
$archiveDir = substr($archiveDir, 0, strlen($archiveDir) - 1);
$temp_stat = stat(FILEUPLOADS_DIR);
$stat = array(2 => $temp_stat[2], "mode" => $temp_stat["mode"]);
$dest->newFile($archiveDir, $stat);
}
if (_FULLBACKUP_OUTPUT_SOURCE) {
$archiveDir = $archiveBaseDir . implode('/', $baseDirs) . '/' . basename(WEBAPP_DIR) . '/' . 'templates_c';
$temp_stat = stat(WEBAPP_DIR . "/templates_c");
$stat = array(2 => $temp_stat[2], "mode" => $temp_stat["mode"]);
$dest->newFile($archiveDir, $stat);
}
File_Archive::extract($source, $dest);
// file_size 更新
$params = array('file_size' => $this->fileView->getSize($target_file), 'garbage_flag' => _OFF);
$where_params = array("upload_id" => $upload_id);
$result = $this->uploadsAction->updUploads($params, $where_params);
if ($result === false) {
$this->_delUploads();
return false;
}
//
// ダンプファイル削除
//
unlink($temporary_file_path . BACKUP_FULL_SQL_FILE_NAME);
rmdir($temporary_file_path);
rmdir(WEBAPP_DIR . "/templates_c/" . BACKUP_BACKUP_DIR_NAME . "/");
return true;
}