ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
module.archive.szip.php
Go to the documentation of this file.
1<?php
4// available at http://getid3.sourceforge.net //
5// or http://www.getid3.org //
6// also https://github.com/JamesHeinrich/getID3 //
8// See readme.txt for more details //
10// //
11// module.archive.szip.php //
12// module for analyzing SZIP compressed files //
13// dependencies: NONE //
14// ///
16
17
19{
20
21 public function Analyze() {
22 $info = &$this->getid3->info;
23
24 $this->fseek($info['avdataoffset']);
25 $SZIPHeader = $this->fread(6);
26 if (substr($SZIPHeader, 0, 4) != "SZ\x0A\x04") {
27 $this->error('Expecting "53 5A 0A 04" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)).'"');
28 return false;
29 }
30 $info['fileformat'] = 'szip';
31 $info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
32 $info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
33$this->error('SZIP parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
34return false;
35
36 while (!$this->feof()) {
37 $NextBlockID = $this->fread(2);
38 switch ($NextBlockID) {
39 case 'SZ':
40 // Note that szip files can be concatenated, this has the same effect as
41 // concatenating the files. this also means that global header blocks
42 // might be present between directory/data blocks.
43 $this->fseek(4, SEEK_CUR);
44 break;
45
46 case 'BH':
47 $BHheaderbytes = getid3_lib::BigEndian2Int($this->fread(3));
48 $BHheaderdata = $this->fread($BHheaderbytes);
49 $BHheaderoffset = 0;
50 while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) {
51 //filename as \0 terminated string (empty string indicates end)
52 //owner as \0 terminated string (empty is same as last file)
53 //group as \0 terminated string (empty is same as last file)
54 //3 byte filelength in this block
55 //2 byte access flags
56 //4 byte creation time (like in unix)
57 //4 byte modification time (like in unix)
58 //4 byte access time (like in unix)
59
60 $BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
61 $BHheaderoffset += (strlen($BHdataArray['filename']) + 1);
62
63 $BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
64 $BHheaderoffset += (strlen($BHdataArray['owner']) + 1);
65
66 $BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
67 $BHheaderoffset += (strlen($BHdataArray['group']) + 1);
68
69 $BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3));
70 $BHheaderoffset += 3;
71
72 $BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2));
73 $BHheaderoffset += 2;
74
75 $BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
76 $BHheaderoffset += 4;
77
78 $BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
79 $BHheaderoffset += 4;
80
81 $BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
82 $BHheaderoffset += 4;
83
84 $info['szip']['BH'][] = $BHdataArray;
85 }
86 break;
87
88 default:
89 break 2;
90 }
91 }
92
93 return true;
94
95 }
96
97}
An exception for terminatinating execution or to throw for unit testing.
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
fread($bytes)
Definition: getid3.php:1683
error($text)
Definition: getid3.php:1752
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: getid3.lib.php:18
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:263
getID3() by James Heinrich info@getid3.org //
$info
Definition: index.php:5