Php Tutorial package program (extract and download the source code online)
This program supports file downloading and decompression and online compression, so that we can check the online decompression and online package download functions of the instance.
*/
// Phpzip. class. php
Class phpzip {
Var $ datasec, $ ctrl_dir = array ();
Var $ eof_ctrl_dir = "x50x4bx05x06x00x00x00x00 ";
Var $ old_offset = 0; var $ dirs = array (".");
Function get_list ($ zip_name ){
$ Zip = @ fopen ($ zip_name, 'RB ');
If (! $ Zip) return (0 );
$ Centd = $ this-> readcentraldir ($ zip, $ zip_name );
@ Rewind ($ zip );
@ Fseek ($ zip, $ centd ['offset']);
For ($ I = 0; $ I <$ centd ['entries']; $ I ++)
{
$ Header = $ this-> readcentralfileheaders ($ zip );
$ Header ['index'] = $ I; $ info ['filename'] = $ header ['filename'];
$ Info ['stored _ filename'] = $ header ['stored _ filename'];
$ Info ['size'] = $ header ['size']; $ info ['compressed _ size'] = $ header ['compressed _ size'];
$ Info ['crc '] = strtoupper (dechex ($ header ['crc']);
$ Info ['mtime'] = $ header ['mtime']; $ info ['comment'] = $ header ['comment'];
$ Info ['Folder'] = ($ header ['external '] = 0x41ff0010 | $ header ['external'] = 16 )? 1:0;
$ Info ['index'] = $ header ['index']; $ info ['status'] = $ header ['status'];
$ Ret [] = $ info; unset ($ header );
}
Return $ ret;
}
Function add ($ files, $ compact ){
If (! Is_array ($ files [0]) $ files = array ($ files );
For ($ I = 0; $ files [$ I]; $ I ++ ){
$ Fn = $ files [$ I];
If (! In_array (dirname ($ fn [0]), $ this-> dirs ))
$ This-> add_dir (dirname ($ fn [0]);
If (basename ($ fn [0])
$ Ret [basename ($ fn [0])] = $ this-> add_file ($ fn [1], $ fn [0], $ compact );
}
Return $ ret;
}