Php package program (extract and download the source code online) (1/8) _ PHP Tutorial

Source: Internet
Author: User
Php package program (extract and download the source code online) (18 ). Php package program (online decompression and online packaging and download source code) This program supports file download and decompression and online compression, so that we can check the online decompression and online packaging and download functions of instances. Php package program (online decompression and online packaging and download source code) This program supports file download and decompression and online compression, so that we can check the online decompression and online packaging and download functions of instances.

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;
}

1 2 3 4 5 6 7 8

Unzip (online decompression and online packaging and download source code) This program supports file download and decompression and online compression, so we can check the online decompression and online packaging and download functions of the instance ....

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.