本文整理汇总了PHP中PclZip::create方法的典型用法代码示例。如果您正苦于以下问题:PHP PclZip::create方法的具体用法?PHP PclZip::create怎么用?PHP PclZip::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PclZip
的用法示例。
在下文中一共展示了PclZip::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zip_go
function zip_go()
{
global $list, $options;
$saveTo = realpath($options['download_dir']) . '/';
$_POST["archive"] = strlen(trim(urldecode($_POST["archive"]))) > 4 && substr(trim(urldecode($_POST["archive"])), -4) == ".zip" ? trim(urldecode($_POST["archive"])) : "archive.zip";
$_POST["archive"] = $saveTo . basename($_POST["archive"]);
for ($i = 0; $i < count($_POST["files"]); $i++) {
$files[] = $list[$_POST["files"][$i]];
}
foreach ($files as $file) {
$CurrDir = ROOT_DIR;
$inCurrDir = stristr(dirname($file["name"]), $CurrDir) ? TRUE : FALSE;
if ($inCurrDir) {
$add_files[] = substr($file["name"], strlen($CurrDir) + 1);
}
}
require_once CLASS_DIR . "pclzip.php";
$archive = new PclZip($_POST["archive"]);
$no_compression = $options['disable_archive_compression'] || isset($_POST["no_compression"]);
if (file_exists($_POST["archive"])) {
if ($no_compression) {
$v_list = $archive->add($add_files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
} else {
$v_list = $archive->add($add_files, PCLZIP_OPT_REMOVE_ALL_PATH);
}
} else {
if ($no_compression) {
$v_list = $archive->create($add_files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
} else {
$v_list = $archive->create($add_files, PCLZIP_OPT_REMOVE_ALL_PATH);
}
}
if ($v_list == 0) {
echo "Error: " . $archive->errorInfo(true) . "<br /><br />";
return;
} else {
echo "Archive <b>" . $_POST["archive"] . "</b> successfully created!<br /><br />";
}
if (is_file($_POST['archive'])) {
$time = filemtime($_POST['archive']);
while (isset($list[$time])) {
$time++;
}
$list[$time] = array("name" => $_POST['archive'], "size" => bytesToKbOrMbOrGb(filesize($_POST['archive'])), "date" => $time);
if (!updateListInFile($list)) {
echo lang(146) . "<br /><br />";
}
}
}
示例2: templatezip
/**
* Exports a template
*
* @access public
* @param string $templatename
* @return void
*/
public function templatezip($templatename)
{
global $oEditedTemplate;
if (!Permission::model()->hasGlobalPermission('templates', 'export')) {
die('No permission');
}
$templatedir = $oEditedTemplate->viewPath . DIRECTORY_SEPARATOR;
$tempdir = Yii::app()->getConfig('tempdir');
$zipfile = "{$tempdir}/{$templatename}.zip";
Yii::app()->loadLibrary('admin.pclzip');
$zip = new PclZip($zipfile);
$zip->create($templatedir, PCLZIP_OPT_REMOVE_PATH, $oEditedTemplate->viewPath);
if (is_file($zipfile)) {
// Send the file for download!
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename={$templatename}.zip");
header("Content-Description: File Transfer");
@readfile($zipfile);
// Delete the temporary file
unlink($zipfile);
}
}
示例3: create_zip
function create_zip($themeName)
{
$exclude_files = array('.', '..', '.svn', 'thumbs.db', '!sources', 'style.less.cache', 'bootstrap.less.cache', '.gitignore', '.git');
$all_themes_dir = str_replace('\\', '/', get_theme_root());
$backup_dir = str_replace('\\', '/', WP_CONTENT_DIR) . '/themes_backup';
$zip_name = $backup_dir . "/" . $themeName . '.zip';
$backup_date = date("F d Y");
if (is_dir($all_themes_dir . "/" . $themeName)) {
$file_string = scan_dir($all_themes_dir . "/" . $themeName, $exclude_files);
}
if (function_exists('wp_get_theme')) {
$backup_version = wp_get_theme($themeName)->Version;
} else {
$backup_version = get_current_theme($themeName)->Version;
}
if (!is_dir($backup_dir)) {
if (mkdir($backup_dir, 0700)) {
$htaccess_file = fopen($backup_dir . '/.htaccess', 'a');
$htaccess_text = 'deny from all';
fwrite($htaccess_file, $htaccess_text);
fclose($htaccess_file);
}
}
$zip = new PclZip($zip_name);
if ($zip->create($file_string, PCLZIP_OPT_REMOVE_PATH, $all_themes_dir . "/" . $themeName) == 0) {
die("Error : " . $zip->errorInfo(true));
}
update_option($themeName . "_date_backup", $backup_date, '', 'yes');
update_option($themeName . "_version_backup", $backup_version, '', 'yes');
echo $backup_date . "," . $backup_version;
}
示例4: compress
/**
* Creates a compressed cache file for the chapter
*
* @author Woxxy
* @return url to compressed file
*/
function compress($chapter)
{
$chapter->get_comic();
$chapter->get_pages();
$files = array();
$this->where('chapter_id', $chapter->id)->get();
if ($this->result_count() == 0 || !file_exists("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename)) {
$this->remove_old();
$CI =& get_instance();
require_once FCPATH . 'assets/pclzip/pclzip.lib.php';
$filename = $this->filename_compressed($chapter);
$archive = new PclZip("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $filename . '.zip');
$filearray = array();
foreach ($chapter->pages as $page) {
$filearray[] = "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $page["filename"];
}
$v_list = $archive->create(implode(',', $filearray), PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, $filename, PCLZIP_OPT_NO_COMPRESSION);
$this->chapter_id = $chapter->id;
$this->filename = $filename . '.zip';
$this->size = filesize("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $filename . '.zip');
$this->lastdownload = date('Y-m-d H:i:s', time());
$this->save();
} else {
$this->lastdownload = date('Y-m-d H:i:s', time());
$this->save();
}
return array("url" => site_url() . "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . urlencode($this->filename), "server_path" => FCPATH . "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename);
}
示例5: bps_Zip_CC_Master_File
function bps_Zip_CC_Master_File()
{
// Use ZipArchive
if (class_exists('ZipArchive')) {
$zip = new ZipArchive();
$filename = WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.zip';
if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
exit("Error: Cannot Open {$filename}\n");
}
$zip->addFile(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.txt', "cc-master.txt");
$zip->close();
return true;
} else {
// Use PclZip
define('PCLZIP_TEMPORARY_DIR', WP_PLUGIN_DIR . '/bulletproof-security/admin/core/');
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
if (ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding')) {
$previous_encoding = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
}
$archive = new PclZip(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.zip');
$v_list = $archive->create(WP_PLUGIN_DIR . '/bulletproof-security/admin/core/cc-master.txt', PCLZIP_OPT_REMOVE_PATH, WP_PLUGIN_DIR . '/bulletproof-security/admin/core/');
return true;
if ($v_list == 0) {
die("Error : " . $archive->errorInfo(true));
return false;
}
}
}
示例6: toSCO
function toSCO()
{
$deck_id = $_GET['deck_id'];
if (isset($_GET['format'])) {
$format = $_GET['format'];
} else {
$format = 'scorm2004_3rd';
}
$scorm = new Scorm();
$scorm->create($deck_id, $format);
$deck_name = $scorm->root_deck_name;
$archive = new PclZip($deck_name . '.zip');
//adding sco universal metadata
$v_list = $archive->create(ROOT . DS . 'libraries' . DS . 'backend' . DS . $format, PCLZIP_OPT_REMOVE_PATH, ROOT . DS . 'libraries' . DS . 'backend' . DS . $format, PCLZIP_OPT_ADD_TEMP_FILE_ON);
if ($v_list == 0) {
die("Error : " . $archive->errorInfo(true));
}
//adding sco from tmp
$v_list = $archive->add(ROOT . DS . 'tmp' . DS . $deck_name, PCLZIP_OPT_REMOVE_PATH, ROOT . DS . 'tmp' . DS . $deck_name, PCLZIP_OPT_ADD_TEMP_FILE_ON);
if ($v_list == 0) {
die("Error : " . $archive->errorInfo(true));
}
$archive->force_download();
chmod(ROOT . DS . $deck_name . '.zip', 0777);
unlink(ROOT . DS . $deck_name . '.zip');
$this->RemoveDir(ROOT . DS . 'tmp' . DS . $deck_name);
}
示例7: export
function export()
{
header("Content-type: text/html; charset=utf-8");
ob_end_clean();
//在循环输出前,要关闭输出缓冲区
echo str_pad('', 1024);
//浏览器在接受输出一定长度内容之前不会显示缓冲输出
echo '<h1>开始导出!</h1><hr/><h3>删除初始文件</h3><hr/>';
flush();
del_dir($this->path_to);
echo '删除完成!<br/><h3>删除成功,开始编译less</h3><hr/>';
flush();
//$this->_less();
echo '编译成功!<br/><h3>开始复制文件</h3><hr/>';
flush();
$this->_fileInit();
echo '复制成功!<br/><h3>删除开发相关文件</h3><hr/>';
flush();
$this->_remove();
echo '删除成功!<br/><h3>开始替换模板种less相关内容</h3><hr/>';
flush();
$this->_fileReplace();
echo '替换成功!<br/><h3>打包程序</h3><hr/>';
flush();
load_class('pclzip');
ini_set('memory_limit', '2028M');
//2G;
$archive = new PclZip($this->zip_to);
$v_list = $archive->create($this->path_to, PCLZIP_OPT_REMOVE_PATH, $this->path_to);
echo '打包成功!<br/><h3>初始化配置文件</h3><hr/>';
flush();
$this->_initUser();
echo '更新成功!<br/><h1>导出处理完成!^_^</h1>';
flush();
}
示例8: backup
/**
* 数据库备份
*/
public function backup()
{
set_time_limit(0);
$data = array();
if ($_POST) {
$backup_dir = BASEPATH . '../cache/backup/';
if (!is_dir($backup_dir)) {
mkdir($backup_dir, '0777', true);
}
include dirname(__FILE__) . '/../../config/config.db.php';
$cfg = $db[$db['active_group']];
$is_export_student = intval($this->input->post('is_export_student'));
$sql_file = DbmanageModel::backupTables($cfg['database'], $backup_dir, array('*'), $is_export_student);
if (file_exists($backup_dir . $sql_file)) {
require_once APPPATH . 'libraries/Pclzip.php';
$save_file = $backup_dir . "/zmte_database.zip";
if (is_file($save_file)) {
@unlink($save_file);
}
$archive = new PclZip($save_file);
//将文件进行压缩
$archive->create($backup_dir . $sql_file, PCLZIP_OPT_REMOVE_ALL_PATH);
@unlink($backup_dir . $sql_file);
Func::dumpFile('application/zip', $save_file, 'zmte_database_' . date('YmdHis') . '.zip');
@unlink($save_file);
redirect('/admin/dbmanage/backup');
} else {
message('数据库备份失败,请稍后重试!');
}
} else {
$this->load->view('dbmanage/backup', $data);
}
}
示例9: compress
/**
* Creates a compressed cache file for the chapter
*
* @author Woxxy
* @return url to compressed file
*/
function compress($comic, $language = 'en', $volume = null, $chapter = null, $subchapter = 0)
{
require_once FCPATH . 'assets/pclzip/pclzip.lib.php';
$files = array();
if (get_setting('fs_dl_volume_enabled') && $volume !== null && $chapter === null) {
if ($volume == 0) {
show_404();
}
$chapters = new Chapter();
$chapters->where('comic_id', $comic->id)->where('volume', $volume)->order_by('volume', 'asc')->order_by('chapter', 'asc')->order_by('subchapter', 'asc')->get();
if ($chapters->result_count() == 0) {
show_404();
}
$volume_id = $volume;
$chapter_id = $chapters->id;
$filepath = $comic->directory();
$filename = $this->filename_chapters_compressed($chapters);
foreach ($chapters as $chaptere) {
$pages = new Page();
$pages->where('chapter_id', $chaptere->id)->get();
foreach ($pages as $page) {
$files[] = array(PCLZIP_ATT_FILE_NAME => 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename, PCLZIP_ATT_FILE_NEW_FULL_NAME => $this->filename_chapter_compressed($chaptere) . '/' . $page->filename);
}
}
} else {
$chaptere = new Chapter();
$chaptere->where('comic_id', $comic->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->where('subchapter', $subchapter);
$chaptere->get();
if ($chaptere->result_count() == 0) {
show_404();
}
$volume_id = 0;
$chapter_id = $chaptere->id;
$filepath = $comic->directory() . '/' . $chaptere->directory();
$filename = $this->filename_chapter_compressed($chaptere);
$pages = new Page();
$pages->where('chapter_id', $chaptere->id)->get();
foreach ($pages as $page) {
$files[] = 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename;
}
}
$this->where('comic_id', $comic->id)->where('volume_id', $volume_id)->where('chapter_id', $chapter_id)->get();
if ($this->result_count() == 0 || !file_exists('content/comics/' . $filepath . '/' . $this->filename)) {
$this->remove_old();
$archive = new PclZip('content/comics/' . $filepath . '/' . $filename . '.zip');
$archive->create($files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
$this->comic_id = $comic->id;
$this->volume_id = $volume_id;
$this->chapter_id = $chapter_id;
$this->filename = $filename . '.zip';
$this->size = filesize('content/comics/' . $filepath . '/' . $filename . '.zip');
$this->lastdownload = date('Y-m-d H:i:s', time());
$this->save();
} else {
$this->lastdownload = date('Y-m-d H:i:s', time());
$this->save();
}
return array("url" => site_url() . 'content/comics/' . $filepath . '/' . urlencode($this->filename), "server_path" => FCPATH . 'content/comics/' . $filepath . '/' . $this->filename);
}
示例10: zip_dir
function zip_dir($zip_dir, $zip_archive)
{
$archive = new PclZip("{$zip_archive}");
$v_list = $archive->create("{$zip_dir}");
if ($v_list == 0) {
die("Error: " . $archive->errorInfo(true));
}
}
示例11: compress
/**
* Creamos un archivo zip con la lista de archivo enviados.
* @param string $file Archivo donde colocar la compresión.
* @param string $base_path Path base a utilizar en la compresión zip.
* @param array|string $files Arreglo de archivos o directorio donde se
* encuentran los archivos a comprimir.
* @return bool
*/
public function compress($file, $base_path, $files)
{
$archive = new PclZip($file);
if ($archive->create($files, PCLZIP_OPT_REMOVE_PATH, $base_path)) {
return TRUE;
} else {
return FALSE;
}
}
示例12: ZipDir
/**
* zip directory
* @param string $dir directory to zip
* @param string $output output zip file
* @example $com->ZipDir('../libs', './sample.zip');
*/
public function ZipDir($dir, $output)
{
include_once 'external/pclzip.lib.php';
$archive = new PclZip($output);
$v_list = $archive->create($dir, PCLZIP_OPT_REMOVE_PATH, $dir);
if ($v_list == 0) {
die("Error : " . $archive->errorInfo(true));
}
}
示例13: zip
/**
* @param $sourceFolder
* @param $destZip
* @return bool
*/
public function zip($sourceFolder, $destZip)
{
$zip = new \PclZip($destZip);
$result = $zip->create($sourceFolder, PCLZIP_OPT_REMOVE_PATH, $sourceFolder);
if ($result == 0) {
Craft::log('Unable to create zip file: ' . $destZip, LogLevel::Error);
return false;
}
return true;
}
示例14: backupSite
/**
* Функция делает бекап всех файлов скрипта
* Для исключения файлов из архива необходимо прописать их в свойство backup::$arrExcept (по умолчанию в нем array('updates', 'updates/backups'))
*
* @return bool
*/
static function backupSite()
{
function except($p_event, &$p_header)
{
return backup::skipAddingFilesToArchive($p_event, $p_header);
}
$file = CONF_BACKUPS_PATH_TO_FILES . terms::currentDate() . '_site_revision_' . CONF_INFO_SCRIPT_REVISION . '.zip';
file_exists($file) ? unlink($file) : null;
$zip = new PclZip($file);
return !$zip->create(CONF_ROOT_DIR, PCLZIP_OPT_REMOVE_PATH, CONF_ROOT_DIR, PCLZIP_CB_PRE_ADD, 'except') ? $zip->errorInfo(true) : true;
}
示例15: PclZip
function zip_dir($zip_dir, $zip_archive)
{
$archive = new PclZip($zip_archive);
$v_list = $archive->create($zip_dir);
if ($v_list == 0) {
if (!defined('SUGAR_PHPUNIT_RUNNER')) {
die("Error: " . $archive->errorInfo(true));
}
return false;
}
}