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