module.archive.rar.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // also https://github.com/JamesHeinrich/getID3 //
  7. /////////////////////////////////////////////////////////////////
  8. // See readme.txt for more details //
  9. /////////////////////////////////////////////////////////////////
  10. // //
  11. // module.archive.rar.php //
  12. // module for analyzing RAR files //
  13. // dependencies: NONE //
  14. // ///
  15. /////////////////////////////////////////////////////////////////
  16. class getid3_rar extends getid3_handler
  17. {
  18. public $option_use_rar_extension = false;
  19. public function Analyze() {
  20. $info = &$this->getid3->info;
  21. $info['fileformat'] = 'rar';
  22. if ($this->option_use_rar_extension === true) {
  23. if (function_exists('rar_open')) {
  24. if ($rp = rar_open($info['filenamepath'])) {
  25. $info['rar']['files'] = array();
  26. $entries = rar_list($rp);
  27. foreach ($entries as $entry) {
  28. $info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
  29. }
  30. rar_close($rp);
  31. return true;
  32. } else {
  33. $info['error'][] = 'failed to rar_open('.$info['filename'].')';
  34. }
  35. } else {
  36. $info['error'][] = 'RAR support does not appear to be available in this PHP installation';
  37. }
  38. } else {
  39. $info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
  40. }
  41. return false;
  42. }
  43. }