ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Iso.php
Go to the documentation of this file.
1 <?php
2 
3 namespace GetId3\Module\Misc;
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.misc.iso.php //
17 // module for analyzing ISO files //
18 // dependencies: NONE //
19 // ///
21 
29 class Iso extends BaseHandler
30 {
31 
36  public function analyze()
37  {
38  $info = &$this->getid3->info;
39 
40  $info['fileformat'] = 'iso';
41 
42  for ($i = 16; $i <= 19; $i++) {
43  fseek($this->getid3->fp, 2048 * $i, SEEK_SET);
44  $ISOheader = fread($this->getid3->fp, 2048);
45  if (substr($ISOheader, 1, 5) == 'CD001') {
46  switch (ord($ISOheader{0})) {
47  case 1:
48  $info['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;
49  $this->ParsePrimaryVolumeDescriptor($ISOheader);
50  break;
51 
52  case 2:
53  $info['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;
54  $this->ParseSupplementaryVolumeDescriptor($ISOheader);
55  break;
56 
57  default:
58  // skip
59  break;
60  }
61  }
62  }
63 
64  $this->ParsePathTable();
65 
66  $info['iso']['files'] = array();
67  foreach ($info['iso']['path_table']['directories'] as $directorynum => $directorydata) {
68  $info['iso']['directories'][$directorynum] = $this->ParseDirectoryRecord($directorydata);
69  }
70 
71  return true;
72  }
73 
79  public function ParsePrimaryVolumeDescriptor(&$ISOheader)
80  {
81  // ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!!
82  // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
83 
84  // shortcuts
85  $info = &$this->getid3->info;
86  $info['iso']['primary_volume_descriptor']['raw'] = array();
87  $thisfile_iso_primaryVD = &$info['iso']['primary_volume_descriptor'];
88  $thisfile_iso_primaryVD_raw = &$thisfile_iso_primaryVD['raw'];
89 
90  $thisfile_iso_primaryVD_raw['volume_descriptor_type'] = Helper::LittleEndian2Int(substr($ISOheader, 0, 1));
91  $thisfile_iso_primaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5);
92  if ($thisfile_iso_primaryVD_raw['standard_identifier'] != 'CD001') {
93  $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_primaryVD['offset'] + 1).'), found "'.$thisfile_iso_primaryVD_raw['standard_identifier'].'" instead';
94  unset($info['fileformat']);
95  unset($info['iso']);
96 
97  return false;
98  }
99 
100  $thisfile_iso_primaryVD_raw['volume_descriptor_version'] = Helper::LittleEndian2Int(substr($ISOheader, 6, 1));
101  //$thisfile_iso_primaryVD_raw['unused_1'] = substr($ISOheader, 7, 1);
102  $thisfile_iso_primaryVD_raw['system_identifier'] = substr($ISOheader, 8, 32);
103  $thisfile_iso_primaryVD_raw['volume_identifier'] = substr($ISOheader, 40, 32);
104  //$thisfile_iso_primaryVD_raw['unused_2'] = substr($ISOheader, 72, 8);
105  $thisfile_iso_primaryVD_raw['volume_space_size'] = Helper::LittleEndian2Int(substr($ISOheader, 80, 4));
106  //$thisfile_iso_primaryVD_raw['unused_3'] = substr($ISOheader, 88, 32);
107  $thisfile_iso_primaryVD_raw['volume_set_size'] = Helper::LittleEndian2Int(substr($ISOheader, 120, 2));
108  $thisfile_iso_primaryVD_raw['volume_sequence_number'] = Helper::LittleEndian2Int(substr($ISOheader, 124, 2));
109  $thisfile_iso_primaryVD_raw['logical_block_size'] = Helper::LittleEndian2Int(substr($ISOheader, 128, 2));
110  $thisfile_iso_primaryVD_raw['path_table_size'] = Helper::LittleEndian2Int(substr($ISOheader, 132, 4));
111  $thisfile_iso_primaryVD_raw['path_table_l_location'] = Helper::LittleEndian2Int(substr($ISOheader, 140, 2));
112  $thisfile_iso_primaryVD_raw['path_table_l_opt_location'] = Helper::LittleEndian2Int(substr($ISOheader, 144, 2));
113  $thisfile_iso_primaryVD_raw['path_table_m_location'] = Helper::LittleEndian2Int(substr($ISOheader, 148, 2));
114  $thisfile_iso_primaryVD_raw['path_table_m_opt_location'] = Helper::LittleEndian2Int(substr($ISOheader, 152, 2));
115  $thisfile_iso_primaryVD_raw['root_directory_record'] = substr($ISOheader, 156, 34);
116  $thisfile_iso_primaryVD_raw['volume_set_identifier'] = substr($ISOheader, 190, 128);
117  $thisfile_iso_primaryVD_raw['publisher_identifier'] = substr($ISOheader, 318, 128);
118  $thisfile_iso_primaryVD_raw['data_preparer_identifier'] = substr($ISOheader, 446, 128);
119  $thisfile_iso_primaryVD_raw['application_identifier'] = substr($ISOheader, 574, 128);
120  $thisfile_iso_primaryVD_raw['copyright_file_identifier'] = substr($ISOheader, 702, 37);
121  $thisfile_iso_primaryVD_raw['abstract_file_identifier'] = substr($ISOheader, 739, 37);
122  $thisfile_iso_primaryVD_raw['bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
123  $thisfile_iso_primaryVD_raw['volume_creation_date_time'] = substr($ISOheader, 813, 17);
124  $thisfile_iso_primaryVD_raw['volume_modification_date_time'] = substr($ISOheader, 830, 17);
125  $thisfile_iso_primaryVD_raw['volume_expiration_date_time'] = substr($ISOheader, 847, 17);
126  $thisfile_iso_primaryVD_raw['volume_effective_date_time'] = substr($ISOheader, 864, 17);
127  $thisfile_iso_primaryVD_raw['file_structure_version'] = Helper::LittleEndian2Int(substr($ISOheader, 881, 1));
128  //$thisfile_iso_primaryVD_raw['unused_4'] = GetId3_lib::LittleEndian2Int(substr($ISOheader, 882, 1));
129  $thisfile_iso_primaryVD_raw['application_data'] = substr($ISOheader, 883, 512);
130  //$thisfile_iso_primaryVD_raw['unused_5'] = substr($ISOheader, 1395, 653);
131 
132  $thisfile_iso_primaryVD['system_identifier'] = trim($thisfile_iso_primaryVD_raw['system_identifier']);
133  $thisfile_iso_primaryVD['volume_identifier'] = trim($thisfile_iso_primaryVD_raw['volume_identifier']);
134  $thisfile_iso_primaryVD['volume_set_identifier'] = trim($thisfile_iso_primaryVD_raw['volume_set_identifier']);
135  $thisfile_iso_primaryVD['publisher_identifier'] = trim($thisfile_iso_primaryVD_raw['publisher_identifier']);
136  $thisfile_iso_primaryVD['data_preparer_identifier'] = trim($thisfile_iso_primaryVD_raw['data_preparer_identifier']);
137  $thisfile_iso_primaryVD['application_identifier'] = trim($thisfile_iso_primaryVD_raw['application_identifier']);
138  $thisfile_iso_primaryVD['copyright_file_identifier'] = trim($thisfile_iso_primaryVD_raw['copyright_file_identifier']);
139  $thisfile_iso_primaryVD['abstract_file_identifier'] = trim($thisfile_iso_primaryVD_raw['abstract_file_identifier']);
140  $thisfile_iso_primaryVD['bibliographic_file_identifier'] = trim($thisfile_iso_primaryVD_raw['bibliographic_file_identifier']);
141  $thisfile_iso_primaryVD['volume_creation_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_creation_date_time']);
142  $thisfile_iso_primaryVD['volume_modification_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_modification_date_time']);
143  $thisfile_iso_primaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_expiration_date_time']);
144  $thisfile_iso_primaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_effective_date_time']);
145 
146  if (($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048) > $info['filesize']) {
147  $info['error'][] = 'Volume Space Size ('.($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048).' bytes) is larger than the file size ('.$info['filesize'].' bytes) (truncated file?)';
148  }
149 
150  return true;
151  }
152 
158  public function ParseSupplementaryVolumeDescriptor(&$ISOheader)
159  {
160  // ISO integer values are stored Both-Endian format!!
161  // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
162 
163  // shortcuts
164  $info = &$this->getid3->info;
165  $info['iso']['supplementary_volume_descriptor']['raw'] = array();
166  $thisfile_iso_supplementaryVD = &$info['iso']['supplementary_volume_descriptor'];
167  $thisfile_iso_supplementaryVD_raw = &$thisfile_iso_supplementaryVD['raw'];
168 
169  $thisfile_iso_supplementaryVD_raw['volume_descriptor_type'] = Helper::LittleEndian2Int(substr($ISOheader, 0, 1));
170  $thisfile_iso_supplementaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5);
171  if ($thisfile_iso_supplementaryVD_raw['standard_identifier'] != 'CD001') {
172  $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_supplementaryVD['offset'] + 1).'), found "'.$thisfile_iso_supplementaryVD_raw['standard_identifier'].'" instead';
173  unset($info['fileformat']);
174  unset($info['iso']);
175 
176  return false;
177  }
178 
179  $thisfile_iso_supplementaryVD_raw['volume_descriptor_version'] = Helper::LittleEndian2Int(substr($ISOheader, 6, 1));
180  //$thisfile_iso_supplementaryVD_raw['unused_1'] = substr($ISOheader, 7, 1);
181  $thisfile_iso_supplementaryVD_raw['system_identifier'] = substr($ISOheader, 8, 32);
182  $thisfile_iso_supplementaryVD_raw['volume_identifier'] = substr($ISOheader, 40, 32);
183  //$thisfile_iso_supplementaryVD_raw['unused_2'] = substr($ISOheader, 72, 8);
184  $thisfile_iso_supplementaryVD_raw['volume_space_size'] = Helper::LittleEndian2Int(substr($ISOheader, 80, 4));
185  if ($thisfile_iso_supplementaryVD_raw['volume_space_size'] == 0) {
186  // Supplementary Volume Descriptor not used
187  //unset($thisfile_iso_supplementaryVD);
188  //return false;
189  }
190 
191  //$thisfile_iso_supplementaryVD_raw['unused_3'] = substr($ISOheader, 88, 32);
192  $thisfile_iso_supplementaryVD_raw['volume_set_size'] = Helper::LittleEndian2Int(substr($ISOheader, 120, 2));
193  $thisfile_iso_supplementaryVD_raw['volume_sequence_number'] = Helper::LittleEndian2Int(substr($ISOheader, 124, 2));
194  $thisfile_iso_supplementaryVD_raw['logical_block_size'] = Helper::LittleEndian2Int(substr($ISOheader, 128, 2));
195  $thisfile_iso_supplementaryVD_raw['path_table_size'] = Helper::LittleEndian2Int(substr($ISOheader, 132, 4));
196  $thisfile_iso_supplementaryVD_raw['path_table_l_location'] = Helper::LittleEndian2Int(substr($ISOheader, 140, 2));
197  $thisfile_iso_supplementaryVD_raw['path_table_l_opt_location'] = Helper::LittleEndian2Int(substr($ISOheader, 144, 2));
198  $thisfile_iso_supplementaryVD_raw['path_table_m_location'] = Helper::LittleEndian2Int(substr($ISOheader, 148, 2));
199  $thisfile_iso_supplementaryVD_raw['path_table_m_opt_location'] = Helper::LittleEndian2Int(substr($ISOheader, 152, 2));
200  $thisfile_iso_supplementaryVD_raw['root_directory_record'] = substr($ISOheader, 156, 34);
201  $thisfile_iso_supplementaryVD_raw['volume_set_identifier'] = substr($ISOheader, 190, 128);
202  $thisfile_iso_supplementaryVD_raw['publisher_identifier'] = substr($ISOheader, 318, 128);
203  $thisfile_iso_supplementaryVD_raw['data_preparer_identifier'] = substr($ISOheader, 446, 128);
204  $thisfile_iso_supplementaryVD_raw['application_identifier'] = substr($ISOheader, 574, 128);
205  $thisfile_iso_supplementaryVD_raw['copyright_file_identifier'] = substr($ISOheader, 702, 37);
206  $thisfile_iso_supplementaryVD_raw['abstract_file_identifier'] = substr($ISOheader, 739, 37);
207  $thisfile_iso_supplementaryVD_raw['bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
208  $thisfile_iso_supplementaryVD_raw['volume_creation_date_time'] = substr($ISOheader, 813, 17);
209  $thisfile_iso_supplementaryVD_raw['volume_modification_date_time'] = substr($ISOheader, 830, 17);
210  $thisfile_iso_supplementaryVD_raw['volume_expiration_date_time'] = substr($ISOheader, 847, 17);
211  $thisfile_iso_supplementaryVD_raw['volume_effective_date_time'] = substr($ISOheader, 864, 17);
212  $thisfile_iso_supplementaryVD_raw['file_structure_version'] = Helper::LittleEndian2Int(substr($ISOheader, 881, 1));
213  //$thisfile_iso_supplementaryVD_raw['unused_4'] = GetId3_lib::LittleEndian2Int(substr($ISOheader, 882, 1));
214  $thisfile_iso_supplementaryVD_raw['application_data'] = substr($ISOheader, 883, 512);
215  //$thisfile_iso_supplementaryVD_raw['unused_5'] = substr($ISOheader, 1395, 653);
216 
217  $thisfile_iso_supplementaryVD['system_identifier'] = trim($thisfile_iso_supplementaryVD_raw['system_identifier']);
218  $thisfile_iso_supplementaryVD['volume_identifier'] = trim($thisfile_iso_supplementaryVD_raw['volume_identifier']);
219  $thisfile_iso_supplementaryVD['volume_set_identifier'] = trim($thisfile_iso_supplementaryVD_raw['volume_set_identifier']);
220  $thisfile_iso_supplementaryVD['publisher_identifier'] = trim($thisfile_iso_supplementaryVD_raw['publisher_identifier']);
221  $thisfile_iso_supplementaryVD['data_preparer_identifier'] = trim($thisfile_iso_supplementaryVD_raw['data_preparer_identifier']);
222  $thisfile_iso_supplementaryVD['application_identifier'] = trim($thisfile_iso_supplementaryVD_raw['application_identifier']);
223  $thisfile_iso_supplementaryVD['copyright_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['copyright_file_identifier']);
224  $thisfile_iso_supplementaryVD['abstract_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['abstract_file_identifier']);
225  $thisfile_iso_supplementaryVD['bibliographic_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['bibliographic_file_identifier']);
226  $thisfile_iso_supplementaryVD['volume_creation_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_creation_date_time']);
227  $thisfile_iso_supplementaryVD['volume_modification_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_modification_date_time']);
228  $thisfile_iso_supplementaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_expiration_date_time']);
229  $thisfile_iso_supplementaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_effective_date_time']);
230 
231  if (($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']) > $info['filesize']) {
232  $info['error'][] = 'Volume Space Size ('.($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']).' bytes) is larger than the file size ('.$info['filesize'].' bytes) (truncated file?)';
233  }
234 
235  return true;
236  }
237 
242  public function ParsePathTable()
243  {
244  $info = &$this->getid3->info;
245  if (!isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
246  return false;
247  }
248  if (isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) {
249  $PathTableLocation = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
250  $PathTableSize = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
251  $TextEncoding = 'UTF-16BE'; // Big-Endian Unicode
252  } else {
253  $PathTableLocation = $info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
254  $PathTableSize = $info['iso']['primary_volume_descriptor']['raw']['path_table_size'];
255  $TextEncoding = 'ISO-8859-1'; // Latin-1
256  }
257 
258  if (($PathTableLocation * 2048) > $info['filesize']) {
259  $info['error'][] = 'Path Table Location specifies an offset ('.($PathTableLocation * 2048).') beyond the end-of-file ('.$info['filesize'].')';
260 
261  return false;
262  }
263 
264  $info['iso']['path_table']['offset'] = $PathTableLocation * 2048;
265  fseek($this->getid3->fp, $info['iso']['path_table']['offset'], SEEK_SET);
266  $info['iso']['path_table']['raw'] = fread($this->getid3->fp, $PathTableSize);
267 
268  $offset = 0;
269  $pathcounter = 1;
270  while ($offset < $PathTableSize) {
271  // shortcut
272  $info['iso']['path_table']['directories'][$pathcounter] = array();
273  $thisfile_iso_pathtable_directories_current = &$info['iso']['path_table']['directories'][$pathcounter];
274 
275  $thisfile_iso_pathtable_directories_current['length'] = Helper::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1));
276  $offset += 1;
277  $thisfile_iso_pathtable_directories_current['extended_length'] = Helper::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1));
278  $offset += 1;
279  $thisfile_iso_pathtable_directories_current['location_logical'] = Helper::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 4));
280  $offset += 4;
281  $thisfile_iso_pathtable_directories_current['parent_directory'] = Helper::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 2));
282  $offset += 2;
283  $thisfile_iso_pathtable_directories_current['name'] = substr($info['iso']['path_table']['raw'], $offset, $thisfile_iso_pathtable_directories_current['length']);
284  $offset += $thisfile_iso_pathtable_directories_current['length'] + ($thisfile_iso_pathtable_directories_current['length'] % 2);
285 
286  $thisfile_iso_pathtable_directories_current['name_ascii'] = Helper::iconv_fallback($TextEncoding, $info['encoding'], $thisfile_iso_pathtable_directories_current['name']);
287 
288  $thisfile_iso_pathtable_directories_current['location_bytes'] = $thisfile_iso_pathtable_directories_current['location_logical'] * 2048;
289  if ($pathcounter == 1) {
290  $thisfile_iso_pathtable_directories_current['full_path'] = '/';
291  } else {
292  $thisfile_iso_pathtable_directories_current['full_path'] = $info['iso']['path_table']['directories'][$thisfile_iso_pathtable_directories_current['parent_directory']]['full_path'].$thisfile_iso_pathtable_directories_current['name_ascii'].'/';
293  }
294  $FullPathArray[] = $thisfile_iso_pathtable_directories_current['full_path'];
295 
296  $pathcounter++;
297  }
298 
299  return true;
300  }
301 
307  public function ParseDirectoryRecord($directorydata)
308  {
309  $info = &$this->getid3->info;
310  if (isset($info['iso']['supplementary_volume_descriptor'])) {
311  $TextEncoding = 'UTF-16BE'; // Big-Endian Unicode
312  } else {
313  $TextEncoding = 'ISO-8859-1'; // Latin-1
314  }
315 
316  fseek($this->getid3->fp, $directorydata['location_bytes'], SEEK_SET);
317  $DirectoryRecordData = fread($this->getid3->fp, 1);
318 
319  while (ord($DirectoryRecordData{0}) > 33) {
320 
321  $DirectoryRecordData .= fread($this->getid3->fp, ord($DirectoryRecordData{0}) - 1);
322 
323  $ThisDirectoryRecord['raw']['length'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 0, 1));
324  $ThisDirectoryRecord['raw']['extended_attribute_length'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 1, 1));
325  $ThisDirectoryRecord['raw']['offset_logical'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 2, 4));
326  $ThisDirectoryRecord['raw']['filesize'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 10, 4));
327  $ThisDirectoryRecord['raw']['recording_date_time'] = substr($DirectoryRecordData, 18, 7);
328  $ThisDirectoryRecord['raw']['file_flags'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 25, 1));
329  $ThisDirectoryRecord['raw']['file_unit_size'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 26, 1));
330  $ThisDirectoryRecord['raw']['interleave_gap_size'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 27, 1));
331  $ThisDirectoryRecord['raw']['volume_sequence_number'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 28, 2));
332  $ThisDirectoryRecord['raw']['file_identifier_length'] = Helper::LittleEndian2Int(substr($DirectoryRecordData, 32, 1));
333  $ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']);
334 
335  $ThisDirectoryRecord['file_identifier_ascii'] = Helper::iconv_fallback($TextEncoding, $info['encoding'], $ThisDirectoryRecord['raw']['file_identifier']);
336 
337  $ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize'];
338  $ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048;
339  $ThisDirectoryRecord['file_flags']['hidden'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x01);
340  $ThisDirectoryRecord['file_flags']['directory'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x02);
341  $ThisDirectoryRecord['file_flags']['associated'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x04);
342  $ThisDirectoryRecord['file_flags']['extended'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x08);
343  $ThisDirectoryRecord['file_flags']['permissions'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x10);
344  $ThisDirectoryRecord['file_flags']['multiple'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x80);
345  $ThisDirectoryRecord['recording_timestamp'] = $this->ISOtime2UNIXtime($ThisDirectoryRecord['raw']['recording_date_time']);
346 
347  if ($ThisDirectoryRecord['file_flags']['directory']) {
348  $ThisDirectoryRecord['filename'] = $directorydata['full_path'];
349  } else {
350  $ThisDirectoryRecord['filename'] = $directorydata['full_path'].$this->ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']);
351  $info['iso']['files'] = Helper::array_merge_clobber($info['iso']['files'], Helper::CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
352  }
353 
354  $DirectoryRecord[] = $ThisDirectoryRecord;
355  $DirectoryRecordData = fread($this->getid3->fp, 1);
356  }
357 
358  return $DirectoryRecord;
359  }
360 
366  public function ISOstripFilenameVersion($ISOfilename)
367  {
368  // convert 'filename.ext;1' to 'filename.ext'
369  if (!strstr($ISOfilename, ';')) {
370  return $ISOfilename;
371  } else {
372  return substr($ISOfilename, 0, strpos($ISOfilename, ';'));
373  }
374  }
375 
381  public function ISOtimeText2UNIXtime($ISOtime)
382  {
383  $UNIXyear = (int) substr($ISOtime, 0, 4);
384  $UNIXmonth = (int) substr($ISOtime, 4, 2);
385  $UNIXday = (int) substr($ISOtime, 6, 2);
386  $UNIXhour = (int) substr($ISOtime, 8, 2);
387  $UNIXminute = (int) substr($ISOtime, 10, 2);
388  $UNIXsecond = (int) substr($ISOtime, 12, 2);
389 
390  if (!$UNIXyear) {
391  return false;
392  }
393 
394  return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
395  }
396 
402  public function ISOtime2UNIXtime($ISOtime)
403  {
404  // Represented by seven bytes:
405  // 1: Number of years since 1900
406  // 2: Month of the year from 1 to 12
407  // 3: Day of the Month from 1 to 31
408  // 4: Hour of the day from 0 to 23
409  // 5: Minute of the hour from 0 to 59
410  // 6: second of the minute from 0 to 59
411  // 7: Offset from Greenwich Mean Time in number of 15 minute intervals from -48 (West) to +52 (East)
412 
413  $UNIXyear = ord($ISOtime{0}) + 1900;
414  $UNIXmonth = ord($ISOtime{1});
415  $UNIXday = ord($ISOtime{2});
416  $UNIXhour = ord($ISOtime{3});
417  $UNIXminute = ord($ISOtime{4});
418  $UNIXsecond = ord($ISOtime{5});
419  $GMToffset = $this->TwosCompliment2Decimal(ord($ISOtime{5}));
420 
421  return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
422  }
423 
429  public function TwosCompliment2Decimal($BinaryValue)
430  {
431  // http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html
432  // First check if the number is negative or positive by looking at the sign bit.
433  // If it is positive, simply convert it to decimal.
434  // If it is negative, make it positive by inverting the bits and adding one.
435  // Then, convert the result to decimal.
436  // The negative of this number is the value of the original binary.
437 
438  if ($BinaryValue & 0x80) {
439 
440  // negative number
441  return (0 - ((~$BinaryValue & 0xFF) + 1));
442  } else {
443  // positive number
444  return $BinaryValue;
445  }
446  }
447 }
ISOtimeText2UNIXtime($ISOtime)
Definition: Iso.php:381
static CreateDeepArray($ArrayPath, $Separator, $Value)
Definition: Helper.php:726
ISOtime2UNIXtime($ISOtime)
Definition: Iso.php:402
ParseDirectoryRecord($directorydata)
Definition: Iso.php:307
ParseSupplementaryVolumeDescriptor(&$ISOheader)
Definition: Iso.php:158
GetId3() by James Heinrich info@getid3.org //.
Definition: BaseHandler.php:25
GetId3() by James Heinrich info@getid3.org //.
Definition: Iso.php:29
TwosCompliment2Decimal($BinaryValue)
Definition: Iso.php:429
fseek($bytes, $whence=SEEK_SET)
$info
Definition: example_052.php:80
ParsePrimaryVolumeDescriptor(&$ISOheader)
Definition: Iso.php:79
Create styles array
The data for the language used.
static array_merge_clobber($array1, $array2)
Definition: Helper.php:561
static LittleEndian2Int($byteword, $signed=false)
Definition: Helper.php:413
ISOstripFilenameVersion($ISOfilename)
Definition: Iso.php:366
static iconv_fallback($in_charset, $out_charset, $string)
array $ConversionFunctionList
Definition: Helper.php:1375