File indexing completed on 2024-12-22 05:33:14
0001 <?php 0002 ///////////////////////////////////////////////////////////////// 0003 /// getID3() by James Heinrich <info@getid3.org> // 0004 // available at http://getid3.sourceforge.net // 0005 // or http://www.getid3.org // 0006 // also https://github.com/JamesHeinrich/getID3 // 0007 ///////////////////////////////////////////////////////////////// 0008 // See readme.txt for more details // 0009 ///////////////////////////////////////////////////////////////// 0010 // // 0011 // module.misc.iso.php // 0012 // module for analyzing ISO files // 0013 // dependencies: NONE // 0014 // /// 0015 ///////////////////////////////////////////////////////////////// 0016 0017 0018 class getid3_iso extends getid3_handler 0019 { 0020 0021 public function Analyze() { 0022 $info = &$this->getid3->info; 0023 0024 $info['fileformat'] = 'iso'; 0025 0026 for ($i = 16; $i <= 19; $i++) { 0027 $this->fseek(2048 * $i); 0028 $ISOheader = $this->fread(2048); 0029 if (substr($ISOheader, 1, 5) == 'CD001') { 0030 switch (ord($ISOheader{0})) { 0031 case 1: 0032 $info['iso']['primary_volume_descriptor']['offset'] = 2048 * $i; 0033 $this->ParsePrimaryVolumeDescriptor($ISOheader); 0034 break; 0035 0036 case 2: 0037 $info['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i; 0038 $this->ParseSupplementaryVolumeDescriptor($ISOheader); 0039 break; 0040 0041 default: 0042 // skip 0043 break; 0044 } 0045 } 0046 } 0047 0048 $this->ParsePathTable(); 0049 0050 $info['iso']['files'] = array(); 0051 foreach ($info['iso']['path_table']['directories'] as $directorynum => $directorydata) { 0052 $info['iso']['directories'][$directorynum] = $this->ParseDirectoryRecord($directorydata); 0053 } 0054 0055 return true; 0056 } 0057 0058 0059 public function ParsePrimaryVolumeDescriptor(&$ISOheader) { 0060 // ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!! 0061 // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field 0062 0063 // shortcuts 0064 $info = &$this->getid3->info; 0065 $info['iso']['primary_volume_descriptor']['raw'] = array(); 0066 $thisfile_iso_primaryVD = &$info['iso']['primary_volume_descriptor']; 0067 $thisfile_iso_primaryVD_raw = &$thisfile_iso_primaryVD['raw']; 0068 0069 $thisfile_iso_primaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 0, 1)); 0070 $thisfile_iso_primaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5); 0071 if ($thisfile_iso_primaryVD_raw['standard_identifier'] != 'CD001') { 0072 $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_primaryVD['offset'] + 1).'), found "'.$thisfile_iso_primaryVD_raw['standard_identifier'].'" instead'; 0073 unset($info['fileformat']); 0074 unset($info['iso']); 0075 return false; 0076 } 0077 0078 0079 $thisfile_iso_primaryVD_raw['volume_descriptor_version'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 6, 1)); 0080 //$thisfile_iso_primaryVD_raw['unused_1'] = substr($ISOheader, 7, 1); 0081 $thisfile_iso_primaryVD_raw['system_identifier'] = substr($ISOheader, 8, 32); 0082 $thisfile_iso_primaryVD_raw['volume_identifier'] = substr($ISOheader, 40, 32); 0083 //$thisfile_iso_primaryVD_raw['unused_2'] = substr($ISOheader, 72, 8); 0084 $thisfile_iso_primaryVD_raw['volume_space_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 80, 4)); 0085 //$thisfile_iso_primaryVD_raw['unused_3'] = substr($ISOheader, 88, 32); 0086 $thisfile_iso_primaryVD_raw['volume_set_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 120, 2)); 0087 $thisfile_iso_primaryVD_raw['volume_sequence_number'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 124, 2)); 0088 $thisfile_iso_primaryVD_raw['logical_block_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 128, 2)); 0089 $thisfile_iso_primaryVD_raw['path_table_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 132, 4)); 0090 $thisfile_iso_primaryVD_raw['path_table_l_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 140, 2)); 0091 $thisfile_iso_primaryVD_raw['path_table_l_opt_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 144, 2)); 0092 $thisfile_iso_primaryVD_raw['path_table_m_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 148, 2)); 0093 $thisfile_iso_primaryVD_raw['path_table_m_opt_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 152, 2)); 0094 $thisfile_iso_primaryVD_raw['root_directory_record'] = substr($ISOheader, 156, 34); 0095 $thisfile_iso_primaryVD_raw['volume_set_identifier'] = substr($ISOheader, 190, 128); 0096 $thisfile_iso_primaryVD_raw['publisher_identifier'] = substr($ISOheader, 318, 128); 0097 $thisfile_iso_primaryVD_raw['data_preparer_identifier'] = substr($ISOheader, 446, 128); 0098 $thisfile_iso_primaryVD_raw['application_identifier'] = substr($ISOheader, 574, 128); 0099 $thisfile_iso_primaryVD_raw['copyright_file_identifier'] = substr($ISOheader, 702, 37); 0100 $thisfile_iso_primaryVD_raw['abstract_file_identifier'] = substr($ISOheader, 739, 37); 0101 $thisfile_iso_primaryVD_raw['bibliographic_file_identifier'] = substr($ISOheader, 776, 37); 0102 $thisfile_iso_primaryVD_raw['volume_creation_date_time'] = substr($ISOheader, 813, 17); 0103 $thisfile_iso_primaryVD_raw['volume_modification_date_time'] = substr($ISOheader, 830, 17); 0104 $thisfile_iso_primaryVD_raw['volume_expiration_date_time'] = substr($ISOheader, 847, 17); 0105 $thisfile_iso_primaryVD_raw['volume_effective_date_time'] = substr($ISOheader, 864, 17); 0106 $thisfile_iso_primaryVD_raw['file_structure_version'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 881, 1)); 0107 //$thisfile_iso_primaryVD_raw['unused_4'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 882, 1)); 0108 $thisfile_iso_primaryVD_raw['application_data'] = substr($ISOheader, 883, 512); 0109 //$thisfile_iso_primaryVD_raw['unused_5'] = substr($ISOheader, 1395, 653); 0110 0111 $thisfile_iso_primaryVD['system_identifier'] = trim($thisfile_iso_primaryVD_raw['system_identifier']); 0112 $thisfile_iso_primaryVD['volume_identifier'] = trim($thisfile_iso_primaryVD_raw['volume_identifier']); 0113 $thisfile_iso_primaryVD['volume_set_identifier'] = trim($thisfile_iso_primaryVD_raw['volume_set_identifier']); 0114 $thisfile_iso_primaryVD['publisher_identifier'] = trim($thisfile_iso_primaryVD_raw['publisher_identifier']); 0115 $thisfile_iso_primaryVD['data_preparer_identifier'] = trim($thisfile_iso_primaryVD_raw['data_preparer_identifier']); 0116 $thisfile_iso_primaryVD['application_identifier'] = trim($thisfile_iso_primaryVD_raw['application_identifier']); 0117 $thisfile_iso_primaryVD['copyright_file_identifier'] = trim($thisfile_iso_primaryVD_raw['copyright_file_identifier']); 0118 $thisfile_iso_primaryVD['abstract_file_identifier'] = trim($thisfile_iso_primaryVD_raw['abstract_file_identifier']); 0119 $thisfile_iso_primaryVD['bibliographic_file_identifier'] = trim($thisfile_iso_primaryVD_raw['bibliographic_file_identifier']); 0120 $thisfile_iso_primaryVD['volume_creation_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_creation_date_time']); 0121 $thisfile_iso_primaryVD['volume_modification_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_modification_date_time']); 0122 $thisfile_iso_primaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_expiration_date_time']); 0123 $thisfile_iso_primaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_primaryVD_raw['volume_effective_date_time']); 0124 0125 if (($thisfile_iso_primaryVD_raw['volume_space_size'] * 2048) > $info['filesize']) { 0126 $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?)'; 0127 } 0128 0129 return true; 0130 } 0131 0132 0133 public function ParseSupplementaryVolumeDescriptor(&$ISOheader) { 0134 // ISO integer values are stored Both-Endian format!! 0135 // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field 0136 0137 // shortcuts 0138 $info = &$this->getid3->info; 0139 $info['iso']['supplementary_volume_descriptor']['raw'] = array(); 0140 $thisfile_iso_supplementaryVD = &$info['iso']['supplementary_volume_descriptor']; 0141 $thisfile_iso_supplementaryVD_raw = &$thisfile_iso_supplementaryVD['raw']; 0142 0143 $thisfile_iso_supplementaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 0, 1)); 0144 $thisfile_iso_supplementaryVD_raw['standard_identifier'] = substr($ISOheader, 1, 5); 0145 if ($thisfile_iso_supplementaryVD_raw['standard_identifier'] != 'CD001') { 0146 $info['error'][] = 'Expected "CD001" at offset ('.($thisfile_iso_supplementaryVD['offset'] + 1).'), found "'.$thisfile_iso_supplementaryVD_raw['standard_identifier'].'" instead'; 0147 unset($info['fileformat']); 0148 unset($info['iso']); 0149 return false; 0150 } 0151 0152 $thisfile_iso_supplementaryVD_raw['volume_descriptor_version'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 6, 1)); 0153 //$thisfile_iso_supplementaryVD_raw['unused_1'] = substr($ISOheader, 7, 1); 0154 $thisfile_iso_supplementaryVD_raw['system_identifier'] = substr($ISOheader, 8, 32); 0155 $thisfile_iso_supplementaryVD_raw['volume_identifier'] = substr($ISOheader, 40, 32); 0156 //$thisfile_iso_supplementaryVD_raw['unused_2'] = substr($ISOheader, 72, 8); 0157 $thisfile_iso_supplementaryVD_raw['volume_space_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 80, 4)); 0158 if ($thisfile_iso_supplementaryVD_raw['volume_space_size'] == 0) { 0159 // Supplementary Volume Descriptor not used 0160 //unset($thisfile_iso_supplementaryVD); 0161 //return false; 0162 } 0163 0164 //$thisfile_iso_supplementaryVD_raw['unused_3'] = substr($ISOheader, 88, 32); 0165 $thisfile_iso_supplementaryVD_raw['volume_set_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 120, 2)); 0166 $thisfile_iso_supplementaryVD_raw['volume_sequence_number'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 124, 2)); 0167 $thisfile_iso_supplementaryVD_raw['logical_block_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 128, 2)); 0168 $thisfile_iso_supplementaryVD_raw['path_table_size'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 132, 4)); 0169 $thisfile_iso_supplementaryVD_raw['path_table_l_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 140, 2)); 0170 $thisfile_iso_supplementaryVD_raw['path_table_l_opt_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 144, 2)); 0171 $thisfile_iso_supplementaryVD_raw['path_table_m_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 148, 2)); 0172 $thisfile_iso_supplementaryVD_raw['path_table_m_opt_location'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 152, 2)); 0173 $thisfile_iso_supplementaryVD_raw['root_directory_record'] = substr($ISOheader, 156, 34); 0174 $thisfile_iso_supplementaryVD_raw['volume_set_identifier'] = substr($ISOheader, 190, 128); 0175 $thisfile_iso_supplementaryVD_raw['publisher_identifier'] = substr($ISOheader, 318, 128); 0176 $thisfile_iso_supplementaryVD_raw['data_preparer_identifier'] = substr($ISOheader, 446, 128); 0177 $thisfile_iso_supplementaryVD_raw['application_identifier'] = substr($ISOheader, 574, 128); 0178 $thisfile_iso_supplementaryVD_raw['copyright_file_identifier'] = substr($ISOheader, 702, 37); 0179 $thisfile_iso_supplementaryVD_raw['abstract_file_identifier'] = substr($ISOheader, 739, 37); 0180 $thisfile_iso_supplementaryVD_raw['bibliographic_file_identifier'] = substr($ISOheader, 776, 37); 0181 $thisfile_iso_supplementaryVD_raw['volume_creation_date_time'] = substr($ISOheader, 813, 17); 0182 $thisfile_iso_supplementaryVD_raw['volume_modification_date_time'] = substr($ISOheader, 830, 17); 0183 $thisfile_iso_supplementaryVD_raw['volume_expiration_date_time'] = substr($ISOheader, 847, 17); 0184 $thisfile_iso_supplementaryVD_raw['volume_effective_date_time'] = substr($ISOheader, 864, 17); 0185 $thisfile_iso_supplementaryVD_raw['file_structure_version'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 881, 1)); 0186 //$thisfile_iso_supplementaryVD_raw['unused_4'] = getid3_lib::LittleEndian2Int(substr($ISOheader, 882, 1)); 0187 $thisfile_iso_supplementaryVD_raw['application_data'] = substr($ISOheader, 883, 512); 0188 //$thisfile_iso_supplementaryVD_raw['unused_5'] = substr($ISOheader, 1395, 653); 0189 0190 $thisfile_iso_supplementaryVD['system_identifier'] = trim($thisfile_iso_supplementaryVD_raw['system_identifier']); 0191 $thisfile_iso_supplementaryVD['volume_identifier'] = trim($thisfile_iso_supplementaryVD_raw['volume_identifier']); 0192 $thisfile_iso_supplementaryVD['volume_set_identifier'] = trim($thisfile_iso_supplementaryVD_raw['volume_set_identifier']); 0193 $thisfile_iso_supplementaryVD['publisher_identifier'] = trim($thisfile_iso_supplementaryVD_raw['publisher_identifier']); 0194 $thisfile_iso_supplementaryVD['data_preparer_identifier'] = trim($thisfile_iso_supplementaryVD_raw['data_preparer_identifier']); 0195 $thisfile_iso_supplementaryVD['application_identifier'] = trim($thisfile_iso_supplementaryVD_raw['application_identifier']); 0196 $thisfile_iso_supplementaryVD['copyright_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['copyright_file_identifier']); 0197 $thisfile_iso_supplementaryVD['abstract_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['abstract_file_identifier']); 0198 $thisfile_iso_supplementaryVD['bibliographic_file_identifier'] = trim($thisfile_iso_supplementaryVD_raw['bibliographic_file_identifier']); 0199 $thisfile_iso_supplementaryVD['volume_creation_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_creation_date_time']); 0200 $thisfile_iso_supplementaryVD['volume_modification_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_modification_date_time']); 0201 $thisfile_iso_supplementaryVD['volume_expiration_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_expiration_date_time']); 0202 $thisfile_iso_supplementaryVD['volume_effective_date_time'] = $this->ISOtimeText2UNIXtime($thisfile_iso_supplementaryVD_raw['volume_effective_date_time']); 0203 0204 if (($thisfile_iso_supplementaryVD_raw['volume_space_size'] * $thisfile_iso_supplementaryVD_raw['logical_block_size']) > $info['filesize']) { 0205 $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?)'; 0206 } 0207 0208 return true; 0209 } 0210 0211 0212 public function ParsePathTable() { 0213 $info = &$this->getid3->info; 0214 if (!isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) { 0215 return false; 0216 } 0217 if (isset($info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) { 0218 $PathTableLocation = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']; 0219 $PathTableSize = $info['iso']['supplementary_volume_descriptor']['raw']['path_table_size']; 0220 $TextEncoding = 'UTF-16BE'; // Big-Endian Unicode 0221 } else { 0222 $PathTableLocation = $info['iso']['primary_volume_descriptor']['raw']['path_table_l_location']; 0223 $PathTableSize = $info['iso']['primary_volume_descriptor']['raw']['path_table_size']; 0224 $TextEncoding = 'ISO-8859-1'; // Latin-1 0225 } 0226 0227 if (($PathTableLocation * 2048) > $info['filesize']) { 0228 $info['error'][] = 'Path Table Location specifies an offset ('.($PathTableLocation * 2048).') beyond the end-of-file ('.$info['filesize'].')'; 0229 return false; 0230 } 0231 0232 $info['iso']['path_table']['offset'] = $PathTableLocation * 2048; 0233 $this->fseek($info['iso']['path_table']['offset']); 0234 $info['iso']['path_table']['raw'] = $this->fread($PathTableSize); 0235 0236 $offset = 0; 0237 $pathcounter = 1; 0238 while ($offset < $PathTableSize) { 0239 // shortcut 0240 $info['iso']['path_table']['directories'][$pathcounter] = array(); 0241 $thisfile_iso_pathtable_directories_current = &$info['iso']['path_table']['directories'][$pathcounter]; 0242 0243 $thisfile_iso_pathtable_directories_current['length'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1)); 0244 $offset += 1; 0245 $thisfile_iso_pathtable_directories_current['extended_length'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 1)); 0246 $offset += 1; 0247 $thisfile_iso_pathtable_directories_current['location_logical'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 4)); 0248 $offset += 4; 0249 $thisfile_iso_pathtable_directories_current['parent_directory'] = getid3_lib::LittleEndian2Int(substr($info['iso']['path_table']['raw'], $offset, 2)); 0250 $offset += 2; 0251 $thisfile_iso_pathtable_directories_current['name'] = substr($info['iso']['path_table']['raw'], $offset, $thisfile_iso_pathtable_directories_current['length']); 0252 $offset += $thisfile_iso_pathtable_directories_current['length'] + ($thisfile_iso_pathtable_directories_current['length'] % 2); 0253 0254 $thisfile_iso_pathtable_directories_current['name_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $info['encoding'], $thisfile_iso_pathtable_directories_current['name']); 0255 0256 $thisfile_iso_pathtable_directories_current['location_bytes'] = $thisfile_iso_pathtable_directories_current['location_logical'] * 2048; 0257 if ($pathcounter == 1) { 0258 $thisfile_iso_pathtable_directories_current['full_path'] = '/'; 0259 } else { 0260 $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'].'/'; 0261 } 0262 $FullPathArray[] = $thisfile_iso_pathtable_directories_current['full_path']; 0263 0264 $pathcounter++; 0265 } 0266 0267 return true; 0268 } 0269 0270 0271 public function ParseDirectoryRecord($directorydata) { 0272 $info = &$this->getid3->info; 0273 if (isset($info['iso']['supplementary_volume_descriptor'])) { 0274 $TextEncoding = 'UTF-16BE'; // Big-Endian Unicode 0275 } else { 0276 $TextEncoding = 'ISO-8859-1'; // Latin-1 0277 } 0278 0279 $this->fseek($directorydata['location_bytes']); 0280 $DirectoryRecordData = $this->fread(1); 0281 0282 while (ord($DirectoryRecordData{0}) > 33) { 0283 0284 $DirectoryRecordData .= $this->fread(ord($DirectoryRecordData{0}) - 1); 0285 0286 $ThisDirectoryRecord['raw']['length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 0, 1)); 0287 $ThisDirectoryRecord['raw']['extended_attribute_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 1, 1)); 0288 $ThisDirectoryRecord['raw']['offset_logical'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 2, 4)); 0289 $ThisDirectoryRecord['raw']['filesize'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 10, 4)); 0290 $ThisDirectoryRecord['raw']['recording_date_time'] = substr($DirectoryRecordData, 18, 7); 0291 $ThisDirectoryRecord['raw']['file_flags'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 25, 1)); 0292 $ThisDirectoryRecord['raw']['file_unit_size'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 26, 1)); 0293 $ThisDirectoryRecord['raw']['interleave_gap_size'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 27, 1)); 0294 $ThisDirectoryRecord['raw']['volume_sequence_number'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 28, 2)); 0295 $ThisDirectoryRecord['raw']['file_identifier_length'] = getid3_lib::LittleEndian2Int(substr($DirectoryRecordData, 32, 1)); 0296 $ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']); 0297 0298 $ThisDirectoryRecord['file_identifier_ascii'] = getid3_lib::iconv_fallback($TextEncoding, $info['encoding'], $ThisDirectoryRecord['raw']['file_identifier']); 0299 0300 $ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize']; 0301 $ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048; 0302 $ThisDirectoryRecord['file_flags']['hidden'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x01); 0303 $ThisDirectoryRecord['file_flags']['directory'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x02); 0304 $ThisDirectoryRecord['file_flags']['associated'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x04); 0305 $ThisDirectoryRecord['file_flags']['extended'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x08); 0306 $ThisDirectoryRecord['file_flags']['permissions'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x10); 0307 $ThisDirectoryRecord['file_flags']['multiple'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x80); 0308 $ThisDirectoryRecord['recording_timestamp'] = $this->ISOtime2UNIXtime($ThisDirectoryRecord['raw']['recording_date_time']); 0309 0310 if ($ThisDirectoryRecord['file_flags']['directory']) { 0311 $ThisDirectoryRecord['filename'] = $directorydata['full_path']; 0312 } else { 0313 $ThisDirectoryRecord['filename'] = $directorydata['full_path'].$this->ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']); 0314 $info['iso']['files'] = getid3_lib::array_merge_clobber($info['iso']['files'], getid3_lib::CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize'])); 0315 } 0316 0317 $DirectoryRecord[] = $ThisDirectoryRecord; 0318 $DirectoryRecordData = $this->fread(1); 0319 } 0320 0321 return $DirectoryRecord; 0322 } 0323 0324 public function ISOstripFilenameVersion($ISOfilename) { 0325 // convert 'filename.ext;1' to 'filename.ext' 0326 if (!strstr($ISOfilename, ';')) { 0327 return $ISOfilename; 0328 } else { 0329 return substr($ISOfilename, 0, strpos($ISOfilename, ';')); 0330 } 0331 } 0332 0333 public function ISOtimeText2UNIXtime($ISOtime) { 0334 0335 $UNIXyear = (int) substr($ISOtime, 0, 4); 0336 $UNIXmonth = (int) substr($ISOtime, 4, 2); 0337 $UNIXday = (int) substr($ISOtime, 6, 2); 0338 $UNIXhour = (int) substr($ISOtime, 8, 2); 0339 $UNIXminute = (int) substr($ISOtime, 10, 2); 0340 $UNIXsecond = (int) substr($ISOtime, 12, 2); 0341 0342 if (!$UNIXyear) { 0343 return false; 0344 } 0345 return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear); 0346 } 0347 0348 public function ISOtime2UNIXtime($ISOtime) { 0349 // Represented by seven bytes: 0350 // 1: Number of years since 1900 0351 // 2: Month of the year from 1 to 12 0352 // 3: Day of the Month from 1 to 31 0353 // 4: Hour of the day from 0 to 23 0354 // 5: Minute of the hour from 0 to 59 0355 // 6: second of the minute from 0 to 59 0356 // 7: Offset from Greenwich Mean Time in number of 15 minute intervals from -48 (West) to +52 (East) 0357 0358 $UNIXyear = ord($ISOtime{0}) + 1900; 0359 $UNIXmonth = ord($ISOtime{1}); 0360 $UNIXday = ord($ISOtime{2}); 0361 $UNIXhour = ord($ISOtime{3}); 0362 $UNIXminute = ord($ISOtime{4}); 0363 $UNIXsecond = ord($ISOtime{5}); 0364 $GMToffset = $this->TwosCompliment2Decimal(ord($ISOtime{5})); 0365 0366 return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear); 0367 } 0368 0369 public function TwosCompliment2Decimal($BinaryValue) { 0370 // http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html 0371 // First check if the number is negative or positive by looking at the sign bit. 0372 // If it is positive, simply convert it to decimal. 0373 // If it is negative, make it positive by inverting the bits and adding one. 0374 // Then, convert the result to decimal. 0375 // The negative of this number is the value of the original binary. 0376 0377 if ($BinaryValue & 0x80) { 0378 0379 // negative number 0380 return (0 - ((~$BinaryValue & 0xFF) + 1)); 0381 } else { 0382 // positive number 0383 return $BinaryValue; 0384 } 0385 } 0386 0387 0388 }