ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Szip.php
Go to the documentation of this file.
1<?php
2
4
7
10// available at http://getid3.sourceforge.net //
11// or http://www.getid3.org //
13// See readme.txt for more details //
15// //
16// module.archive.szip.php //
17// module for analyzing SZIP compressed files //
18// dependencies: NONE //
19// ///
21
29class Szip extends BaseHandler
30{
35 public function analyze()
36 {
37 $info = &$this->getid3->info;
38
39 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
40 $SZIPHeader = fread($this->getid3->fp, 6);
41 if (substr($SZIPHeader, 0, 4) != "SZ\x0A\x04") {
42 $info['error'][] = 'Expecting "53 5A 0A 04" at offset ' . $info['avdataoffset'] . ', found "' . Helper::PrintHexBytes(substr($SZIPHeader,
43 0,
44 4)) . '"';
45
46 return false;
47 }
48 $info['fileformat'] = 'szip';
49 $info['szip']['major_version'] = Helper::BigEndian2Int(substr($SZIPHeader,
50 4,
51 1));
52 $info['szip']['minor_version'] = Helper::BigEndian2Int(substr($SZIPHeader,
53 5,
54 1));
55
56 while (!feof($this->getid3->fp)) {
57 $NextBlockID = fread($this->getid3->fp, 2);
58 switch ($NextBlockID) {
59 case 'SZ':
60 // Note that szip files can be concatenated, this has the same effect as
61 // concatenating the files. this also means that global header blocks
62 // might be present between directory/data blocks.
63 fseek($this->getid3->fp, 4, SEEK_CUR);
64 break;
65
66 case 'BH':
67 $BHheaderbytes = Helper::BigEndian2Int(fread($this->getid3->fp,
68 3));
69 $BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
70 $BHheaderoffset = 0;
71 while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) {
72 //filename as \0 terminated string (empty string indicates end)
73 //owner as \0 terminated string (empty is same as last file)
74 //group as \0 terminated string (empty is same as last file)
75 //3 byte filelength in this block
76 //2 byte access flags
77 //4 byte creation time (like in unix)
78 //4 byte modification time (like in unix)
79 //4 byte access time (like in unix)
80
81 $BHdataArray['filename'] = substr($BHheaderdata,
82 $BHheaderoffset,
83 strcspn($BHheaderdata,
84 "\x00"));
85 $BHheaderoffset += (strlen($BHdataArray['filename']) + 1);
86
87 $BHdataArray['owner'] = substr($BHheaderdata,
88 $BHheaderoffset,
89 strcspn($BHheaderdata,
90 "\x00"));
91 $BHheaderoffset += (strlen($BHdataArray['owner']) + 1);
92
93 $BHdataArray['group'] = substr($BHheaderdata,
94 $BHheaderoffset,
95 strcspn($BHheaderdata,
96 "\x00"));
97 $BHheaderoffset += (strlen($BHdataArray['group']) + 1);
98
99 $BHdataArray['filelength'] = Helper::BigEndian2Int(substr($BHheaderdata,
100 $BHheaderoffset,
101 3));
102 $BHheaderoffset += 3;
103
104 $BHdataArray['access_flags'] = Helper::BigEndian2Int(substr($BHheaderdata,
105 $BHheaderoffset,
106 2));
107 $BHheaderoffset += 2;
108
109 $BHdataArray['creation_time'] = Helper::BigEndian2Int(substr($BHheaderdata,
110 $BHheaderoffset,
111 4));
112 $BHheaderoffset += 4;
113
114 $BHdataArray['modification_time'] = Helper::BigEndian2Int(substr($BHheaderdata,
115 $BHheaderoffset,
116 4));
117 $BHheaderoffset += 4;
118
119 $BHdataArray['access_time'] = Helper::BigEndian2Int(substr($BHheaderdata,
120 $BHheaderoffset,
121 4));
122 $BHheaderoffset += 4;
123
124 $info['szip']['BH'][] = $BHdataArray;
125 }
126 break;
127
128 default:
129 break 2;
130 }
131 }
132
133 return true;
134 }
135}
An exception for terminatinating execution or to throw for unit testing.
GetId3() by James Heinrich info@getid3.org //.
Definition: BaseHandler.php:26
fseek($bytes, $whence=SEEK_SET)
GetId3() by James Heinrich info@getid3.org //.
Definition: Helper.php:27
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: Helper.php:374
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
GetId3() by James Heinrich info@getid3.org //.
Definition: Szip.php:30
$info
Definition: example_052.php:80