Annotation of /mambo/branches/4.6/administrator/includes/pcl/zip.lib.php
Parent Directory
|
Revision Log
Revision 3 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: zip.lib.php,v 1.1 2005/07/22 01:53:54 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | */ | ||
| 6 : | |||
| 7 : | /** ensure this file is being included by a parent file */ | ||
| 8 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 9 : | |||
| 10 : | // $Id: zip.lib.php,v 1.1 2005/07/22 01:53:54 eddieajau Exp $ | ||
| 11 : | // | ||
| 12 : | // The "GNU General Public License" (GPL) is available at | ||
| 13 : | // http://www.gnu.org/copyleft/gpl.html. | ||
| 14 : | // | ||
| 15 : | // http://www.zend.com/codex.php?id=535&single=1 | ||
| 16 : | // By Eric Mueller <eric@themepark.com> | ||
| 17 : | // | ||
| 18 : | // http://www.zend.com/codex.php?id=470&single=1 | ||
| 19 : | // by Denis125 <webmaster@atlant.ru> | ||
| 20 : | // | ||
| 21 : | // A patch from Peter Listiak <mlady@users.sourceforge.net> for last modified | ||
| 22 : | // date and time of the compressed file | ||
| 23 : | // | ||
| 24 : | // Official ZIP file format: http://www.pkware.com/appnote.txt | ||
| 25 : | |||
| 26 : | // ensure this file is being included by a parent file | ||
| 27 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 28 : | |||
| 29 : | class zipfile { | ||
| 30 : | var $datasec = array(); | ||
| 31 : | var $ctrl_dir = array(); | ||
| 32 : | var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; | ||
| 33 : | var $old_offset = 0; | ||
| 34 : | |||
| 35 : | function unix2DosTime($unixtime = 0) { | ||
| 36 : | $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); | ||
| 37 : | if ($timearray['year'] < 1980) { | ||
| 38 : | $timearray['year'] = 1980; | ||
| 39 : | $timearray['mon'] = 1; | ||
| 40 : | $timearray['mday'] = 1; | ||
| 41 : | $timearray['hours'] = 0; | ||
| 42 : | $timearray['minutes'] = 0; | ||
| 43 : | $timearray['seconds'] = 0; | ||
| 44 : | } | ||
| 45 : | return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); | ||
| 46 : | } | ||
| 47 : | |||
| 48 : | function addFile($data, $name, $time = 0) { | ||
| 49 : | $name = str_replace('\\', '/', $name); | ||
| 50 : | |||
| 51 : | $dtime = dechex($this->unix2DosTime($time)); | ||
| 52 : | $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; | ||
| 53 : | eval('$hexdtime = "' . $hexdtime . '";'); | ||
| 54 : | |||
| 55 : | $fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00" . $hexdtime; | ||
| 56 : | |||
| 57 : | $unc_len = strlen($data); | ||
| 58 : | $crc = crc32($data); | ||
| 59 : | $zdata = gzcompress($data); | ||
| 60 : | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); | ||
| 61 : | $c_len = strlen($zdata); | ||
| 62 : | $fr .= pack('V', $crc) . pack('V', $c_len) . pack('V', $unc_len) . pack('v', strlen($name)) . pack('v', 0) . $name . $zdata . pack('V', $crc) . pack('V', $c_len) . pack('V', $unc_len); | ||
| 63 : | |||
| 64 : | $this -> datasec[] = $fr; | ||
| 65 : | $new_offset = strlen(implode('', $this->datasec)); | ||
| 66 : | |||
| 67 : | $cdrec = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00" . $hexdtime . pack('V', $crc) . pack('V', $c_len) . pack('V', $unc_len) . pack('v', strlen($name)) . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('V', 32) . pack('V', $this -> old_offset ); | ||
| 68 : | $this -> old_offset = $new_offset; | ||
| 69 : | $cdrec .= $name; | ||
| 70 : | $this -> ctrl_dir[] = $cdrec; | ||
| 71 : | } | ||
| 72 : | |||
| 73 : | function file() { | ||
| 74 : | $data = implode('', $this -> datasec); | ||
| 75 : | $ctrldir = implode('', $this -> ctrl_dir); | ||
| 76 : | return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00"; | ||
| 77 : | } | ||
| 78 : | } | ||
| 79 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

