21 $ThisFileInfo[
'fileformat'] =
'iso';
23 for ($i = 16; $i <= 19; $i++) {
24 fseek($fd, 2048 * $i, SEEK_SET);
25 $ISOheader = fread($fd, 2048);
26 if (substr($ISOheader, 1, 5) ==
'CD001') {
27 switch (ord($ISOheader{0})) {
29 $ThisFileInfo[
'iso'][
'primary_volume_descriptor'][
'offset'] = 2048 * $i;
34 $ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'offset'] = 2048 * $i;
47 $ThisFileInfo[
'iso'][
'files'] = array();
48 foreach ($ThisFileInfo[
'iso'][
'path_table'][
'directories'] as $directorynum => $directorydata) {
50 $ThisFileInfo[
'iso'][
'directories'][$directorynum] = $this->
ParseDirectoryRecord($fd, $directorydata, $ThisFileInfo);
64 $ThisFileInfo[
'iso'][
'primary_volume_descriptor'][
'raw'] = array();
65 $thisfile_iso_primaryVD = &$ThisFileInfo[
'iso'][
'primary_volume_descriptor'];
66 $thisfile_iso_primaryVD_raw = &$thisfile_iso_primaryVD[
'raw'];
69 $thisfile_iso_primaryVD_raw[
'standard_identifier'] = substr($ISOheader, 1, 5);
70 if ($thisfile_iso_primaryVD_raw[
'standard_identifier'] !=
'CD001') {
71 $ThisFileInfo[
'error'][] =
'Expected "CD001" at offset ('.($thisfile_iso_primaryVD[
'offset'] + 1).
'), found "'.$thisfile_iso_primaryVD_raw[
'standard_identifier'].
'" instead';
72 unset($ThisFileInfo[
'fileformat']);
73 unset($ThisFileInfo[
'iso']);
80 $thisfile_iso_primaryVD_raw[
'system_identifier'] = substr($ISOheader, 8, 32);
81 $thisfile_iso_primaryVD_raw[
'volume_identifier'] = substr($ISOheader, 40, 32);
93 $thisfile_iso_primaryVD_raw[
'root_directory_record'] = substr($ISOheader, 156, 34);
94 $thisfile_iso_primaryVD_raw[
'volume_set_identifier'] = substr($ISOheader, 190, 128);
95 $thisfile_iso_primaryVD_raw[
'publisher_identifier'] = substr($ISOheader, 318, 128);
96 $thisfile_iso_primaryVD_raw[
'data_preparer_identifier'] = substr($ISOheader, 446, 128);
97 $thisfile_iso_primaryVD_raw[
'application_identifier'] = substr($ISOheader, 574, 128);
98 $thisfile_iso_primaryVD_raw[
'copyright_file_identifier'] = substr($ISOheader, 702, 37);
99 $thisfile_iso_primaryVD_raw[
'abstract_file_identifier'] = substr($ISOheader, 739, 37);
100 $thisfile_iso_primaryVD_raw[
'bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
101 $thisfile_iso_primaryVD_raw[
'volume_creation_date_time'] = substr($ISOheader, 813, 17);
102 $thisfile_iso_primaryVD_raw[
'volume_modification_date_time'] = substr($ISOheader, 830, 17);
103 $thisfile_iso_primaryVD_raw[
'volume_expiration_date_time'] = substr($ISOheader, 847, 17);
104 $thisfile_iso_primaryVD_raw[
'volume_effective_date_time'] = substr($ISOheader, 864, 17);
107 $thisfile_iso_primaryVD_raw[
'application_data'] = substr($ISOheader, 883, 512);
110 $thisfile_iso_primaryVD[
'system_identifier'] = trim($thisfile_iso_primaryVD_raw[
'system_identifier']);
111 $thisfile_iso_primaryVD[
'volume_identifier'] = trim($thisfile_iso_primaryVD_raw[
'volume_identifier']);
112 $thisfile_iso_primaryVD[
'volume_set_identifier'] = trim($thisfile_iso_primaryVD_raw[
'volume_set_identifier']);
113 $thisfile_iso_primaryVD[
'publisher_identifier'] = trim($thisfile_iso_primaryVD_raw[
'publisher_identifier']);
114 $thisfile_iso_primaryVD[
'data_preparer_identifier'] = trim($thisfile_iso_primaryVD_raw[
'data_preparer_identifier']);
115 $thisfile_iso_primaryVD[
'application_identifier'] = trim($thisfile_iso_primaryVD_raw[
'application_identifier']);
116 $thisfile_iso_primaryVD[
'copyright_file_identifier'] = trim($thisfile_iso_primaryVD_raw[
'copyright_file_identifier']);
117 $thisfile_iso_primaryVD[
'abstract_file_identifier'] = trim($thisfile_iso_primaryVD_raw[
'abstract_file_identifier']);
118 $thisfile_iso_primaryVD[
'bibliographic_file_identifier'] = trim($thisfile_iso_primaryVD_raw[
'bibliographic_file_identifier']);
119 $thisfile_iso_primaryVD[
'volume_creation_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw[
'volume_creation_date_time']);
120 $thisfile_iso_primaryVD[
'volume_modification_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw[
'volume_modification_date_time']);
121 $thisfile_iso_primaryVD[
'volume_expiration_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw[
'volume_expiration_date_time']);
122 $thisfile_iso_primaryVD[
'volume_effective_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw[
'volume_effective_date_time']);
124 if (($thisfile_iso_primaryVD_raw[
'volume_space_size'] * 2048) > $ThisFileInfo[
'filesize']) {
125 $ThisFileInfo[
'error'][] =
'Volume Space Size ('.($thisfile_iso_primaryVD_raw[
'volume_space_size'] * 2048).
' bytes) is larger than the file size ('.$ThisFileInfo[
'filesize'].
' bytes) (truncated file?)';
137 $ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'raw'] = array();
138 $thisfile_iso_supplementaryVD = &$ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'];
139 $thisfile_iso_supplementaryVD_raw = &$thisfile_iso_supplementaryVD[
'raw'];
142 $thisfile_iso_supplementaryVD_raw[
'standard_identifier'] = substr($ISOheader, 1, 5);
143 if ($thisfile_iso_supplementaryVD_raw[
'standard_identifier'] !=
'CD001') {
144 $ThisFileInfo[
'error'][] =
'Expected "CD001" at offset ('.($thisfile_iso_supplementaryVD[
'offset'] + 1).
'), found "'.$thisfile_iso_supplementaryVD_raw[
'standard_identifier'].
'" instead';
145 unset($ThisFileInfo[
'fileformat']);
146 unset($ThisFileInfo[
'iso']);
152 $thisfile_iso_supplementaryVD_raw[
'system_identifier'] = substr($ISOheader, 8, 32);
153 $thisfile_iso_supplementaryVD_raw[
'volume_identifier'] = substr($ISOheader, 40, 32);
156 if ($thisfile_iso_supplementaryVD_raw[
'volume_space_size'] == 0) {
171 $thisfile_iso_supplementaryVD_raw[
'root_directory_record'] = substr($ISOheader, 156, 34);
172 $thisfile_iso_supplementaryVD_raw[
'volume_set_identifier'] = substr($ISOheader, 190, 128);
173 $thisfile_iso_supplementaryVD_raw[
'publisher_identifier'] = substr($ISOheader, 318, 128);
174 $thisfile_iso_supplementaryVD_raw[
'data_preparer_identifier'] = substr($ISOheader, 446, 128);
175 $thisfile_iso_supplementaryVD_raw[
'application_identifier'] = substr($ISOheader, 574, 128);
176 $thisfile_iso_supplementaryVD_raw[
'copyright_file_identifier'] = substr($ISOheader, 702, 37);
177 $thisfile_iso_supplementaryVD_raw[
'abstract_file_identifier'] = substr($ISOheader, 739, 37);
178 $thisfile_iso_supplementaryVD_raw[
'bibliographic_file_identifier'] = substr($ISOheader, 776, 37);
179 $thisfile_iso_supplementaryVD_raw[
'volume_creation_date_time'] = substr($ISOheader, 813, 17);
180 $thisfile_iso_supplementaryVD_raw[
'volume_modification_date_time'] = substr($ISOheader, 830, 17);
181 $thisfile_iso_supplementaryVD_raw[
'volume_expiration_date_time'] = substr($ISOheader, 847, 17);
182 $thisfile_iso_supplementaryVD_raw[
'volume_effective_date_time'] = substr($ISOheader, 864, 17);
185 $thisfile_iso_supplementaryVD_raw[
'application_data'] = substr($ISOheader, 883, 512);
188 $thisfile_iso_supplementaryVD[
'system_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'system_identifier']);
189 $thisfile_iso_supplementaryVD[
'volume_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'volume_identifier']);
190 $thisfile_iso_supplementaryVD[
'volume_set_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'volume_set_identifier']);
191 $thisfile_iso_supplementaryVD[
'publisher_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'publisher_identifier']);
192 $thisfile_iso_supplementaryVD[
'data_preparer_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'data_preparer_identifier']);
193 $thisfile_iso_supplementaryVD[
'application_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'application_identifier']);
194 $thisfile_iso_supplementaryVD[
'copyright_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'copyright_file_identifier']);
195 $thisfile_iso_supplementaryVD[
'abstract_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'abstract_file_identifier']);
196 $thisfile_iso_supplementaryVD[
'bibliographic_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw[
'bibliographic_file_identifier']);
197 $thisfile_iso_supplementaryVD[
'volume_creation_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw[
'volume_creation_date_time']);
198 $thisfile_iso_supplementaryVD[
'volume_modification_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw[
'volume_modification_date_time']);
199 $thisfile_iso_supplementaryVD[
'volume_expiration_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw[
'volume_expiration_date_time']);
200 $thisfile_iso_supplementaryVD[
'volume_effective_date_time'] = $this->
ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw[
'volume_effective_date_time']);
202 if (($thisfile_iso_supplementaryVD_raw[
'volume_space_size'] * $thisfile_iso_supplementaryVD_raw[
'logical_block_size']) > $ThisFileInfo[
'filesize']) {
203 $ThisFileInfo[
'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 ('.$ThisFileInfo[
'filesize'].
' bytes) (truncated file?)';
211 if (!isset($ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'raw'][
'path_table_l_location']) && !isset($ThisFileInfo[
'iso'][
'primary_volume_descriptor'][
'raw'][
'path_table_l_location'])) {
214 if (isset($ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'raw'][
'path_table_l_location'])) {
215 $PathTableLocation = $ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'raw'][
'path_table_l_location'];
216 $PathTableSize = $ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'][
'raw'][
'path_table_size'];
217 $TextEncoding =
'UTF-16BE';
219 $PathTableLocation = $ThisFileInfo[
'iso'][
'primary_volume_descriptor'][
'raw'][
'path_table_l_location'];
220 $PathTableSize = $ThisFileInfo[
'iso'][
'primary_volume_descriptor'][
'raw'][
'path_table_size'];
221 $TextEncoding =
'ISO-8859-1';
224 if (($PathTableLocation * 2048) > $ThisFileInfo[
'filesize']) {
225 $ThisFileInfo[
'error'][] =
'Path Table Location specifies an offset ('.($PathTableLocation * 2048).
') beyond the end-of-file ('.$ThisFileInfo[
'filesize'].
')';
229 $ThisFileInfo[
'iso'][
'path_table'][
'offset'] = $PathTableLocation * 2048;
230 fseek($fd, $ThisFileInfo[
'iso'][
'path_table'][
'offset'], SEEK_SET);
231 $ThisFileInfo[
'iso'][
'path_table'][
'raw'] = fread($fd, $PathTableSize);
235 while ($offset < $PathTableSize) {
237 $ThisFileInfo[
'iso'][
'path_table'][
'directories'][$pathcounter] = array();
238 $thisfile_iso_pathtable_directories_current = &$ThisFileInfo[
'iso'][
'path_table'][
'directories'][$pathcounter];
240 $thisfile_iso_pathtable_directories_current[
'length'] =
getid3_lib::LittleEndian2Int(substr($ThisFileInfo[
'iso'][
'path_table'][
'raw'], $offset, 1));
242 $thisfile_iso_pathtable_directories_current[
'extended_length'] =
getid3_lib::LittleEndian2Int(substr($ThisFileInfo[
'iso'][
'path_table'][
'raw'], $offset, 1));
244 $thisfile_iso_pathtable_directories_current[
'location_logical'] =
getid3_lib::LittleEndian2Int(substr($ThisFileInfo[
'iso'][
'path_table'][
'raw'], $offset, 4));
246 $thisfile_iso_pathtable_directories_current[
'parent_directory'] =
getid3_lib::LittleEndian2Int(substr($ThisFileInfo[
'iso'][
'path_table'][
'raw'], $offset, 2));
248 $thisfile_iso_pathtable_directories_current[
'name'] = substr($ThisFileInfo[
'iso'][
'path_table'][
'raw'], $offset, $thisfile_iso_pathtable_directories_current[
'length']);
249 $offset += $thisfile_iso_pathtable_directories_current[
'length'] + ($thisfile_iso_pathtable_directories_current[
'length'] % 2);
251 $thisfile_iso_pathtable_directories_current[
'name_ascii'] =
getid3_lib::iconv_fallback($TextEncoding, $ThisFileInfo[
'encoding'], $thisfile_iso_pathtable_directories_current[
'name']);
253 $thisfile_iso_pathtable_directories_current[
'location_bytes'] = $thisfile_iso_pathtable_directories_current[
'location_logical'] * 2048;
254 if ($pathcounter == 1) {
255 $thisfile_iso_pathtable_directories_current[
'full_path'] =
'/';
257 $thisfile_iso_pathtable_directories_current[
'full_path'] = $ThisFileInfo[
'iso'][
'path_table'][
'directories'][$thisfile_iso_pathtable_directories_current[
'parent_directory']][
'full_path'].$thisfile_iso_pathtable_directories_current[
'name_ascii'].
'/';
259 $FullPathArray[] = $thisfile_iso_pathtable_directories_current[
'full_path'];
269 if (isset($ThisFileInfo[
'iso'][
'supplementary_volume_descriptor'])) {
270 $TextEncoding =
'UTF-16BE';
272 $TextEncoding =
'ISO-8859-1';
275 fseek($fd, $directorydata[
'location_bytes'], SEEK_SET);
276 $DirectoryRecordData = fread($fd, 1);
278 while (ord($DirectoryRecordData{0}) > 33) {
280 $DirectoryRecordData .= fread($fd, ord($DirectoryRecordData{0}) - 1);
286 $ThisDirectoryRecord[
'raw'][
'recording_date_time'] = substr($DirectoryRecordData, 18, 7);
292 $ThisDirectoryRecord[
'raw'][
'file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord[
'raw'][
'file_identifier_length']);
294 $ThisDirectoryRecord[
'file_identifier_ascii'] =
getid3_lib::iconv_fallback($TextEncoding, $ThisFileInfo[
'encoding'], $ThisDirectoryRecord[
'raw'][
'file_identifier']);
296 $ThisDirectoryRecord[
'filesize'] = $ThisDirectoryRecord[
'raw'][
'filesize'];
297 $ThisDirectoryRecord[
'offset_bytes'] = $ThisDirectoryRecord[
'raw'][
'offset_logical'] * 2048;
298 $ThisDirectoryRecord[
'file_flags'][
'hidden'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x01);
299 $ThisDirectoryRecord[
'file_flags'][
'directory'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x02);
300 $ThisDirectoryRecord[
'file_flags'][
'associated'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x04);
301 $ThisDirectoryRecord[
'file_flags'][
'extended'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x08);
302 $ThisDirectoryRecord[
'file_flags'][
'permissions'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x10);
303 $ThisDirectoryRecord[
'file_flags'][
'multiple'] = (bool) ($ThisDirectoryRecord[
'raw'][
'file_flags'] & 0x80);
304 $ThisDirectoryRecord[
'recording_timestamp'] = $this->
ISOtime2UNIXtime($ThisDirectoryRecord[
'raw'][
'recording_date_time']);
306 if ($ThisDirectoryRecord[
'file_flags'][
'directory']) {
307 $ThisDirectoryRecord[
'filename'] = $directorydata[
'full_path'];
309 $ThisDirectoryRecord[
'filename'] = $directorydata[
'full_path'].$this->ISOstripFilenameVersion($ThisDirectoryRecord[
'file_identifier_ascii']);
313 $DirectoryRecord[] = $ThisDirectoryRecord;
314 $DirectoryRecordData = fread($fd, 1);
317 return $DirectoryRecord;
322 if (!strstr($ISOfilename,
';')) {
325 return substr($ISOfilename, 0, strpos($ISOfilename,
';'));
331 $UNIXyear = (int) substr($ISOtime, 0, 4);
332 $UNIXmonth = (int) substr($ISOtime, 4, 2);
333 $UNIXday = (int) substr($ISOtime, 6, 2);
334 $UNIXhour = (int) substr($ISOtime, 8, 2);
335 $UNIXminute = (int) substr($ISOtime, 10, 2);
336 $UNIXsecond = (int) substr($ISOtime, 12, 2);
341 return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
354 $UNIXyear = ord($ISOtime{0}) + 1900;
355 $UNIXmonth = ord($ISOtime{1});
356 $UNIXday = ord($ISOtime{2});
357 $UNIXhour = ord($ISOtime{3});
358 $UNIXminute = ord($ISOtime{4});
359 $UNIXsecond = ord($ISOtime{5});
362 return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
373 if ($BinaryValue & 0x80) {
376 return (0 - ((~$BinaryValue & 0xFF) + 1));