module.audio.mod.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /////////////////////////////////////////////////////////////////
  7. // See readme.txt for more details //
  8. /////////////////////////////////////////////////////////////////
  9. // //
  10. // module.audio.mod.php //
  11. // module for analyzing MOD Audio files //
  12. // dependencies: NONE //
  13. // ///
  14. /////////////////////////////////////////////////////////////////
  15. class getid3_mod extends getid3_handler
  16. {
  17. function Analyze() {
  18. $info = &$this->getid3->info;
  19. fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
  20. $fileheader = fread($this->getid3->fp, 1088);
  21. if (preg_match('#^IMPM#', $fileheader)) {
  22. return $this->getITheaderFilepointer();
  23. } elseif (preg_match('#^Extended Module#', $fileheader)) {
  24. return $this->getXMheaderFilepointer();
  25. } elseif (preg_match('#^.{44}SCRM#', $fileheader)) {
  26. return $this->getS3MheaderFilepointer();
  27. } elseif (preg_match('#^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)#', $fileheader)) {
  28. return $this->getMODheaderFilepointer();
  29. }
  30. $info['error'][] = 'This is not a known type of MOD file';
  31. return false;
  32. }
  33. function getMODheaderFilepointer() {
  34. $info = &$this->getid3->info;
  35. fseek($this->getid3->fp, $info['avdataoffset'] + 1080);
  36. $FormatID = fread($this->getid3->fp, 4);
  37. if (!preg_match('#^(M.K.|[5-9]CHN|[1-3][0-9]CH)$#', $FormatID)) {
  38. $info['error'][] = 'This is not a known type of MOD file';
  39. return false;
  40. }
  41. $info['fileformat'] = 'mod';
  42. $info['error'][] = 'MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
  43. return false;
  44. }
  45. function getXMheaderFilepointer() {
  46. $info = &$this->getid3->info;
  47. fseek($this->getid3->fp, $info['avdataoffset']);
  48. $FormatID = fread($this->getid3->fp, 15);
  49. if (!preg_match('#^Extended Module$#', $FormatID)) {
  50. $info['error'][] = 'This is not a known type of XM-MOD file';
  51. return false;
  52. }
  53. $info['fileformat'] = 'xm';
  54. $info['error'][] = 'XM-MOD parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
  55. return false;
  56. }
  57. function getS3MheaderFilepointer() {
  58. $info = &$this->getid3->info;
  59. fseek($this->getid3->fp, $info['avdataoffset'] + 44);
  60. $FormatID = fread($this->getid3->fp, 4);
  61. if (!preg_match('#^SCRM$#', $FormatID)) {
  62. $info['error'][] = 'This is not a ScreamTracker MOD file';
  63. return false;
  64. }
  65. $info['fileformat'] = 's3m';
  66. $info['error'][] = 'ScreamTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
  67. return false;
  68. }
  69. function getITheaderFilepointer() {
  70. $info = &$this->getid3->info;
  71. fseek($this->getid3->fp, $info['avdataoffset']);
  72. $FormatID = fread($this->getid3->fp, 4);
  73. if (!preg_match('#^IMPM$#', $FormatID)) {
  74. $info['error'][] = 'This is not an ImpulseTracker MOD file';
  75. return false;
  76. }
  77. $info['fileformat'] = 'it';
  78. $info['error'][] = 'ImpulseTracker parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
  79. return false;
  80. }
  81. }
  82. ?>