[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio.mod.php
1 <?php
2 /////////////////////////////////////////////////////////////////
3 /// getID3() by James Heinrich <info@getid3.org> //
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
6 // also https://github.com/JamesHeinrich/getID3 //
7 /////////////////////////////////////////////////////////////////
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 public function Analyze() {
22 $info = &$this->getid3->info;
23 $this->fseek($info['avdataoffset']);
24 $fileheader = $this->fread(1088);
25 if (preg_match('#^IMPM#', $fileheader)) {
26 return $this->getITheaderFilepointer();
27 } elseif (preg_match('#^Extended Module#', $fileheader)) {
28 return $this->getXMheaderFilepointer();
29 } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
30 return $this->getS3MheaderFilepointer();
31 } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
32 return $this->getMODheaderFilepointer();
33 }
34 $this->error('This is not a known type of MOD file');
35 return false;
36 }
37
38
39 public function getMODheaderFilepointer() {
40 $info = &$this->getid3->info;
41 $this->fseek($info['avdataoffset'] + 1080);
42 $FormatID = $this->fread(4);
43 if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
44 $this->error('This is not a known type of MOD file');
45 return false;
46 }
47
48 $info['fileformat'] = 'mod';
49
50 $this->error('MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
51 return false;
52 }
53
54 public function getXMheaderFilepointer() {
55 $info = &$this->getid3->info;
56 $this->fseek($info['avdataoffset']);
57 $FormatID = $this->fread(15);
58 if (!preg_match('#^Extended Module$#', $FormatID)) {
59 $this->error('This is not a known type of XM-MOD file');
60 return false;
61 }
62
63 $info['fileformat'] = 'xm';
64
65 $this->error('XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
66 return false;
67 }
68
69 public function getS3MheaderFilepointer() {
70 $info = &$this->getid3->info;
71 $this->fseek($info['avdataoffset'] + 44);
72 $FormatID = $this->fread(4);
73 if (!preg_match('#^SCRM$#', $FormatID)) {
74 $this->error('This is not a ScreamTracker MOD file');
75 return false;
76 }
77
78 $info['fileformat'] = 's3m';
79
80 $this->error('ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
81 return false;
82 }
83
84 public function getITheaderFilepointer() {
85 $info = &$this->getid3->info;
86 $this->fseek($info['avdataoffset']);
87 $FormatID = $this->fread(4);
88 if (!preg_match('#^IMPM$#', $FormatID)) {
89 $this->error('This is not an ImpulseTracker MOD file');
90 return false;
91 }
92
93 $info['fileformat'] = 'it';
94
95 $this->error('ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
96 return false;
97 }
98
99 }