module.graphic.efax.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.archive.efax.php //
  11. // module for analyzing eFax 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_efax extends getid3_handler
  19. {
  20. /**
  21. * @return bool
  22. */
  23. public function Analyze() {
  24. $info = &$this->getid3->info;
  25. $this->fseek($info['avdataoffset']);
  26. $efaxheader = $this->fread(1024);
  27. $info['efax']['header']['magic'] = substr($efaxheader, 0, 2);
  28. if ($info['efax']['header']['magic'] != "\xDC\xFE") {
  29. $this->error('Invalid eFax byte order identifier (expecting DC FE, found '.getid3_lib::PrintHexBytes($info['efax']['header']['magic']).') at offset '.$info['avdataoffset']);
  30. return false;
  31. }
  32. $info['fileformat'] = 'efax';
  33. $info['efax']['header']['filesize'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 2, 4));
  34. if ($info['efax']['header']['filesize'] != $info['filesize']) {
  35. $this->error('Probable '.(($info['efax']['header']['filesize'] > $info['filesize']) ? 'truncated' : 'corrupt').' file, expecting '.$info['efax']['header']['filesize'].' bytes, found '.$info['filesize'].' bytes');
  36. }
  37. $info['efax']['header']['software1'] = rtrim(substr($efaxheader, 26, 32), "\x00");
  38. $info['efax']['header']['software2'] = rtrim(substr($efaxheader, 58, 32), "\x00");
  39. $info['efax']['header']['software3'] = rtrim(substr($efaxheader, 90, 32), "\x00");
  40. $info['efax']['header']['pages'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 198, 2));
  41. $info['efax']['header']['data_bytes'] = getid3_lib::LittleEndian2Int(substr($efaxheader, 202, 4));
  42. $this->error('eFax parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
  43. return false;
  44. }
  45. }