PHP File online Compression program class (_php) tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.