ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Mod.php
Go to the documentation of this file.
1 <?php
2 
3 namespace GetId3\Module\Audio;
4 
6 
9 // available at http://getid3.sourceforge.net //
10 // or http://www.getid3.org //
12 // See readme.txt for more details //
14 // //
15 // module.audio.mod.php //
16 // module for analyzing MOD Audio files //
17 // dependencies: NONE //
18 // ///
20 
28 class Mod extends BaseHandler
29 {
30 
35  public function analyze()
36  {
37  $info = &$this->getid3->info;
38  fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
39  $fileheader = fread($this->getid3->fp, 1088);
40  if (preg_match('#^IMPM#', $fileheader)) {
41  return $this->getITheaderFilepointer();
42  } elseif (preg_match('#^Extended Module#', $fileheader)) {
43  return $this->getXMheaderFilepointer();
44  } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
45  return $this->getS3MheaderFilepointer();
46  } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
47  return $this->getMODheaderFilepointer();
48  }
49  $info['error'][] = 'This is not a known type of MOD file';
50 
51  return false;
52  }
53 
58  public function getMODheaderFilepointer()
59  {
60  $info = &$this->getid3->info;
61  fseek($this->getid3->fp, $info['avdataoffset'] + 1080);
62  $FormatID = fread($this->getid3->fp, 4);
63  if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
64  $info['error'][] = 'This is not a known type of MOD file';
65 
66  return false;
67  }
68 
69  $info['fileformat'] = 'mod';
70 
71  $info['error'][] = 'MOD parsing not enabled in this version of GetId3Core() ['.$this->getid3->version().']';
72 
73  return false;
74  }
75 
80  public function getXMheaderFilepointer()
81  {
82  $info = &$this->getid3->info;
83  fseek($this->getid3->fp, $info['avdataoffset']);
84  $FormatID = fread($this->getid3->fp, 15);
85  if (!preg_match('#^Extended Module$#', $FormatID)) {
86  $info['error'][] = 'This is not a known type of XM-MOD file';
87 
88  return false;
89  }
90 
91  $info['fileformat'] = 'xm';
92 
93  $info['error'][] = 'XM-MOD parsing not enabled in this version of GetId3Core() ['.$this->getid3->version().']';
94 
95  return false;
96  }
97 
102  public function getS3MheaderFilepointer()
103  {
104  $info = &$this->getid3->info;
105  fseek($this->getid3->fp, $info['avdataoffset'] + 44);
106  $FormatID = fread($this->getid3->fp, 4);
107  if (!preg_match('#^SCRM$#', $FormatID)) {
108  $info['error'][] = 'This is not a ScreamTracker MOD file';
109 
110  return false;
111  }
112 
113  $info['fileformat'] = 's3m';
114 
115  $info['error'][] = 'ScreamTracker parsing not enabled in this version of GetId3Core() ['.$this->getid3->version().']';
116 
117  return false;
118  }
119 
124  public function getITheaderFilepointer()
125  {
126  $info = &$this->getid3->info;
127  fseek($this->getid3->fp, $info['avdataoffset']);
128  $FormatID = fread($this->getid3->fp, 4);
129  if (!preg_match('#^IMPM$#', $FormatID)) {
130  $info['error'][] = 'This is not an ImpulseTracker MOD file';
131 
132  return false;
133  }
134 
135  $info['fileformat'] = 'it';
136 
137  $info['error'][] = 'ImpulseTracker parsing not enabled in this version of GetId3Core() ['.$this->getid3->version().']';
138 
139  return false;
140  }
141 }
GetId3() by James Heinrich info@getid3.org //.
Definition: Mod.php:28
GetId3() by James Heinrich info@getid3.org //.
Definition: BaseHandler.php:25
fseek($bytes, $whence=SEEK_SET)
$info
Definition: example_052.php:80