3 /////////////////////////////////////////////////////////////////
4 /// getID3() by James Heinrich <info@getid3.org> //
5 // available at https://github.com/JamesHeinrich/getID3 //
6 // or https://www.getid3.org //
7 // or http://getid3.sourceforge.net //
8 // see readme.txt for more details //
9 /////////////////////////////////////////////////////////////////
11 // module.archive.rar.php //
12 // module for analyzing RAR files //
13 // dependencies: NONE //
15 /////////////////////////////////////////////////////////////////
17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
21 class getid3_rar
extends getid3_handler
26 public $option_use_rar_extension = false;
31 public function Analyze() {
32 $info = &$this->getid3
->info
;
34 $info['fileformat'] = 'rar';
36 if ($this->option_use_rar_extension
=== true) {
37 if (function_exists('rar_open')) {
38 if ($rp = rar_open($info['filenamepath'])) {
39 $info['rar']['files'] = array();
40 $entries = rar_list($rp);
41 foreach ($entries as $entry) {
42 $info['rar']['files'] = getid3_lib
::array_merge_clobber($info['rar']['files'], getid3_lib
::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
47 $this->error('failed to rar_open('.$info['filename'].')');
50 $this->error('RAR support does not appear to be available in this PHP installation');
53 $this->error('PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)');