708d213b4eef8cabbae9230c2f0d3261daacb735
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio.mod.php
1 <?php
2
3 /////////////////////////////////////////////////////////////////
4 /// getID3() by James Heinrich <info@getid3.org> //
5 // available at https://github.com/JamesHeinrich/getID3 //
6 // or https://www.getid3.org //
7 // or http://getid3.sourceforge.net //
8 // see readme.txt for more details //
9 /////////////////////////////////////////////////////////////////
10 // //
11 // module.audio.mod.php //
12 // module for analyzing MOD Audio files //
13 // dependencies: NONE //
14 // ///
15 /////////////////////////////////////////////////////////////////
16
17
18 class getid3_mod extends getid3_handler
19 {
20 /**
21 * @return bool
22 */
23 public function Analyze() {
24 $info = &$this->getid3->info;
25 $this->fseek($info['avdataoffset']);
26 $fileheader = $this->fread(1088);
27 if (preg_match('#^IMPM#', $fileheader)) {
28 return $this->getITheaderFilepointer();
29 } elseif (preg_match('#^Extended Module#', $fileheader)) {
30 return $this->getXMheaderFilepointer();
31 } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
32 return $this->getS3MheaderFilepointer();
33 } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
34 return $this->getMODheaderFilepointer();
35 }
36 $this->error('This is not a known type of MOD file');
37 return false;
38 }
39
40 /**
41 * @return bool
42 */
43 public function getMODheaderFilepointer() {
44 $info = &$this->getid3->info;
45 $this->fseek($info['avdataoffset'] + 1080);
46 $FormatID = $this->fread(4);
47 if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
48 $this->error('This is not a known type of MOD file');
49 return false;
50 }
51
52 $info['fileformat'] = 'mod';
53
54 $this->error('MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
55 return false;
56 }
57
58 /**
59 * @return bool
60 */
61 public function getXMheaderFilepointer() {
62 $info = &$this->getid3->info;
63 $this->fseek($info['avdataoffset']);
64 $FormatID = $this->fread(15);
65 if (!preg_match('#^Extended Module$#', $FormatID)) {
66 $this->error('This is not a known type of XM-MOD file');
67 return false;
68 }
69
70 $info['fileformat'] = 'xm';
71
72 $this->error('XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
73 return false;
74 }
75
76 /**
77 * @return bool
78 */
79 public function getS3MheaderFilepointer() {
80 $info = &$this->getid3->info;
81 $this->fseek($info['avdataoffset'] + 44);
82 $FormatID = $this->fread(4);
83 if (!preg_match('#^SCRM$#', $FormatID)) {
84 $this->error('This is not a ScreamTracker MOD file');
85 return false;
86 }
87
88 $info['fileformat'] = 's3m';
89
90 $this->error('ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
91 return false;
92 }
93
94 /**
95 * @return bool
96 */
97 public function getITheaderFilepointer() {
98 $info = &$this->getid3->info;
99 $this->fseek($info['avdataoffset']);
100 $FormatID = $this->fread(4);
101 if (!preg_match('#^IMPM$#', $FormatID)) {
102 $this->error('This is not an ImpulseTracker MOD file');
103 return false;
104 }
105
106 $info['fileformat'] = 'it';
107
108 $this->error('ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
109 return false;
110 }
111
112 }