module.audio.mod.php 3.0 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
  16. {
  17. // new combined constructor
  18. function getid3_mod(&$fd, &$ThisFileInfo, $option) {
  19. if ($option === 'mod') {
  20. $this->getMODheaderFilepointer($fd, $ThisFileInfo);
  21. }
  22. elseif ($option === 'xm') {
  23. $this->getXMheaderFilepointer($fd, $ThisFileInfo);
  24. }
  25. elseif ($option === 'it') {
  26. $this->getITheaderFilepointer($fd, $ThisFileInfo);
  27. }
  28. elseif ($option === 's3m') {
  29. $this->getS3MheaderFilepointer($fd, $ThisFileInfo);
  30. }
  31. }
  32. function getMODheaderFilepointer(&$fd, &$ThisFileInfo) {
  33. fseek($fd, $ThisFileInfo['avdataoffset'] + 1080);
  34. $FormatID = fread($fd, 4);
  35. if (!ereg('^(M.K.|[5-9]CHN|[1-3][0-9]CH)$', $FormatID)) {
  36. $ThisFileInfo['error'][] = 'This is not a known type of MOD file';
  37. return false;
  38. }
  39. $ThisFileInfo['fileformat'] = 'mod';
  40. $ThisFileInfo['error'][] = 'MOD parsing not enabled in this version of getID3()';
  41. return false;
  42. }
  43. function getXMheaderFilepointer(&$fd, &$ThisFileInfo) {
  44. fseek($fd, $ThisFileInfo['avdataoffset']);
  45. $FormatID = fread($fd, 15);
  46. if (!ereg('^Extended Module$', $FormatID)) {
  47. $ThisFileInfo['error'][] = 'This is not a known type of XM-MOD file';
  48. return false;
  49. }
  50. $ThisFileInfo['fileformat'] = 'xm';
  51. $ThisFileInfo['error'][] = 'XM-MOD parsing not enabled in this version of getID3()';
  52. return false;
  53. }
  54. function getS3MheaderFilepointer(&$fd, &$ThisFileInfo) {
  55. fseek($fd, $ThisFileInfo['avdataoffset'] + 44);
  56. $FormatID = fread($fd, 4);
  57. if (!ereg('^SCRM$', $FormatID)) {
  58. $ThisFileInfo['error'][] = 'This is not a ScreamTracker MOD file';
  59. return false;
  60. }
  61. $ThisFileInfo['fileformat'] = 's3m';
  62. $ThisFileInfo['error'][] = 'ScreamTracker parsing not enabled in this version of getID3()';
  63. return false;
  64. }
  65. function getITheaderFilepointer(&$fd, &$ThisFileInfo) {
  66. fseek($fd, $ThisFileInfo['avdataoffset']);
  67. $FormatID = fread($fd, 4);
  68. if (!ereg('^IMPM$', $FormatID)) {
  69. $ThisFileInfo['error'][] = 'This is not an ImpulseTracker MOD file';
  70. return false;
  71. }
  72. $ThisFileInfo['fileformat'] = 'it';
  73. $ThisFileInfo['error'][] = 'ImpulseTracker parsing not enabled in this version of getID3()';
  74. return false;
  75. }
  76. }
  77. ?>