module.graphic.efax.php 2.4 KB

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