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...