module.archive.xz.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.xz.php //
  11. // module for analyzing XZ 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_xz extends getid3_handler
  19. {
  20. /**
  21. * @return bool
  22. */
  23. public function Analyze() {
  24. $info = &$this->getid3->info;
  25. $this->fseek($info['avdataoffset']);
  26. $xzheader = $this->fread(6);
  27. // https://tukaani.org/xz/xz-file-format-1.0.4.txt
  28. $info['xz']['stream_header']['magic'] = substr($xzheader, 0, 6);
  29. if ($info['xz']['stream_header']['magic'] != "\xFD".'7zXZ'."\x00") {
  30. $this->error('Invalid XZ stream header magic (expecting FD 37 7A 58 5A 00, found '.getid3_lib::PrintHexBytes($info['xz']['stream_header']['magic']).') at offset '.$info['avdataoffset']);
  31. return false;
  32. }
  33. $info['fileformat'] = 'xz';
  34. $this->error('XZ parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
  35. return false;
  36. }
  37. }