root / admin / unzip.lib.php @ 765cf74636d34cd9fdb1dc3a2a727a4d031c9d12
Historique | Voir | Annoter | Télécharger (15,68 ko)
1 | 008ae173 | Romuald | <?PHP
|
---|---|---|---|
2 | 008ae173 | Romuald | /* $Id: unzip.lib.php,v 1.2 2006/01/17 17:02:31 cybot_tm Exp $ */
|
3 | 008ae173 | Romuald | |
4 | 008ae173 | Romuald | /**
|
5 | 008ae173 | Romuald | * ZIP file unpack classes. Contributed to the phpMyAdmin project. |
6 | 008ae173 | Romuald | * |
7 | 008ae173 | Romuald | * @category phpPublic |
8 | 008ae173 | Romuald | * @package File-Formats-ZIP |
9 | 008ae173 | Romuald | * @subpackage Unzip |
10 | 008ae173 | Romuald | * @filesource unzip.lib.php |
11 | 008ae173 | Romuald | * @version 1.0.1 |
12 | 008ae173 | Romuald | * |
13 | 008ae173 | Romuald | * @author Holger Boskugel <vbwebprofi@gmx.de> |
14 | 008ae173 | Romuald | * @copyright Copyright © 2003, Holger Boskugel, Berlin, Germany |
15 | 008ae173 | Romuald | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
16 | 008ae173 | Romuald | * |
17 | 008ae173 | Romuald | * @history |
18 | 008ae173 | Romuald | * 2003-12-02 - HB : Patched : naming bug : Time/Size of file |
19 | 008ae173 | Romuald | * Added : ZIP file comment |
20 | 008ae173 | Romuald | * Added : Check BZIP2 support of PHP |
21 | 008ae173 | Romuald | * 2003-11-29 - HB * Initial version |
22 | 008ae173 | Romuald | */ |
23 | 008ae173 | Romuald | |
24 | 008ae173 | Romuald | /**
|
25 | 008ae173 | Romuald | * Unzip class, which retrieves entries from ZIP files. |
26 | 008ae173 | Romuald | * |
27 | 008ae173 | Romuald | * Supports only the compression modes |
28 | 008ae173 | Romuald | * - 0 : Stored, |
29 | 008ae173 | Romuald | * - 8 : Deflated and |
30 | 008ae173 | Romuald | * - 12 : BZIP2 |
31 | 008ae173 | Romuald | * |
32 | 008ae173 | Romuald | * Based on :<BR> |
33 | 008ae173 | Romuald | * <BR> |
34 | 008ae173 | Romuald | * {@link http://www.pkware.com/products/enterprise/white_papers/appnote.html |
35 | 008ae173 | Romuald | * * Official ZIP file format}<BR> |
36 | 008ae173 | Romuald | * {@link http://msdn.microsoft.com/library/en-us/w98ddk/hh/w98ddk/storage_5l4m.asp |
37 | 008ae173 | Romuald | * * Microsoft DOS date/time format} |
38 | 008ae173 | Romuald | * |
39 | 008ae173 | Romuald | * @category phpPublic |
40 | 008ae173 | Romuald | * @package File-Formats-ZIP |
41 | 008ae173 | Romuald | * @subpackage Unzip |
42 | 008ae173 | Romuald | * @version 1.0.1 |
43 | 008ae173 | Romuald | * @author Holger Boskugel <vbwebprofi@gmx.de> |
44 | 008ae173 | Romuald | * @uses SimpleUnzipEntry |
45 | 008ae173 | Romuald | * @example example.unzip.php Two examples |
46 | 008ae173 | Romuald | */ |
47 | 008ae173 | Romuald | class SimpleUnzip { |
48 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
49 | 008ae173 | Romuald | /**
|
50 | 008ae173 | Romuald | * Array to store file entries |
51 | 008ae173 | Romuald | * |
52 | 008ae173 | Romuald | * @var string |
53 | 008ae173 | Romuald | * @access public |
54 | 008ae173 | Romuald | * @see ReadFile() |
55 | 008ae173 | Romuald | * @since 1.0.1 |
56 | 008ae173 | Romuald | */ |
57 | 008ae173 | Romuald | var $Comment = ''; |
58 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
59 | 008ae173 | Romuald | |
60 | 008ae173 | Romuald | /**
|
61 | 008ae173 | Romuald | * Array to store file entries |
62 | 008ae173 | Romuald | * |
63 | 008ae173 | Romuald | * @var array |
64 | 008ae173 | Romuald | * @access public |
65 | 008ae173 | Romuald | * @see ReadFile() |
66 | 008ae173 | Romuald | * @since 1.0 |
67 | 008ae173 | Romuald | */ |
68 | 008ae173 | Romuald | var $Entries = array(); |
69 | 008ae173 | Romuald | |
70 | 008ae173 | Romuald | /**
|
71 | 008ae173 | Romuald | * Name of the ZIP file |
72 | 008ae173 | Romuald | * |
73 | 008ae173 | Romuald | * @var string |
74 | 008ae173 | Romuald | * @access public |
75 | 008ae173 | Romuald | * @see ReadFile() |
76 | 008ae173 | Romuald | * @since 1.0 |
77 | 008ae173 | Romuald | */ |
78 | 008ae173 | Romuald | var $Name = ''; |
79 | 008ae173 | Romuald | |
80 | 008ae173 | Romuald | /**
|
81 | 008ae173 | Romuald | * Size of the ZIP file |
82 | 008ae173 | Romuald | * |
83 | 008ae173 | Romuald | * @var integer |
84 | 008ae173 | Romuald | * @access public |
85 | 008ae173 | Romuald | * @see ReadFile() |
86 | 008ae173 | Romuald | * @since 1.0 |
87 | 008ae173 | Romuald | */ |
88 | 008ae173 | Romuald | var $Size = 0; |
89 | 008ae173 | Romuald | |
90 | 008ae173 | Romuald | /**
|
91 | 008ae173 | Romuald | * Time of the ZIP file (unix timestamp) |
92 | 008ae173 | Romuald | * |
93 | 008ae173 | Romuald | * @var integer |
94 | 008ae173 | Romuald | * @access public |
95 | 008ae173 | Romuald | * @see ReadFile() |
96 | 008ae173 | Romuald | * @since 1.0 |
97 | 008ae173 | Romuald | */ |
98 | 008ae173 | Romuald | var $Time = 0; |
99 | 008ae173 | Romuald | |
100 | 008ae173 | Romuald | /**
|
101 | 008ae173 | Romuald | * Contructor of the class |
102 | 008ae173 | Romuald | * |
103 | 008ae173 | Romuald | * @param string File name |
104 | 008ae173 | Romuald | * @return SimpleUnzip Instanced class |
105 | 008ae173 | Romuald | * @access public |
106 | 008ae173 | Romuald | * @uses SimpleUnzip::ReadFile() Opens file on new if specified |
107 | 008ae173 | Romuald | * @since 1.0 |
108 | 008ae173 | Romuald | */ |
109 | 008ae173 | Romuald | function SimpleUnzip($in_FileName = '') |
110 | 008ae173 | Romuald | { |
111 | 008ae173 | Romuald | if ($in_FileName !== '') { |
112 | 008ae173 | Romuald | SimpleUnzip::ReadFile($in_FileName); |
113 | 008ae173 | Romuald | } |
114 | 008ae173 | Romuald | } // end of the 'SimpleUnzip' constructor
|
115 | 008ae173 | Romuald | |
116 | 008ae173 | Romuald | /**
|
117 | 008ae173 | Romuald | * Counts the entries |
118 | 008ae173 | Romuald | * |
119 | 008ae173 | Romuald | * @return integer Count of ZIP entries |
120 | 008ae173 | Romuald | * @access public |
121 | 008ae173 | Romuald | * @uses $Entries |
122 | 008ae173 | Romuald | * @since 1.0 |
123 | 008ae173 | Romuald | */ |
124 | 008ae173 | Romuald | function Count() |
125 | 008ae173 | Romuald | { |
126 | 008ae173 | Romuald | return count($this->Entries); |
127 | 008ae173 | Romuald | } // end of the 'Count()' method
|
128 | 008ae173 | Romuald | |
129 | 008ae173 | Romuald | /**
|
130 | 008ae173 | Romuald | * Gets data of the specified ZIP entry |
131 | 008ae173 | Romuald | * |
132 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
133 | 008ae173 | Romuald | * @return mixed Data for the ZIP entry |
134 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$Data |
135 | 008ae173 | Romuald | * @access public |
136 | 008ae173 | Romuald | * @since 1.0 |
137 | 008ae173 | Romuald | */ |
138 | 008ae173 | Romuald | function GetData($in_Index) |
139 | 008ae173 | Romuald | { |
140 | 008ae173 | Romuald | return $this->Entries[$in_Index]->Data; |
141 | 008ae173 | Romuald | } // end of the 'GetData()' method
|
142 | 008ae173 | Romuald | |
143 | 008ae173 | Romuald | /**
|
144 | 008ae173 | Romuald | * Gets an entry of the ZIP file |
145 | 008ae173 | Romuald | * |
146 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
147 | 008ae173 | Romuald | * @return SimpleUnzipEntry Entry of the ZIP file |
148 | 008ae173 | Romuald | * @uses $Entries |
149 | 008ae173 | Romuald | * @access public |
150 | 008ae173 | Romuald | * @since 1.0 |
151 | 008ae173 | Romuald | */ |
152 | 008ae173 | Romuald | function GetEntry($in_Index) |
153 | 008ae173 | Romuald | { |
154 | 008ae173 | Romuald | return $this->Entries[$in_Index]; |
155 | 008ae173 | Romuald | } // end of the 'GetEntry()' method
|
156 | 008ae173 | Romuald | |
157 | 008ae173 | Romuald | /**
|
158 | 008ae173 | Romuald | * Gets error code for the specified ZIP entry |
159 | 008ae173 | Romuald | * |
160 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
161 | 008ae173 | Romuald | * @return integer Error code for the ZIP entry |
162 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$Error |
163 | 008ae173 | Romuald | * @access public |
164 | 008ae173 | Romuald | * @since 1.0 |
165 | 008ae173 | Romuald | */ |
166 | 008ae173 | Romuald | function GetError($in_Index) |
167 | 008ae173 | Romuald | { |
168 | 008ae173 | Romuald | return $this->Entries[$in_Index]->Error; |
169 | 008ae173 | Romuald | } // end of the 'GetError()' method
|
170 | 008ae173 | Romuald | |
171 | 008ae173 | Romuald | /**
|
172 | 008ae173 | Romuald | * Gets error message for the specified ZIP entry |
173 | 008ae173 | Romuald | * |
174 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
175 | 008ae173 | Romuald | * @return string Error message for the ZIP entry |
176 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$ErrorMsg |
177 | 008ae173 | Romuald | * @access public |
178 | 008ae173 | Romuald | * @since 1.0 |
179 | 008ae173 | Romuald | */ |
180 | 008ae173 | Romuald | function GetErrorMsg($in_Index) |
181 | 008ae173 | Romuald | { |
182 | 008ae173 | Romuald | return $this->Entries[$in_Index]->ErrorMsg; |
183 | 008ae173 | Romuald | } // end of the 'GetErrorMsg()' method
|
184 | 008ae173 | Romuald | |
185 | 008ae173 | Romuald | /**
|
186 | 008ae173 | Romuald | * Gets file name for the specified ZIP entry |
187 | 008ae173 | Romuald | * |
188 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
189 | 008ae173 | Romuald | * @return string File name for the ZIP entry |
190 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$Name |
191 | 008ae173 | Romuald | * @access public |
192 | 008ae173 | Romuald | * @since 1.0 |
193 | 008ae173 | Romuald | */ |
194 | 008ae173 | Romuald | function GetName($in_Index) |
195 | 008ae173 | Romuald | { |
196 | 008ae173 | Romuald | return $this->Entries[$in_Index]->Name; |
197 | 008ae173 | Romuald | } // end of the 'GetName()' method
|
198 | 008ae173 | Romuald | |
199 | 008ae173 | Romuald | /**
|
200 | 008ae173 | Romuald | * Gets path of the file for the specified ZIP entry |
201 | 008ae173 | Romuald | * |
202 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
203 | 008ae173 | Romuald | * @return string Path of the file for the ZIP entry |
204 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$Path |
205 | 008ae173 | Romuald | * @access public |
206 | 008ae173 | Romuald | * @since 1.0 |
207 | 008ae173 | Romuald | */ |
208 | 008ae173 | Romuald | function GetPath($in_Index) |
209 | 008ae173 | Romuald | { |
210 | 008ae173 | Romuald | return $this->Entries[$in_Index]->Path; |
211 | 008ae173 | Romuald | } // end of the 'GetPath()' method
|
212 | 008ae173 | Romuald | |
213 | 008ae173 | Romuald | /**
|
214 | 008ae173 | Romuald | * Gets file time for the specified ZIP entry |
215 | 008ae173 | Romuald | * |
216 | 008ae173 | Romuald | * @param integer Index of the ZIP entry |
217 | 008ae173 | Romuald | * @return integer File time for the ZIP entry (unix timestamp) |
218 | 008ae173 | Romuald | * @uses SimpleUnzipEntry::$Time |
219 | 008ae173 | Romuald | * @access public |
220 | 008ae173 | Romuald | * @since 1.0 |
221 | 008ae173 | Romuald | */ |
222 | 008ae173 | Romuald | function GetTime($in_Index) |
223 | 008ae173 | Romuald | { |
224 | 008ae173 | Romuald | return $this->Entries[$in_Index]->Time; |
225 | 008ae173 | Romuald | } // end of the 'GetTime()' method
|
226 | 008ae173 | Romuald | |
227 | 008ae173 | Romuald | /**
|
228 | 008ae173 | Romuald | * Reads ZIP file and extracts the entries |
229 | 008ae173 | Romuald | * |
230 | 008ae173 | Romuald | * @param string File name of the ZIP archive |
231 | 008ae173 | Romuald | * @return array ZIP entry list (see also class variable {@link $Entries $Entries}) |
232 | 008ae173 | Romuald | * @uses SimpleUnzipEntry For the entries |
233 | 008ae173 | Romuald | * @access public |
234 | 008ae173 | Romuald | * @since 1.0 |
235 | 008ae173 | Romuald | */ |
236 | 008ae173 | Romuald | function ReadFile($in_FileName) |
237 | 008ae173 | Romuald | { |
238 | 008ae173 | Romuald | $this->Entries = array(); |
239 | 008ae173 | Romuald | |
240 | 008ae173 | Romuald | // Get file parameters
|
241 | 008ae173 | Romuald | $this->Name = $in_FileName; |
242 | 008ae173 | Romuald | $this->Time = filemtime($in_FileName); |
243 | 008ae173 | Romuald | $this->Size = filesize($in_FileName); |
244 | 008ae173 | Romuald | |
245 | 008ae173 | Romuald | // Read file
|
246 | 008ae173 | Romuald | $oF = fopen($in_FileName, 'rb'); |
247 | 008ae173 | Romuald | $vZ = fread($oF, $this->Size); |
248 | 008ae173 | Romuald | fclose($oF); |
249 | 008ae173 | Romuald | |
250 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
251 | 008ae173 | Romuald | // Cut end of central directory
|
252 | 008ae173 | Romuald | $aE = explode("\x50\x4b\x05\x06", $vZ); |
253 | 008ae173 | Romuald | |
254 | 008ae173 | Romuald | // Easiest way, but not sure if format changes
|
255 | 008ae173 | Romuald | //$this->Comment = substr($aE[1], 18);
|
256 | 008ae173 | Romuald | |
257 | 008ae173 | Romuald | // Normal way
|
258 | 008ae173 | Romuald | $aP = unpack('x16/v1CL', $aE[1]); |
259 | 008ae173 | Romuald | $this->Comment = substr($aE[1], 18, $aP['CL']); |
260 | 008ae173 | Romuald | |
261 | 008ae173 | Romuald | // Translates end of line from other operating systems
|
262 | 008ae173 | Romuald | $this->Comment = strtr($this->Comment, array("\r\n" => "\n", |
263 | 008ae173 | Romuald | "\r" => "\n")); |
264 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
265 | 008ae173 | Romuald | |
266 | 008ae173 | Romuald | // Cut the entries from the central directory
|
267 | 008ae173 | Romuald | $aE = explode("\x50\x4b\x01\x02", $vZ); |
268 | 008ae173 | Romuald | // Explode to each part
|
269 | 008ae173 | Romuald | $aE = explode("\x50\x4b\x03\x04", $aE[0]); |
270 | 008ae173 | Romuald | // Shift out spanning signature or empty entry
|
271 | 008ae173 | Romuald | array_shift($aE); |
272 | 008ae173 | Romuald | |
273 | 008ae173 | Romuald | // Loop through the entries
|
274 | 008ae173 | Romuald | foreach ($aE as $vZ) { |
275 | 008ae173 | Romuald | $aI = array(); |
276 | 008ae173 | Romuald | $aI['E'] = 0; |
277 | 008ae173 | Romuald | $aI['EM'] = ''; |
278 | 008ae173 | Romuald | // Retrieving local file header information
|
279 | 008ae173 | Romuald | $aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ); |
280 | 008ae173 | Romuald | // Check if data is encrypted
|
281 | 008ae173 | Romuald | $bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE; |
282 | 008ae173 | Romuald | $nF = $aP['FNL']; |
283 | 008ae173 | Romuald | |
284 | 008ae173 | Romuald | // Special case : value block after the compressed data
|
285 | 008ae173 | Romuald | if ($aP['GPF'] & 0x0008) { |
286 | 008ae173 | Romuald | $aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12)); |
287 | 008ae173 | Romuald | |
288 | 008ae173 | Romuald | $aP['CRC'] = $aP1['CRC']; |
289 | 008ae173 | Romuald | $aP['CS'] = $aP1['CS']; |
290 | 008ae173 | Romuald | $aP['UCS'] = $aP1['UCS']; |
291 | 008ae173 | Romuald | |
292 | 008ae173 | Romuald | $vZ = substr($vZ, 0, -12); |
293 | 008ae173 | Romuald | } |
294 | 008ae173 | Romuald | |
295 | 008ae173 | Romuald | // Getting stored filename
|
296 | 008ae173 | Romuald | $aI['N'] = substr($vZ, 26, $nF); |
297 | 008ae173 | Romuald | |
298 | 008ae173 | Romuald | if (substr($aI['N'], -1) == '/') { |
299 | 008ae173 | Romuald | // is a directory entry - will be skipped
|
300 | 008ae173 | Romuald | continue;
|
301 | 008ae173 | Romuald | } |
302 | 008ae173 | Romuald | |
303 | 008ae173 | Romuald | // Truncate full filename in path and filename
|
304 | 008ae173 | Romuald | $aI['P'] = dirname($aI['N']); |
305 | 008ae173 | Romuald | $aI['P'] = $aI['P'] == '.' ? '' : $aI['P']; |
306 | 008ae173 | Romuald | $aI['N'] = basename($aI['N']); |
307 | 008ae173 | Romuald | |
308 | 008ae173 | Romuald | $vZ = substr($vZ, 26 + $nF); |
309 | 008ae173 | Romuald | |
310 | 008ae173 | Romuald | if (strlen($vZ) != $aP['CS']) { |
311 | 008ae173 | Romuald | $aI['E'] = 1; |
312 | 008ae173 | Romuald | $aI['EM'] = 'Compressed size is not equal with the value in header information.'; |
313 | 008ae173 | Romuald | } else {
|
314 | 008ae173 | Romuald | if ($bE) { |
315 | 008ae173 | Romuald | $aI['E'] = 5; |
316 | 008ae173 | Romuald | $aI['EM'] = 'File is encrypted, which is not supported from this class.'; |
317 | 008ae173 | Romuald | } else {
|
318 | 008ae173 | Romuald | switch($aP['CM']) { |
319 | 008ae173 | Romuald | case 0: // Stored |
320 | 008ae173 | Romuald | // Here is nothing to do, the file ist flat.
|
321 | 008ae173 | Romuald | break;
|
322 | 008ae173 | Romuald | |
323 | 008ae173 | Romuald | case 8: // Deflated |
324 | 008ae173 | Romuald | $vZ = gzinflate($vZ); |
325 | 008ae173 | Romuald | break;
|
326 | 008ae173 | Romuald | |
327 | 008ae173 | Romuald | case 12: // BZIP2 |
328 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
329 | 008ae173 | Romuald | if (! extension_loaded('bz2')) { |
330 | 008ae173 | Romuald | if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
331 | 008ae173 | Romuald | @dl('php_bz2.dll'); |
332 | 008ae173 | Romuald | } else {
|
333 | 008ae173 | Romuald | @dl('bz2.so'); |
334 | 008ae173 | Romuald | } |
335 | 008ae173 | Romuald | } |
336 | 008ae173 | Romuald | |
337 | 008ae173 | Romuald | if (extension_loaded('bz2')) { |
338 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
339 | 008ae173 | Romuald | $vZ = bzdecompress($vZ); |
340 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
341 | 008ae173 | Romuald | } else {
|
342 | 008ae173 | Romuald | $aI['E'] = 7; |
343 | 008ae173 | Romuald | $aI['EM'] = "PHP BZIP2 extension not available."; |
344 | 008ae173 | Romuald | } |
345 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
346 | 008ae173 | Romuald | |
347 | 008ae173 | Romuald | break;
|
348 | 008ae173 | Romuald | |
349 | 008ae173 | Romuald | default:
|
350 | 008ae173 | Romuald | $aI['E'] = 6; |
351 | 008ae173 | Romuald | $aI['EM'] = "De-/Compression method {$aP['CM']} is not supported."; |
352 | 008ae173 | Romuald | } |
353 | 008ae173 | Romuald | |
354 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
355 | 008ae173 | Romuald | if (! $aI['E']) { |
356 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
357 | 008ae173 | Romuald | if ($vZ === FALSE) { |
358 | 008ae173 | Romuald | $aI['E'] = 2; |
359 | 008ae173 | Romuald | $aI['EM'] = 'Decompression of data failed.'; |
360 | 008ae173 | Romuald | } else {
|
361 | 008ae173 | Romuald | if (strlen($vZ) != $aP['UCS']) { |
362 | 008ae173 | Romuald | $aI['E'] = 3; |
363 | 008ae173 | Romuald | $aI['EM'] = 'Uncompressed size is not equal with the value in header information.'; |
364 | 008ae173 | Romuald | } else {
|
365 | 008ae173 | Romuald | if (crc32($vZ) != $aP['CRC']) { |
366 | 008ae173 | Romuald | $aI['E'] = 4; |
367 | 008ae173 | Romuald | $aI['EM'] = 'CRC32 checksum is not equal with the value in header information.'; |
368 | 008ae173 | Romuald | } |
369 | 008ae173 | Romuald | } |
370 | 008ae173 | Romuald | } |
371 | 008ae173 | Romuald | // 2003-12-02 - HB >
|
372 | 008ae173 | Romuald | } |
373 | 008ae173 | Romuald | // 2003-12-02 - HB <
|
374 | 008ae173 | Romuald | } |
375 | 008ae173 | Romuald | } |
376 | 008ae173 | Romuald | |
377 | 008ae173 | Romuald | $aI['D'] = $vZ; |
378 | 008ae173 | Romuald | |
379 | 008ae173 | Romuald | // DOS to UNIX timestamp
|
380 | 008ae173 | Romuald | $aI['T'] = mktime(($aP['FT'] & 0xf800) >> 11, |
381 | 008ae173 | Romuald | ($aP['FT'] & 0x07e0) >> 5, |
382 | 008ae173 | Romuald | ($aP['FT'] & 0x001f) << 1, |
383 | 008ae173 | Romuald | ($aP['FD'] & 0x01e0) >> 5, |
384 | 008ae173 | Romuald | ($aP['FD'] & 0x001f), |
385 | 008ae173 | Romuald | (($aP['FD'] & 0xfe00) >> 9) + 1980); |
386 | 008ae173 | Romuald | |
387 | 008ae173 | Romuald | $this->Entries[] = &new SimpleUnzipEntry($aI); |
388 | 008ae173 | Romuald | } // end for each entries
|
389 | 008ae173 | Romuald | |
390 | 008ae173 | Romuald | return $this->Entries; |
391 | 008ae173 | Romuald | } // end of the 'ReadFile()' method
|
392 | 008ae173 | Romuald | } // end of the 'SimpleUnzip' class
|
393 | 008ae173 | Romuald | |
394 | 008ae173 | Romuald | /**
|
395 | 008ae173 | Romuald | * Entry of the ZIP file. |
396 | 008ae173 | Romuald | * |
397 | 008ae173 | Romuald | * @category phpPublic |
398 | 008ae173 | Romuald | * @package File-Formats-ZIP |
399 | 008ae173 | Romuald | * @subpackage Unzip |
400 | 008ae173 | Romuald | * @version 1.0 |
401 | 008ae173 | Romuald | * @author Holger Boskugel <vbwebprofi@gmx.de> |
402 | 008ae173 | Romuald | * @example example.unzip.php Two examples |
403 | 008ae173 | Romuald | */ |
404 | 008ae173 | Romuald | class SimpleUnzipEntry { |
405 | 008ae173 | Romuald | /**
|
406 | 008ae173 | Romuald | * Data of the file entry |
407 | 008ae173 | Romuald | * |
408 | 008ae173 | Romuald | * @var mixed |
409 | 008ae173 | Romuald | * @access public |
410 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
411 | 008ae173 | Romuald | * @since 1.0 |
412 | 008ae173 | Romuald | */ |
413 | 008ae173 | Romuald | var $Data = ''; |
414 | 008ae173 | Romuald | |
415 | 008ae173 | Romuald | /**
|
416 | 008ae173 | Romuald | * Error of the file entry |
417 | 008ae173 | Romuald | * |
418 | 008ae173 | Romuald | * - 0 : No error raised.<BR> |
419 | 008ae173 | Romuald | * - 1 : Compressed size is not equal with the value in header information.<BR> |
420 | 008ae173 | Romuald | * - 2 : Decompression of data failed.<BR> |
421 | 008ae173 | Romuald | * - 3 : Uncompressed size is not equal with the value in header information.<BR> |
422 | 008ae173 | Romuald | * - 4 : CRC32 checksum is not equal with the value in header information.<BR> |
423 | 008ae173 | Romuald | * - 5 : File is encrypted, which is not supported from this class.<BR> |
424 | 008ae173 | Romuald | * - 6 : De-/Compression method ... is not supported.<BR> |
425 | 008ae173 | Romuald | * - 7 : PHP BZIP2 extension not available. |
426 | 008ae173 | Romuald | * |
427 | 008ae173 | Romuald | * @var integer |
428 | 008ae173 | Romuald | * @access public |
429 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
430 | 008ae173 | Romuald | * @since 1.0 |
431 | 008ae173 | Romuald | */ |
432 | 008ae173 | Romuald | var $Error = 0; |
433 | 008ae173 | Romuald | |
434 | 008ae173 | Romuald | /**
|
435 | 008ae173 | Romuald | * Error message of the file entry |
436 | 008ae173 | Romuald | * |
437 | 008ae173 | Romuald | * @var string |
438 | 008ae173 | Romuald | * @access public |
439 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
440 | 008ae173 | Romuald | * @since 1.0 |
441 | 008ae173 | Romuald | */ |
442 | 008ae173 | Romuald | var $ErrorMsg = ''; |
443 | 008ae173 | Romuald | |
444 | 008ae173 | Romuald | /**
|
445 | 008ae173 | Romuald | * File name of the file entry |
446 | 008ae173 | Romuald | * |
447 | 008ae173 | Romuald | * @var string |
448 | 008ae173 | Romuald | * @access public |
449 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
450 | 008ae173 | Romuald | * @since 1.0 |
451 | 008ae173 | Romuald | */ |
452 | 008ae173 | Romuald | var $Name = ''; |
453 | 008ae173 | Romuald | |
454 | 008ae173 | Romuald | /**
|
455 | 008ae173 | Romuald | * File path of the file entry |
456 | 008ae173 | Romuald | * |
457 | 008ae173 | Romuald | * @var string |
458 | 008ae173 | Romuald | * @access public |
459 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
460 | 008ae173 | Romuald | * @since 1.0 |
461 | 008ae173 | Romuald | */ |
462 | 008ae173 | Romuald | var $Path = ''; |
463 | 008ae173 | Romuald | |
464 | 008ae173 | Romuald | /**
|
465 | 008ae173 | Romuald | * File time of the file entry (unix timestamp) |
466 | 008ae173 | Romuald | * |
467 | 008ae173 | Romuald | * @var integer |
468 | 008ae173 | Romuald | * @access public |
469 | 008ae173 | Romuald | * @see SimpleUnzipEntry() |
470 | 008ae173 | Romuald | * @since 1.0 |
471 | 008ae173 | Romuald | */ |
472 | 008ae173 | Romuald | var $Time = 0; |
473 | 008ae173 | Romuald | |
474 | 008ae173 | Romuald | /**
|
475 | 008ae173 | Romuald | * Contructor of the class |
476 | 008ae173 | Romuald | * |
477 | 008ae173 | Romuald | * @param array Entry datas |
478 | 008ae173 | Romuald | * @return SimpleUnzipEntry Instanced class |
479 | 008ae173 | Romuald | * @access public |
480 | 008ae173 | Romuald | * @since 1.0 |
481 | 008ae173 | Romuald | */ |
482 | 008ae173 | Romuald | function SimpleUnzipEntry($in_Entry) |
483 | 008ae173 | Romuald | { |
484 | 008ae173 | Romuald | $this->Data = $in_Entry['D']; |
485 | 008ae173 | Romuald | $this->Error = $in_Entry['E']; |
486 | 008ae173 | Romuald | $this->ErrorMsg = $in_Entry['EM']; |
487 | 008ae173 | Romuald | $this->Name = $in_Entry['N']; |
488 | 008ae173 | Romuald | $this->Path = $in_Entry['P']; |
489 | 008ae173 | Romuald | $this->Time = $in_Entry['T']; |
490 | 008ae173 | Romuald | } // end of the 'SimpleUnzipEntry' constructor
|
491 | 008ae173 | Romuald | } // end of the 'SimpleUnzipEntry' class
|
492 | 008ae173 | Romuald | ?> |