module.misc.iso.php - <?php / / getID3() by James Heinrich...

This preview shows page 1 - 4 out of 11 pages.

<?php//////////////////////////////////////////////////////////////////// getID3() by James Heinrich <[email protected]>////available at ////or ////or ////see readme.txt for more details///////////////////////////////////////////////////////////////////////// module.misc.iso.php//// module for analyzing ISO files//// dependencies: NONE////////////////////////////////////////////////////////////////////////if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that accessmodules directly on public webserversexit;}class getid3_iso extends getid3_handler{/*** @return bool*/public function Analyze() {$info = &$this->getid3->info;$info['fileformat'] = 'iso';for ($i = 16; $i <= 19; $i++) {$this->fseek(2048 * $i);$ISOheader = $this->fread(2048);if (substr($ISOheader, 1, 5) == 'CD001') {switch (ord($ISOheader[0])) {case 1:$info['iso']['primary_volume_descriptor']['offset'] = 2048 * $i;$this->ParsePrimaryVolumeDescriptor($ISOheader);break;case 2:$info['iso']['supplementary_volume_descriptor']['offset'] = 2048 * $i;$this->ParseSupplementaryVolumeDescriptor($ISOheader);break;default:// skipbreak;}}}$this->ParsePathTable();
$info['iso']['files'] = array();if (!empty($info['iso']['path_table']['directories'])) {foreach ($info['iso']['path_table']['directories'] as$directorynum => $directorydata) {$info['iso']['directories'][$directorynum] = $this->ParseDirectoryRecord($directorydata);}}return true;}/*** @param string $ISOheader** @return bool*/public function ParsePrimaryVolumeDescriptor(&$ISOheader) {// ISO integer values are stored *BOTH* Little-Endian AND Big-Endianformat!!// ie 12345 == 0x3039is stored as $39 $30 $30 $39 in a 4-byte field// shortcuts$info = &$this->getid3->info;$info['iso']['primary_volume_descriptor']['raw'] = array();$thisfile_iso_primaryVD= &$info['iso']['primary_volume_descriptor'];$thisfile_iso_primaryVD_raw = &$thisfile_iso_primaryVD['raw'];$thisfile_iso_primaryVD_raw['volume_descriptor_type']=getid3_lib::LittleEndian2Int(substr($ISOheader,0, 1));$thisfile_iso_primaryVD_raw['standard_identifier']=substr($ISOheader,1, 5);if ($thisfile_iso_primaryVD_raw['standard_identifier'] != 'CD001') {$this->error('Expected "CD001" at offset ('.($thisfile_iso_primaryVD['offset'] + 1).'), found "'.$thisfile_iso_primaryVD_raw['standard_identifier'].'" instead');unset($info['fileformat']);unset($info['iso']);return false;}$thisfile_iso_primaryVD_raw['volume_descriptor_version']=getid3_lib::LittleEndian2Int(substr($ISOheader,6, 1));//$thisfile_iso_primaryVD_raw['unused_1']=substr($ISOheader,7, 1);$thisfile_iso_primaryVD_raw['system_identifier']=substr($ISOheader,8, 32);$thisfile_iso_primaryVD_raw['volume_identifier']=substr($ISOheader,40, 32);//$thisfile_iso_primaryVD_raw['unused_2']=substr($ISOheader,72, 8);$thisfile_iso_primaryVD_raw['volume_space_size']=getid3_lib::LittleEndian2Int(substr($ISOheader,80, 4));//$thisfile_iso_primaryVD_raw['unused_3']=substr($ISOheader,88, 32);$thisfile_iso_primaryVD_raw['volume_set_size']=getid3_lib::LittleEndian2Int(substr($ISOheader,120, 2));
$thisfile_iso_primaryVD_raw['volume_sequence_number']=getid3_lib::LittleEndian2Int(substr($ISOheader,124, 2));$thisfile_iso_primaryVD_raw['logical_block_size']=getid3_lib::LittleEndian2Int(substr($ISOheader,128, 2));$thisfile_iso_primaryVD_raw['path_table_size']=getid3_lib::LittleEndian2Int(substr($ISOheader,132, 4));$thisfile_iso_primaryVD_raw['path_table_l_location']=getid3_lib::LittleEndian2Int(substr($ISOheader,140, 2));$thisfile_iso_primaryVD_raw['path_table_l_opt_location']=getid3_lib::LittleEndian2Int(substr($ISOheader,144, 2));$thisfile_iso_primaryVD_raw['path_table_m_location']=

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 11 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Summer
Professor
NoProfessor
Tags
Endianness, Negative and non negative numbers, ISO files

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture