| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 */ 5 6 /** ensure this file is being included by a parent file */ 7 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 8 9 // $Id: zip.lib.php,v 1.1 2005/07/22 01:53:54 eddieajau Exp $ 10 // 11 // The "GNU General Public License" (GPL) is available at 12 // http://www.opensource.org/licenses/gpl-2.0.php. 13 // 14 // http://www.zend.com/codex.php?id=535&single=1 15 // By Eric Mueller <eric@themepark.com> 16 // 17 // http://www.zend.com/codex.php?id=470&single=1 18 // by Denis125 <webmaster@atlant.ru> 19 // 20 // A patch from Peter Listiak <mlady@users.sourceforge.net> for last modified 21 // date and time of the compressed file 22 // 23 // Official ZIP file format: http://www.pkware.com/appnote.txt 24 25 // ensure this file is being included by a parent file 26 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 27 28 class zipfile { 29 var $datasec = array(); 30 var $ctrl_dir = array(); 31 var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; 32 var $old_offset = 0; 33 34 function unix2DosTime($unixtime = 0) { 35 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); 36 if ($timearray['year'] < 1980) { 37 $timearray['year'] = 1980; 38 $timearray['mon'] = 1; 39 $timearray['mday'] = 1; 40 $timearray['hours'] = 0; 41 $timearray['minutes'] = 0; 42 $timearray['seconds'] = 0; 43 } 44 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); 45 } 46 47 function addFile($data, $name, $time = 0) { 48 $name = str_replace('\\', '/', $name); 49 50 $dtime = dechex($this->unix2DosTime($time)); 51 $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; 52 eval('$hexdtime = "' . $hexdtime . '";'); 53 54 $fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00" . $hexdtime; 55 56 $unc_len = strlen($data); 57 $crc = crc32($data); 58 $zdata = gzcompress($data); 59 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); 60 $c_len = strlen($zdata); 61 $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); 62 63 $this -> datasec[] = $fr; 64 $new_offset = strlen(implode('', $this->datasec)); 65 66 $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 ); 67 $this -> old_offset = $new_offset; 68 $cdrec .= $name; 69 $this -> ctrl_dir[] = $cdrec; 70 } 71 72 function file() { 73 $data = implode('', $this -> datasec); 74 $ctrldir = implode('', $this -> ctrl_dir); 75 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"; 76 } 77 } 78 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |