PHP file online compression program class (1/2) _ PHP Tutorial

Source: Internet
Author: User
Php file online compression program class (12 ). Php file online compression program class provides a super perfect php file online compression program, the principle is very simple is to save the file in binary form, previously used to use rar kernel program, this PHP file online compression program class provides a super perfect php file online compression program, the principle is very simple is to save the file in binary form, previously used to use the rar kernel program, this is the built-in compression function of php.

Php Tutorial file online compression program class
Provides a Super Perfect Online php file compression program, the principle is very simple is to save the file in binary form, previously used to use the rar kernel program, this is the php built-in compression function.
*/

Set_time_limit (0 );
Class phpzip {

Var $ file_count = 0;
Var $ datastr_len = 0;
Var $ dirstr_len = 0;
Var $ filedata = ''; // This variable is only accessed by external programs.
Var $ gzfilename;
Var $ fp;
Var $ dirstr = '';

/*
The modified time format of the returned file.
This class only calls internal 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 ['urs'] = 0;
$ Timearray ['minutes '] = 0;
$ Timearray ['seconds'] = 0;
}

Return ($ timearray ['Year']-1980) <25) | ($ timearray ['mon'] <21) | ($ timearray ['mday'] <16) |
($ Timearray ['urs'] <11) | ($ timearray ['minutes '] <5) | ($ timearray ['seconds']> 1 );
}
/*
Initialize the file and create a file directory,
And return the write permission of 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 package.
*/

1 2

Ghost provides a Super Perfect Online PHP file compression program, the principle is very simple is to save the file in binary form, previously used to use the rar kernel program, this...

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.