annotate e2gallerypro/e2upload/Backend/Assets/getid3/module.misc.iso.php @ 20:1038db2374ec judyates

change address
author Robert McIntyre <rlm@mit.edu>
date Sun, 08 Sep 2013 00:47:09 -0400
parents 3f6b44aa6b35
children
rev   line source
rlm@3 1 <?php
rlm@3 2 // +----------------------------------------------------------------------+
rlm@3 3 // | PHP version 5 |
rlm@3 4 // +----------------------------------------------------------------------+
rlm@3 5 // | Copyright (c) 2002-2006 James Heinrich, Allan Hansen |
rlm@3 6 // +----------------------------------------------------------------------+
rlm@3 7 // | This source file is subject to version 2 of the GPL license, |
rlm@3 8 // | that is bundled with this package in the file license.txt and is |
rlm@3 9 // | available through the world-wide-web at the following url: |
rlm@3 10 // | http://www.gnu.org/copyleft/gpl.html |
rlm@3 11 // +----------------------------------------------------------------------+
rlm@3 12 // | getID3() - http://getid3.sourceforge.net or http://www.getid3.org |
rlm@3 13 // +----------------------------------------------------------------------+
rlm@3 14 // | Authors: James Heinrich <infoØgetid3*org> |
rlm@3 15 // | Allan Hansen <ahØartemis*dk> |
rlm@3 16 // +----------------------------------------------------------------------+
rlm@3 17 // | module.misc.iso.php |
rlm@3 18 // | Module for analyzing ISO files |
rlm@3 19 // | dependencies: NONE |
rlm@3 20 // +----------------------------------------------------------------------+
rlm@3 21 //
rlm@3 22 // $Id: module.misc.iso.php,v 1.3 2006/11/02 10:48:02 ah Exp $
rlm@3 23
rlm@3 24
rlm@3 25
rlm@3 26 class getid3_iso extends getid3_handler
rlm@3 27 {
rlm@3 28
rlm@3 29 public function Analyze() {
rlm@3 30
rlm@3 31 $getid3 = $this->getid3;
rlm@3 32
rlm@3 33 $getid3->info['fileformat'] = 'iso';
rlm@3 34
rlm@3 35 for ($i = 16; $i <= 19; $i++) {
rlm@3 36 fseek($getid3->fp, 2048 * $i, SEEK_SET);
rlm@3 37 $iso_header = fread($getid3->fp, 2048);
rlm@3 38 if (substr($iso_header, 1, 5) == 'CD001') {
rlm@3 39 switch (ord($iso_header{0})) {
rlm@3 40 case 1:
rlm@3 41 $getid3->info['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;
rlm@3 42 $this->ParsePrimaryVolumeDescriptor($iso_header);
rlm@3 43 break;
rlm@3 44
rlm@3 45 case 2:
rlm@3 46 $getid3->info['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;
rlm@3 47 $this->ParseSupplementaryVolumeDescriptor($iso_header);
rlm@3 48 break;
rlm@3 49
rlm@3 50 default:
rlm@3 51 // skip
rlm@3 52 break;
rlm@3 53 }
rlm@3 54 }
rlm@3 55 }
rlm@3 56
rlm@3 57 $this->ParsePathTable();
rlm@3 58
rlm@3 59 $getid3->info['iso']['files'] = array ();
rlm@3 60 foreach ($getid3->info['iso']['path_table']['directories'] as $directory_num => $directory_data) {
rlm@3 61 $getid3->info['iso']['directories'][$directory_num] = $this->ParseDirectoryRecord($directory_data);
rlm@3 62 }
rlm@3 63
rlm@3 64 return true;
rlm@3 65 }
rlm@3 66
rlm@3 67
rlm@3 68
rlm@3 69 private function ParsePrimaryVolumeDescriptor(&$iso_header) {
rlm@3 70
rlm@3 71 $getid3 = $this->getid3;
rlm@3 72
rlm@3 73 // ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!!
rlm@3 74 // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
rlm@3 75
rlm@3 76 $getid3->info['iso']['primary_volume_descriptor']['raw'] = array ();
rlm@3 77 $info_iso_primaryVD = &$getid3->info['iso']['primary_volume_descriptor'];
rlm@3 78 $info_iso_primaryVD_raw = &$info_iso_primaryVD['raw'];
rlm@3 79
rlm@3 80 $info_iso_primaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($iso_header, 0, 1));
rlm@3 81 $info_iso_primaryVD_raw['standard_identifier'] = substr($iso_header, 1, 5);
rlm@3 82 if ($info_iso_primaryVD_raw['standard_identifier'] != 'CD001') {
rlm@3 83 throw new getid3_exception('Expected "CD001" at offset ('.($info_iso_primaryVD['offset'] + 1).'), found "'.$info_iso_primaryVD_raw['standard_identifier'].'" instead');
rlm@3 84 }
rlm@3 85
rlm@3 86 getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_primaryVD_raw, $iso_header, 6,
rlm@3 87 array (
rlm@3 88 'volume_descriptor_version' => 1,
rlm@3 89 'IGNORE-unused_1' => 1,
rlm@3 90 'system_identifier' => -32, // string
rlm@3 91 'volume_identifier' => -32, // string
rlm@3 92 'IGNORE-unused_2' => 8,
rlm@3 93 'volume_space_size' => 4,
rlm@3 94 'IGNORE-1' => 4,
rlm@3 95 'IGNORE-unused_3' => 32,
rlm@3 96 'volume_set_size' => 2,
rlm@3 97 'IGNORE-2' => 2,
rlm@3 98 'volume_sequence_number' => 2,
rlm@3 99 'IGNORE-3' => 2,
rlm@3 100 'logical_block_size' => 2,
rlm@3 101 'IGNORE-4' => 2,
rlm@3 102 'path_table_size' => 4,
rlm@3 103 'IGNORE-5' => 4,
rlm@3 104 'path_table_l_location' => 2,
rlm@3 105 'IGNORE-6' => 2,
rlm@3 106 'path_table_l_opt_location' => 2,
rlm@3 107 'IGNORE-7' => 2,
rlm@3 108 'path_table_m_location' => 2,
rlm@3 109 'IGNORE-8' => 2,
rlm@3 110 'path_table_m_opt_location' => 2,
rlm@3 111 'IGNORE-9' => 2,
rlm@3 112 'root_directory_record' => -34, // string
rlm@3 113 'volume_set_identifier' => -128, // string
rlm@3 114 'publisher_identifier' => -128, // string
rlm@3 115 'data_preparer_identifier' => -128, // string
rlm@3 116 'application_identifier' => -128, // string
rlm@3 117 'copyright_file_identifier' => -37, // string
rlm@3 118 'abstract_file_identifier' => -37, // string
rlm@3 119 'bibliographic_file_identifier' => -37, // string
rlm@3 120 'volume_creation_date_time' => -17, // string
rlm@3 121 'volume_modification_date_time' => -17, // string
rlm@3 122 'volume_expiration_date_time' => -17, // string
rlm@3 123 'volume_effective_date_time' => -17, // string
rlm@3 124 'file_structure_version' => 1,
rlm@3 125 'IGNORE-unused_4' => 1,
rlm@3 126 'application_data' => -512 // string
rlm@3 127 )
rlm@3 128 );
rlm@3 129
rlm@3 130 $info_iso_primaryVD['system_identifier'] = trim($info_iso_primaryVD_raw['system_identifier']);
rlm@3 131 $info_iso_primaryVD['volume_identifier'] = trim($info_iso_primaryVD_raw['volume_identifier']);
rlm@3 132 $info_iso_primaryVD['volume_set_identifier'] = trim($info_iso_primaryVD_raw['volume_set_identifier']);
rlm@3 133 $info_iso_primaryVD['publisher_identifier'] = trim($info_iso_primaryVD_raw['publisher_identifier']);
rlm@3 134 $info_iso_primaryVD['data_preparer_identifier'] = trim($info_iso_primaryVD_raw['data_preparer_identifier']);
rlm@3 135 $info_iso_primaryVD['application_identifier'] = trim($info_iso_primaryVD_raw['application_identifier']);
rlm@3 136 $info_iso_primaryVD['copyright_file_identifier'] = trim($info_iso_primaryVD_raw['copyright_file_identifier']);
rlm@3 137 $info_iso_primaryVD['abstract_file_identifier'] = trim($info_iso_primaryVD_raw['abstract_file_identifier']);
rlm@3 138 $info_iso_primaryVD['bibliographic_file_identifier'] = trim($info_iso_primaryVD_raw['bibliographic_file_identifier']);
rlm@3 139
rlm@3 140 $info_iso_primaryVD['volume_creation_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_creation_date_time']);
rlm@3 141 $info_iso_primaryVD['volume_modification_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_modification_date_time']);
rlm@3 142 $info_iso_primaryVD['volume_expiration_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_expiration_date_time']);
rlm@3 143 $info_iso_primaryVD['volume_effective_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_effective_date_time']);
rlm@3 144
rlm@3 145 if (($info_iso_primaryVD_raw['volume_space_size'] * 2048) > $getid3->info['filesize']) {
rlm@3 146 throw new getid3_exception('Volume Space Size ('.($info_iso_primaryVD_raw['volume_space_size'] * 2048).' bytes) is larger than the file size ('.$getid3->info['filesize'].' bytes) (truncated file?)');
rlm@3 147 }
rlm@3 148
rlm@3 149 return true;
rlm@3 150 }
rlm@3 151
rlm@3 152
rlm@3 153
rlm@3 154 private function ParseSupplementaryVolumeDescriptor(&$iso_header) {
rlm@3 155
rlm@3 156 $getid3 = $this->getid3;
rlm@3 157
rlm@3 158 // ISO integer values are stored Both-Endian format!!
rlm@3 159 // ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
rlm@3 160
rlm@3 161 $getid3->info['iso']['supplementary_volume_descriptor']['raw'] = array ();
rlm@3 162 $info_iso_supplementaryVD = &$getid3->info['iso']['supplementary_volume_descriptor'];
rlm@3 163 $info_iso_supplementaryVD_raw = &$info_iso_supplementaryVD['raw'];
rlm@3 164
rlm@3 165 $info_iso_supplementaryVD_raw['volume_descriptor_type'] = getid3_lib::LittleEndian2Int(substr($iso_header, 0, 1));
rlm@3 166 $info_iso_supplementaryVD_raw['standard_identifier'] = substr($iso_header, 1, 5);
rlm@3 167 if ($info_iso_supplementaryVD_raw['standard_identifier'] != 'CD001') {
rlm@3 168 throw new getid3_exception('Expected "CD001" at offset ('.($info_iso_supplementaryVD['offset'] + 1).'), found "'.$info_iso_supplementaryVD_raw['standard_identifier'].'" instead');
rlm@3 169 }
rlm@3 170
rlm@3 171 getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_supplementaryVD_raw, $iso_header, 6,
rlm@3 172 array (
rlm@3 173 'volume_descriptor_version' => 1,
rlm@3 174 'IGNORE-unused_1' => -1,
rlm@3 175 'system_identifier' => -32,
rlm@3 176 'volume_identifier' => -32,
rlm@3 177 'IGNORE-unused_2' => -8,
rlm@3 178 'volume_space_size' => 4,
rlm@3 179 'IGNORE-1' => 4,
rlm@3 180 'IGNORE-unused_3' => -32,
rlm@3 181 'volume_set_size' => 2,
rlm@3 182 'IGNORE-2' => 2,
rlm@3 183 'volume_sequence_number' => 2,
rlm@3 184 'IGNORE-3' => 2,
rlm@3 185 'logical_block_size' => 2,
rlm@3 186 'IGNORE-4' => 2,
rlm@3 187 'path_table_size' => 4,
rlm@3 188 'IGNORE-5' => 4,
rlm@3 189 'path_table_l_location' => 2,
rlm@3 190 'IGNORE-6' => 2,
rlm@3 191 'path_table_l_opt_location' => 2,
rlm@3 192 'IGNORE-7' => 2,
rlm@3 193 'path_table_m_location' => 2,
rlm@3 194 'IGNORE-8' => 2,
rlm@3 195 'path_table_m_opt_location' => 2,
rlm@3 196 'IGNORE-9' => 2,
rlm@3 197 'root_directory_record' => -34,
rlm@3 198 'volume_set_identifier' => -128,
rlm@3 199 'publisher_identifier' => -128,
rlm@3 200 'data_preparer_identifier' => -128,
rlm@3 201 'application_identifier' => -128,
rlm@3 202 'copyright_file_identifier' => -37,
rlm@3 203 'abstract_file_identifier' => -37,
rlm@3 204 'bibliographic_file_identifier' => -37,
rlm@3 205 'volume_creation_date_time' => -17,
rlm@3 206 'volume_modification_date_time' => -17,
rlm@3 207 'volume_expiration_date_time' => -17,
rlm@3 208 'volume_effective_date_time' => -17,
rlm@3 209 'file_structure_version' => 1,
rlm@3 210 'IGNORE-unused_4' => 1,
rlm@3 211 'application_data' => -512
rlm@3 212 )
rlm@3 213 );
rlm@3 214
rlm@3 215 $info_iso_supplementaryVD['system_identifier'] = trim($info_iso_supplementaryVD_raw['system_identifier']);
rlm@3 216 $info_iso_supplementaryVD['volume_identifier'] = trim($info_iso_supplementaryVD_raw['volume_identifier']);
rlm@3 217 $info_iso_supplementaryVD['volume_set_identifier'] = trim($info_iso_supplementaryVD_raw['volume_set_identifier']);
rlm@3 218 $info_iso_supplementaryVD['publisher_identifier'] = trim($info_iso_supplementaryVD_raw['publisher_identifier']);
rlm@3 219 $info_iso_supplementaryVD['data_preparer_identifier'] = trim($info_iso_supplementaryVD_raw['data_preparer_identifier']);
rlm@3 220 $info_iso_supplementaryVD['application_identifier'] = trim($info_iso_supplementaryVD_raw['application_identifier']);
rlm@3 221 $info_iso_supplementaryVD['copyright_file_identifier'] = trim($info_iso_supplementaryVD_raw['copyright_file_identifier']);
rlm@3 222 $info_iso_supplementaryVD['abstract_file_identifier'] = trim($info_iso_supplementaryVD_raw['abstract_file_identifier']);
rlm@3 223 $info_iso_supplementaryVD['bibliographic_file_identifier'] = trim($info_iso_supplementaryVD_raw['bibliographic_file_identifier']);
rlm@3 224
rlm@3 225 $info_iso_supplementaryVD['volume_creation_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_creation_date_time']);
rlm@3 226 $info_iso_supplementaryVD['volume_modification_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_modification_date_time']);
rlm@3 227 $info_iso_supplementaryVD['volume_expiration_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_expiration_date_time']);
rlm@3 228 $info_iso_supplementaryVD['volume_effective_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_effective_date_time']);
rlm@3 229
rlm@3 230 if (($info_iso_supplementaryVD_raw['volume_space_size'] * $info_iso_supplementaryVD_raw['logical_block_size']) > $getid3->info['filesize']) {
rlm@3 231 throw new getid3_exception('Volume Space Size ('.($info_iso_supplementaryVD_raw['volume_space_size'] * $info_iso_supplementaryVD_raw['logical_block_size']).' bytes) is larger than the file size ('.$getid3->info['filesize'].' bytes) (truncated file?)');
rlm@3 232 }
rlm@3 233
rlm@3 234 return true;
rlm@3 235 }
rlm@3 236
rlm@3 237
rlm@3 238
rlm@3 239 private function ParsePathTable() {
rlm@3 240
rlm@3 241 $getid3 = $this->getid3;
rlm@3 242
rlm@3 243 if (!isset($getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
rlm@3 244 return false;
rlm@3 245 }
rlm@3 246 if (isset($getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'])) {
rlm@3 247 $path_table_location = $getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
rlm@3 248 $path_table_size = $getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
rlm@3 249 $text_encoding = 'UTF-16BE'; // Big-Endian Unicode
rlm@3 250 }
rlm@3 251 else {
rlm@3 252 $path_table_location = $getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
rlm@3 253 $path_table_size = $getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_size'];
rlm@3 254 $text_encoding = 'ISO-8859-1'; // Latin-1
rlm@3 255 }
rlm@3 256
rlm@3 257 if (($path_table_location * 2048) > $getid3->info['filesize']) {
rlm@3 258 throw new getid3_exception('Path Table Location specifies an offset ('.($path_table_location * 2048).') beyond the end-of-file ('.$getid3->info['filesize'].')');
rlm@3 259 }
rlm@3 260
rlm@3 261 $getid3->info['iso']['path_table']['offset'] = $path_table_location * 2048;
rlm@3 262 fseek($getid3->fp, $getid3->info['iso']['path_table']['offset'], SEEK_SET);
rlm@3 263 $getid3->info['iso']['path_table']['raw'] = fread($getid3->fp, $path_table_size);
rlm@3 264
rlm@3 265 $offset = 0;
rlm@3 266 $pathcounter = 1;
rlm@3 267 while ($offset < $path_table_size) {
rlm@3 268
rlm@3 269 $getid3->info['iso']['path_table']['directories'][$pathcounter] = array ();
rlm@3 270 $info_iso_pathtable_directories_current = &$getid3->info['iso']['path_table']['directories'][$pathcounter];
rlm@3 271
rlm@3 272 getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_pathtable_directories_current, $getid3->info['iso']['path_table']['raw'], $offset,
rlm@3 273 array (
rlm@3 274 'length' => 1,
rlm@3 275 'extended_length' => 1,
rlm@3 276 'location_logical' => 4,
rlm@3 277 'parent_directory' => 2,
rlm@3 278 )
rlm@3 279 );
rlm@3 280
rlm@3 281 $info_iso_pathtable_directories_current['name'] = substr($getid3->info['iso']['path_table']['raw'], $offset+8, $info_iso_pathtable_directories_current['length']);
rlm@3 282
rlm@3 283 $offset += 8 + $info_iso_pathtable_directories_current['length'] + ($info_iso_pathtable_directories_current['length'] % 2);
rlm@3 284
rlm@3 285 $info_iso_pathtable_directories_current['name_ascii'] = $getid3->iconv($text_encoding, $getid3->encoding, $info_iso_pathtable_directories_current['name'], true);
rlm@3 286
rlm@3 287 $info_iso_pathtable_directories_current['location_bytes'] = $info_iso_pathtable_directories_current['location_logical'] * 2048;
rlm@3 288 if ($pathcounter == 1) {
rlm@3 289 $info_iso_pathtable_directories_current['full_path'] = '/';
rlm@3 290 }
rlm@3 291 else {
rlm@3 292 $info_iso_pathtable_directories_current['full_path'] = $getid3->info['iso']['path_table']['directories'][$info_iso_pathtable_directories_current['parent_directory']]['full_path'].$info_iso_pathtable_directories_current['name_ascii'].'/';
rlm@3 293 }
rlm@3 294 $full_path_array[] = $info_iso_pathtable_directories_current['full_path'];
rlm@3 295
rlm@3 296 $pathcounter++;
rlm@3 297 }
rlm@3 298
rlm@3 299 return true;
rlm@3 300 }
rlm@3 301
rlm@3 302
rlm@3 303
rlm@3 304 private function ParseDirectoryRecord($directory_data) {
rlm@3 305
rlm@3 306 $getid3 = $this->getid3;
rlm@3 307
rlm@3 308 $text_encoding = isset($getid3->info['iso']['supplementary_volume_descriptor']) ? 'UTF-16BE' : 'ISO-8859-1';
rlm@3 309
rlm@3 310 fseek($getid3->fp, $directory_data['location_bytes'], SEEK_SET);
rlm@3 311 $directory_record_data = fread($getid3->fp, 1);
rlm@3 312
rlm@3 313 while (ord($directory_record_data{0}) > 33) {
rlm@3 314
rlm@3 315 $directory_record_data .= fread($getid3->fp, ord($directory_record_data{0}) - 1);
rlm@3 316
rlm@3 317 $this_directory_record = array ();
rlm@3 318 $this_directory_record['raw'] = array ();
rlm@3 319 $this_directory_record_raw = &$this_directory_record['raw'];
rlm@3 320
rlm@3 321 getid3_lib::ReadSequence('LittleEndian2Int', $this_directory_record_raw, $directory_record_data, 0,
rlm@3 322 array (
rlm@3 323 'length' => 1,
rlm@3 324 'extended_attribute_length' => 1,
rlm@3 325 'offset_logical' => 4,
rlm@3 326 'IGNORE-1' => 4,
rlm@3 327 'filesize' => 4,
rlm@3 328 'IGNORE-2' => 4,
rlm@3 329 'recording_date_time' => -7,
rlm@3 330 'file_flags' => 1,
rlm@3 331 'file_unit_size' => 1,
rlm@3 332 'interleave_gap_size' => 1,
rlm@3 333 'volume_sequence_number' => 2,
rlm@3 334 'IGNORE-3' => 2,
rlm@3 335 'file_identifier_length' => 1,
rlm@3 336 )
rlm@3 337 );
rlm@3 338
rlm@3 339 $this_directory_record_raw['file_identifier'] = substr($directory_record_data, 33, $this_directory_record_raw['file_identifier_length']);
rlm@3 340
rlm@3 341 $this_directory_record['file_identifier_ascii'] = $getid3->iconv($text_encoding, $getid3->encoding, $this_directory_record_raw['file_identifier'], true);
rlm@3 342 $this_directory_record['filesize'] = $this_directory_record_raw['filesize'];
rlm@3 343 $this_directory_record['offset_bytes'] = $this_directory_record_raw['offset_logical'] * 2048;
rlm@3 344 $this_directory_record['file_flags']['hidden'] = (bool)($this_directory_record_raw['file_flags'] & 0x01);
rlm@3 345 $this_directory_record['file_flags']['directory'] = (bool)($this_directory_record_raw['file_flags'] & 0x02);
rlm@3 346 $this_directory_record['file_flags']['associated'] = (bool)($this_directory_record_raw['file_flags'] & 0x04);
rlm@3 347 $this_directory_record['file_flags']['extended'] = (bool)($this_directory_record_raw['file_flags'] & 0x08);
rlm@3 348 $this_directory_record['file_flags']['permissions'] = (bool)($this_directory_record_raw['file_flags'] & 0x10);
rlm@3 349 $this_directory_record['file_flags']['multiple'] = (bool)($this_directory_record_raw['file_flags'] & 0x80);
rlm@3 350 $this_directory_record['recording_timestamp'] = getid3_iso::ISOtime2UNIXtime($this_directory_record_raw['recording_date_time']);
rlm@3 351
rlm@3 352 if ($this_directory_record['file_flags']['directory']) {
rlm@3 353 $this_directory_record['filename'] = $directory_data['full_path'];
rlm@3 354 }
rlm@3 355 else {
rlm@3 356 $this_directory_record['filename'] = $directory_data['full_path'].getid3_iso::ISOstripFilenameVersion($this_directory_record['file_identifier_ascii']);
rlm@3 357 $getid3->info['iso']['files'] = getid3_iso::array_merge_clobber($getid3->info['iso']['files'], getid3_iso::CreateDeepArray($this_directory_record['filename'], '/', $this_directory_record['filesize']));
rlm@3 358 }
rlm@3 359
rlm@3 360 $directory_record[] = $this_directory_record;
rlm@3 361 $directory_record_data = fread($getid3->fp, 1);
rlm@3 362 }
rlm@3 363
rlm@3 364 return $directory_record;
rlm@3 365 }
rlm@3 366
rlm@3 367
rlm@3 368
rlm@3 369 public static function ISOstripFilenameVersion($iso_filename) {
rlm@3 370
rlm@3 371 // convert 'filename.ext;1' to 'filename.ext'
rlm@3 372 if (!strstr($iso_filename, ';')) {
rlm@3 373 return $iso_filename;
rlm@3 374 }
rlm@3 375 return substr($iso_filename, 0, strpos($iso_filename, ';'));
rlm@3 376 }
rlm@3 377
rlm@3 378
rlm@3 379
rlm@3 380 public static function ISOtimeText2UNIXtime($iso_time) {
rlm@3 381
rlm@3 382 if (!(int)substr($iso_time, 0, 4)) {
rlm@3 383 return false;
rlm@3 384 }
rlm@3 385
rlm@3 386 return gmmktime((int)substr($iso_time, 8, 2), (int)substr($iso_time, 10, 2), (int)substr($iso_time, 12, 2), (int)substr($iso_time, 4, 2), (int)substr($iso_time, 6, 2), (int)substr($iso_time, 0, 4));
rlm@3 387 }
rlm@3 388
rlm@3 389
rlm@3 390
rlm@3 391 public static function ISOtime2UNIXtime($iso_time) {
rlm@3 392
rlm@3 393 // Represented by seven bytes:
rlm@3 394 // 1: Number of years since 1900
rlm@3 395 // 2: Month of the year from 1 to 12
rlm@3 396 // 3: Day of the Month from 1 to 31
rlm@3 397 // 4: Hour of the day from 0 to 23
rlm@3 398 // 5: Minute of the hour from 0 to 59
rlm@3 399 // 6: second of the minute from 0 to 59
rlm@3 400 // 7: Offset from Greenwich Mean Time in number of 15 minute intervals from -48 (West) to +52 (East)
rlm@3 401
rlm@3 402 return gmmktime(ord($iso_time[3]), ord($iso_time[4]), ord($iso_time[5]), ord($iso_time[1]), ord($iso_time[2]), ord($iso_time[0]) + 1900);
rlm@3 403 }
rlm@3 404
rlm@3 405
rlm@3 406
rlm@3 407 public static function array_merge_clobber($array1, $array2) {
rlm@3 408
rlm@3 409 // written by kcØhireability*com
rlm@3 410 // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
rlm@3 411
rlm@3 412 if (!is_array($array1) || !is_array($array2)) {
rlm@3 413 return false;
rlm@3 414 }
rlm@3 415
rlm@3 416 $newarray = $array1;
rlm@3 417 foreach ($array2 as $key => $val) {
rlm@3 418 if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
rlm@3 419 $newarray[$key] = getid3_iso::array_merge_clobber($newarray[$key], $val);
rlm@3 420 } else {
rlm@3 421 $newarray[$key] = $val;
rlm@3 422 }
rlm@3 423 }
rlm@3 424 return $newarray;
rlm@3 425 }
rlm@3 426
rlm@3 427
rlm@3 428
rlm@3 429 public static function CreateDeepArray($array_path, $separator, $value) {
rlm@3 430
rlm@3 431 // assigns $value to a nested array path:
rlm@3 432 // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
rlm@3 433 // is the same as:
rlm@3 434 // $foo = array ('path'=>array('to'=>'array('my'=>array('file.txt'))));
rlm@3 435 // or
rlm@3 436 // $foo['path']['to']['my'] = 'file.txt';
rlm@3 437
rlm@3 438 while ($array_path{0} == $separator) {
rlm@3 439 $array_path = substr($array_path, 1);
rlm@3 440 }
rlm@3 441 if (($pos = strpos($array_path, $separator)) !== false) {
rlm@3 442 return array (substr($array_path, 0, $pos) => getid3_iso::CreateDeepArray(substr($array_path, $pos + 1), $separator, $value));
rlm@3 443 }
rlm@3 444
rlm@3 445 return array ($array_path => $value);
rlm@3 446 }
rlm@3 447
rlm@3 448 }
rlm@3 449
rlm@3 450 ?>