module.misc.msoffice.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at https://github.com/JamesHeinrich/getID3 //
  5. // or https://www.getid3.org //
  6. // or http://getid3.sourceforge.net //
  7. // see readme.txt for more details //
  8. /////////////////////////////////////////////////////////////////
  9. // //
  10. // module.misc.msoffice.php //
  11. // module for analyzing MS Office (.doc, .xls, etc) files //
  12. // dependencies: NONE //
  13. // ///
  14. /////////////////////////////////////////////////////////////////
  15. if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
  16. exit;
  17. }
  18. class getid3_msoffice extends getid3_handler
  19. {
  20. /**
  21. * @return bool
  22. */
  23. public function Analyze() {
  24. $info = &$this->getid3->info;
  25. $this->fseek($info['avdataoffset']);
  26. $DOCFILEheader = $this->fread(8);
  27. $magic = "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1";
  28. if (substr($DOCFILEheader, 0, 8) != $magic) {
  29. $this->error('Expecting "'.getid3_lib::PrintHexBytes($magic).'" at '.$info['avdataoffset'].', found '.getid3_lib::PrintHexBytes(substr($DOCFILEheader, 0, 8)).' instead.');
  30. return false;
  31. }
  32. $info['fileformat'] = 'msoffice';
  33. $this->error('MS Office (.doc, .xls, etc) parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
  34. return false;
  35. }
  36. }