File indexing completed on 2025-01-26 05:25:49
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.audio.mod.php // 0012 // module for analyzing MOD Audio files // 0013 // dependencies: NONE // 0014 // /// 0015 ///////////////////////////////////////////////////////////////// 0016 0017 0018 class getid3_mod extends getid3_handler 0019 { 0020 0021 public function Analyze() { 0022 $info = &$this->getid3->info; 0023 $this->fseek($info['avdataoffset']); 0024 $fileheader = $this->fread(1088); 0025 if (preg_match('#^IMPM#', $fileheader)) { 0026 return $this->getITheaderFilepointer(); 0027 } elseif (preg_match('#^Extended Module#', $fileheader)) { 0028 return $this->getXMheaderFilepointer(); 0029 } elseif (preg_match('#^.{44}SCRM#', $fileheader)) { 0030 return $this->getS3MheaderFilepointer(); 0031 } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) { 0032 return $this->getMODheaderFilepointer(); 0033 } 0034 $info['error'][] = 'This is not a known type of MOD file'; 0035 return false; 0036 } 0037 0038 0039 public function getMODheaderFilepointer() { 0040 $info = &$this->getid3->info; 0041 $this->fseek($info['avdataoffset'] + 1080); 0042 $FormatID = $this->fread(4); 0043 if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) { 0044 $info['error'][] = 'This is not a known type of MOD file'; 0045 return false; 0046 } 0047 0048 $info['fileformat'] = 'mod'; 0049 0050 $info['error'][] = 'MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']'; 0051 return false; 0052 } 0053 0054 public function getXMheaderFilepointer() { 0055 $info = &$this->getid3->info; 0056 $this->fseek($info['avdataoffset']); 0057 $FormatID = $this->fread(15); 0058 if (!preg_match('#^Extended Module$#', $FormatID)) { 0059 $info['error'][] = 'This is not a known type of XM-MOD file'; 0060 return false; 0061 } 0062 0063 $info['fileformat'] = 'xm'; 0064 0065 $info['error'][] = 'XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']'; 0066 return false; 0067 } 0068 0069 public function getS3MheaderFilepointer() { 0070 $info = &$this->getid3->info; 0071 $this->fseek($info['avdataoffset'] + 44); 0072 $FormatID = $this->fread(4); 0073 if (!preg_match('#^SCRM$#', $FormatID)) { 0074 $info['error'][] = 'This is not a ScreamTracker MOD file'; 0075 return false; 0076 } 0077 0078 $info['fileformat'] = 's3m'; 0079 0080 $info['error'][] = 'ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']'; 0081 return false; 0082 } 0083 0084 public function getITheaderFilepointer() { 0085 $info = &$this->getid3->info; 0086 $this->fseek($info['avdataoffset']); 0087 $FormatID = $this->fread(4); 0088 if (!preg_match('#^IMPM$#', $FormatID)) { 0089 $info['error'][] = 'This is not an ImpulseTracker MOD file'; 0090 return false; 0091 } 0092 0093 $info['fileformat'] = 'it'; 0094 0095 $info['error'][] = 'ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']'; 0096 return false; 0097 } 0098 0099 }