PHP File online Compression program class to provide a super perfect PHP file online compression program, the principle is very simple is to put the file in binary form, the previous use of RAR kernel program, which is PHP's own compression function.
PHP Tutorial File online compression Program class
Provide a super perfect PHP file online compression program, the principle is very simple is to put the file in binary form to save the previous use of RAR kernel program, which is PHP's own compression function.
*/
Set_time_limit (0);
Class phpzip{
var $file _count = 0;
var $datastr _len = 0;
var $dirstr _len = 0;
var $filedata = '; The variable is accessed only by the class external program
var $gzfilename;
var $fp;
var $dirstr = ';
/*
Returns the modified time format of the file.
Called only for this class of intrinsic functions.
*/
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;
}
Return (($timearray [' Year ']-1980) << 25) | ($timearray [' mon '] << 21) | ($timearray [' Mday '] << 16) |
($timearray [' hours '] << 11) | ($timearray [' minutes '] << 5) | ($timearray [' seconds '] >> 1);
}
/*
Initialize the file, create the file directory,
and returns the Write permission for the file.
*/
function Startfile ($path = ' faisun.zip ') {
$this->gzfilename= $path;
$mypathdir =array ();
do{
$mypathdir [] = $path = DirName ($path);
}while ($path! = '. ');
@end ($mypathdir);
do{
$path = @current ($mypathdir);
@mkdir ($path);
}while (@prev ($mypathdir));
if ($this->fp= @fopen ($this->gzfilename, "W")) {
return true;
}
return false;
}
/*
Add a file to the ZIP archive package.
*/
1 2
http://www.bkjia.com/PHPjc/444846.html www.bkjia.com true http://www.bkjia.com/PHPjc/444846.html techarticle PHP File online compression program class to provide a super perfect PHP file online compression program, the principle is very simple is to save the file in binary form, the previous use of RAR kernel program, this ...