module.archive.rar.php 1.8 KB

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