112 if ($in_FileName !==
'') {
127 return count($this->Entries);
141 return $this->Entries[$in_Index]->Data;
155 return $this->Entries[$in_Index];
169 return $this->Entries[$in_Index]->Error;
183 return $this->Entries[$in_Index]->ErrorMsg;
197 return $this->Entries[$in_Index]->Name;
211 return $this->Entries[$in_Index]->Path;
225 return $this->Entries[$in_Index]->Time;
239 $this->Entries = array();
242 $this->Name = $in_FileName;
243 $this->Time = filemtime($in_FileName);
244 $this->Size = filesize($in_FileName);
247 $oF = fopen($in_FileName,
'rb');
248 $vZ = fread($oF, $this->Size);
253 $aE = explode(
"\x50\x4b\x05\x06", $vZ);
259 $aP = unpack(
'x16/v1CL', $aE[1]);
260 $this->Comment = substr($aE[1], 18, $aP[
'CL']);
263 $this->Comment = strtr($this->Comment, array(
"\r\n" =>
"\n",
268 $aE = explode(
"\x50\x4b\x01\x02", $vZ);
270 $aE = explode(
"\x50\x4b\x03\x04", $aE[0]);
275 foreach ($aE
as $vZ) {
280 $aP = unpack(
'v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
282 $bE = ($aP[
'GPF'] & 0x0001) ?
TRUE : FALSE;
286 if ($aP[
'GPF'] & 0x0008) {
287 $aP1 = unpack(
'V1CRC/V1CS/V1UCS', substr($vZ, -12));
289 $aP[
'CRC'] = $aP1[
'CRC'];
290 $aP[
'CS'] = $aP1[
'CS'];
291 $aP[
'UCS'] = $aP1[
'UCS'];
293 $vZ = substr($vZ, 0, -12);
297 $aI[
'N'] = substr($vZ, 26, $nF);
299 if (substr($aI[
'N'], -1) ==
'/') {
305 $aI[
'P'] = dirname($aI[
'N']);
306 $aI[
'P'] = $aI[
'P'] ==
'.' ?
'' : $aI[
'P'];
307 $aI[
'N'] = basename($aI[
'N']);
309 $vZ = substr($vZ, 26 + $nF);
311 if (strlen($vZ) != $aP[
'CS']) {
313 $aI[
'EM'] =
'Compressed size is not equal with the value in header information.';
317 $aI[
'EM'] =
'File is encrypted, which is not supported from this class.';
325 $vZ = gzinflate($vZ);
330 if (! extension_loaded(
'bz2')) {
331 if (strtoupper(substr(PHP_OS, 0, 3)) ==
'WIN') {
338 if (extension_loaded(
'bz2')) {
340 $vZ = bzdecompress($vZ);
344 $aI[
'EM'] =
"PHP BZIP2 extension not available.";
352 $aI[
'EM'] =
"De-/Compression method {$aP['CM']} is not supported.";
360 $aI[
'EM'] =
'Decompression of data failed.';
362 if (strlen($vZ) != $aP[
'UCS']) {
364 $aI[
'EM'] =
'Uncompressed size is not equal with the value in header information.';
366 if (crc32($vZ) != $aP[
'CRC']) {
368 $aI[
'EM'] =
'CRC32 checksum is not equal with the value in header information.';
381 $aI[
'T'] = mktime(($aP[
'FT'] & 0xf800) >> 11,
382 ($aP[
'FT'] & 0x07e0) >> 5,
383 ($aP[
'FT'] & 0x001f) << 1,
384 ($aP[
'FD'] & 0x01e0) >> 5,
385 ($aP[
'FD'] & 0x001f),
386 (($aP[
'FD'] & 0xfe00) >> 9) + 1980);
485 $this->Data = $in_Entry[
'D'];
486 $this->Error = $in_Entry[
'E'];
487 $this->ErrorMsg = $in_Entry[
'EM'];
488 $this->Name = $in_Entry[
'N'];
489 $this->Path = $in_Entry[
'P'];
490 $this->Time = $in_Entry[
'T'];