- 浏览: 401925 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
wcjagta:
...
dedecms插件开发教程 -
xc2013:
看起来不错 先下载来试试
ECSHOP完全静态化解决方法 -
greemranqq:
你好,我在xp 上做实验,也是JS css带不过来,关于 ro ...
nginx资源定向 css js路径问题 -
hotsmile:
表结构给出来吧,测试的提示说要注册,
中国移动CMPP短信开发平台通讯包 2.8 -
mengdejun:
gang80306176 写道这个插件怎么用和安装普通插件一样 ...
phpcms2008 sp4单网页编辑器插件
<?php class PHPZip { function Zip($dir, $zipfilename) { if (@function_exists ( 'gzcompress' )) { $curdir = getcwd (); if (is_array ( $dir )) { $filelist = $dir; } else { $filelist = $this->GetFileList ( $dir ); } if ((! empty ( $dir )) && (! is_array ( $dir )) && (file_exists ( $dir ))) chdir ( $dir ); else chdir ( $curdir ); if (count ( $filelist ) > 0) { foreach ( $filelist as $filename ) { if (is_file ( $filename )) { $fd = fopen ( $filename, "r" ); $content = fread ( $fd, filesize ( $filename ) ); fclose ( $fd ); if (is_array ( $dir )) $filename = basename ( $filename ); $this->addFile ( $content, $filename ); } } $out = $this->file (); chdir ( $curdir ); $fp = fopen ( $zipfilename, "w" ); fwrite ( $fp, $out, strlen ( $out ) ); fclose ( $fp ); } return 1; } else return 0; } function GetFileList($dir) { if (file_exists ( $dir )) { $args = func_get_args (); $pref = $args [1]; $dh = opendir ( $dir ); while ( $files = readdir ( $dh ) ) { if (($files != ".") && ($files != "..")) { if (is_dir ( $dir . $files )) { $curdir = getcwd (); chdir ( $dir . $files ); $file = array_merge ( $file, $this->GetFileList ( "", "$pref$files/" ) ); chdir ( $curdir ); } else $file [] = $pref . $files; } } closedir ( $dh ); } return $file; } var $datasec = array (); var $ctrl_dir = array (); var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; var $old_offset = 0; /** * Converts an Unix timestamp to a four byte DOS date and time format (date * in high two bytes, time in low two bytes allowing magnitude comparison). * * @param integer the current Unix timestamp * * @return integer the current date in a four byte DOS format * * @access private */ function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate () : getdate ( $unixtime ); if ($timearray ['year'] < 1980) { $timearray ['year'] = 1980; $timearray ['mon'] = 1; $timearray ['mday'] = 1; $timearray ['hours'] = 0; $timearray ['minutes'] = 0; $timearray ['seconds'] = 0; } // end if return (($timearray ['year'] - 1980) << 25) | ($timearray ['mon'] << 21) | ($timearray ['mday'] << 16) | ($timearray ['hours'] << 11) | ($timearray ['minutes'] << 5) | ($timearray ['seconds'] >> 1); } // end of the 'unix2DosTime()' method /** * Adds "file" to archive * * @param string file contents * @param string name of the file in the archive (may contains the path) * @param integer the current timestamp * * @access public */ function addFile($data, $name, $time = 0) { $name = str_replace ( '\\', '/', $name ); $dtime = dechex ( $this->unix2DosTime ( $time ) ); $hexdtime = '\x' . $dtime [6] . $dtime [7] . '\x' . $dtime [4] . $dtime [5] . '\x' . $dtime [2] . $dtime [3] . '\x' . $dtime [0] . $dtime [1]; eval ( '$hexdtime = "' . $hexdtime . '";' ); $fr = "\x50\x4b\x03\x04"; $fr .= "\x14\x00"; // ver needed to extract $fr .= "\x00\x00"; // gen purpose bit flag $fr .= "\x08\x00"; // compression method $fr .= $hexdtime; // last mod time and date // "local file header" segment $unc_len = strlen ( $data ); $crc = crc32 ( $data ); $zdata = gzcompress ( $data ); $c_len = strlen ( $zdata ); $zdata = substr ( substr ( $zdata, 0, strlen ( $zdata ) - 4 ), 2 ); // fix crc bug $fr .= pack ( 'V', $crc ); // crc32 $fr .= pack ( 'V', $c_len ); // compressed filesize $fr .= pack ( 'V', $unc_len ); // uncompressed filesize $fr .= pack ( 'v', strlen ( $name ) ); // length of filename $fr .= pack ( 'v', 0 ); // extra field length $fr .= $name; // "file data" segment $fr .= $zdata; // "data descriptor" segment (optional but necessary if archive is not // served as file) $fr .= pack ( 'V', $crc ); // crc32 $fr .= pack ( 'V', $c_len ); // compressed filesize $fr .= pack ( 'V', $unc_len ); // uncompressed filesize // add this entry to array $this->datasec [] = $fr; $new_offset = strlen ( implode ( '', $this->datasec ) ); // now add to central directory record $cdrec = "\x50\x4b\x01\x02"; $cdrec .= "\x00\x00"; // version made by $cdrec .= "\x14\x00"; // version needed to extract $cdrec .= "\x00\x00"; // gen purpose bit flag $cdrec .= "\x08\x00"; // compression method $cdrec .= $hexdtime; // last mod time & date $cdrec .= pack ( 'V', $crc ); // crc32 $cdrec .= pack ( 'V', $c_len ); // compressed filesize $cdrec .= pack ( 'V', $unc_len ); // uncompressed filesize $cdrec .= pack ( 'v', strlen ( $name ) ); // length of filename $cdrec .= pack ( 'v', 0 ); // extra field length $cdrec .= pack ( 'v', 0 ); // file comment length $cdrec .= pack ( 'v', 0 ); // disk number start $cdrec .= pack ( 'v', 0 ); // internal file attributes $cdrec .= pack ( 'V', 32 ); // external file attributes - 'archive' bit set $cdrec .= pack ( 'V', $this->old_offset ); // relative offset of local header $this->old_offset = $new_offset; $cdrec .= $name; // optional extra field, file comment goes here // save to central directory $this->ctrl_dir [] = $cdrec; } // end of the 'addFile()' method /** * Dumps out file * * @return string the zipped file * * @access public */ function file() { $data = implode ( '', $this->datasec ); $ctrldir = implode ( '', $this->ctrl_dir ); return $data . $ctrldir . $this->eof_ctrl_dir . pack ( 'v', sizeof ( $this->ctrl_dir ) ) . // total # of entries "on this disk" pack ( 'v', sizeof ( $this->ctrl_dir ) ) . // total # of entries overall pack ( 'V', strlen ( $ctrldir ) ) . // size of central dir pack ( 'V', strlen ( $data ) ) . // offset to start of central dir "\x00\x00"; // .zip file comment length } // end of the 'file()' method } // end of the 'PHPZip' class ?>
<?php require'PHPZip.php'; $z = new PHPZip(); //新建立一个zip的类 //$z->Zip("","z.zip");当前文件夹压缩 $z->Zip(array("PHPZip.php"),"phpx.zip") ?>
- zip_lib.rar (2.2 KB)
- 下载次数: 9
发表评论
-
php异步操作类库
2011-06-05 16:01 1784httpclient for php 的选择常用方案有以 ... -
织梦HTTP IMAGE下载类
2011-06-05 14:57 1858<?php if(!defined('DEDEINC ... -
php汉字转拼音
2011-06-05 14:41 1577<?php /**************** ... -
PHP采集利器:Snoopy 试用心得
2011-06-05 14:34 14031Snoopy是一个php类,用 ... -
php异步调用 提高用户体验
2011-05-30 14:22 1296这是我的一个技术很好的朋友写的,要我发表在我的博客上可让php ... -
PHP 异步调用 后台调用 持续执行 断开连接/浏览器
2011-05-26 10:31 1685标题很怪,因为我也 ... -
php socket模拟POST GET请求 fsockopen版
2011-05-26 10:14 7350function httpRequestGET($url){ ... -
php socket GET POST提交方法(HttpClient) 框架
2011-05-25 18:29 5515<?php /* Version 0.9, 6th ... -
mantis
2011-05-25 09:50 1262mantis 缺陷管理平台Mantis,也做Mantis ... -
Curl参数一览
2011-05-06 17:30 1454* 目录 1. 介绍 ... -
PHPRPC
2011-04-24 11:01 1294PHPRPC 是一个轻型的、安全的、跨网际的、跨语言的、跨平台 ... -
PHP身份证验证程序
2011-04-24 10:56 1246<?php // 计算身份证校验码,根据国家标准GB 116 ... -
nginx 502 Bad Gateway 错误问题收集
2011-04-23 09:43 1740502是FastCGI出现问题,所以从FastCGI配置入手。 ... -
深入理解PHP内存管理之谁动了我的内存
2011-04-12 21:57 831首先让我们看一个问题: ... -
socket模拟post表单
2011-04-11 15:40 2774post的本质就是发送给目的程序一个标志为post的协议串如下 ... -
OAUTH协议
2011-04-09 09:59 1067OAUTH协议为用户资源的 ... -
nginx/windows: 让nginx以服务的方式运行
2011-04-09 09:33 1129在windows下安装了nginx, 郁闷是发现它没有以服 ... -
ThinkPHP处理海量数据分表机制详细代码
2011-04-07 18:27 7184应用ThinkPHP内置的分表算法处理百万级用户数据. ... -
php 分库分表hash算法
2011-04-07 18:16 1678//分库分表算法 function calc_hash_d ... -
nginx配置文件实例: php (fastcgi), perl, proxy, rrd, nagios
2011-04-06 20:33 1812nginx.conf worker_processes 5; ...
相关推荐
本篇文章是对php生成zip压缩文件的方法进行了详细的分析介绍,需要的朋友参考下
用PHP生成zip文件的类文件. 示例如: $phpZip = new PHPZip(); $phpZip->Zip("c:\abc", 'testzip.zip');
PHP生成压缩文,不带要压缩文件的根目录,去掉根目录,有时可能需要这样
PHP导出包含图片的excel文件;PHP生成压缩文件
1.生成压缩文件,压缩文件名格式: 2.压缩文件存放在根目录 /upload/zipfile/年月/自定义的压缩文件名.zip 3.点击下载压缩包,系统开始对压缩文件打包,打包完成后自动开始下载 4.为了防止暴露压缩包文件路径,...
本文实例讲述了PHP生成zip压缩包的常用方法。分享给大家供大家参考,具体如下: 压缩一个文件 我们将一个文件生成一个压缩包。 <?php $path = c:/wamp/www/log.txt; $filename = test.zip; $zip = new Zip...
又一款与PHP解压缩相匹配的打包(压缩)工具,其特点是可以在远程服务器上方便、快速的压缩文件,并且提供下载链接,方便下载,是网站备份的好工具。其他用途有待开发!(声明:此程序为开源程序,本人只是对其二次...
PHPZip类,生成zip格式的压缩包,可以直接在服务器上生成压缩包,也可以生成压缩并下载,也可以直接在线解压以及获得压缩包的相应信息
PHP在线打包在线压缩ZIP工具使用方法: 下载到本地之后,上传PHPZip.php文件到你的服务器上,对其进行访问。 默认密码:xibo123 修改密码方法:在地址栏访问你服务器上PHPZip.php文件,在其后面加上?pwd=密码代码...
用ZipArchive压缩文件,这个是php的扩展类,自php5.2...php /* 生成zip 压缩文件 */function create_zip($files = array(),$destination = ”,$overwrite = false) { //if the zip file already exists and overwrite
<?... defined('BASEPATH')) exit('No direct script access allowed');.../* Location: ./application/config/constants.php */这是一个PHP生成和在线浏览类库,需要的朋友可以下载使用。
PHPZip类,生成zip格式的压缩包,生成压缩并下载,简单的zip压缩类
1.生成压缩文件,压缩文件名格式: 2.压缩文件存放在根目录 /upload/zipfile/年月/自定义的压缩文件名.zip 3.点击下载压缩包,系统开始对压缩文件打包,打包完成后自动开始下载 4.为了防止暴露压缩包文件路径,需要...
程序比较简单,适合购买了空间,但空间服务商不提供解压和压缩服务的用户。使用需开启zip扩展
事实上,这不是关于 Laravel 的,而是和 PHP 的关联更多,我们准备使用从 PHP 5.2 以来就存在的 ZipArchive 类 ,如果要使用,需要确保php.ini 中的 ext-zip 扩展开启。 任务 1: 存储用户的发票文件到 storage/...
PclZip简介PclZip是一个很强大的压缩与解压缩zip文件的PHP类,PclZip library能够压缩与解压缩Zip格式的压缩档(WinZip、PKZIP);...生成zip文件用法一: 复制代码 代码如下:< ?phpinclude_once(‘pc