[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.archive.rar.php
1 <?php
2
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 /////////////////////////////////////////////////////////////////
10 // //
11 // module.archive.rar.php //
12 // module for analyzing RAR files //
13 // dependencies: NONE //
14 // ///
15 /////////////////////////////////////////////////////////////////
16
17
18 class getid3_rar extends getid3_handler
19 {
20 /**
21 * @var bool
22 */
23 public $option_use_rar_extension = false;
24
25 /**
26 * @return bool
27 */
28 public function Analyze() {
29 $info = &$this->getid3->info;
30
31 $info['fileformat'] = 'rar';
32
33 if ($this->option_use_rar_extension === true) {
34 if (function_exists('rar_open')) {
35 if ($rp = rar_open($info['filenamepath'])) {
36 $info['rar']['files'] = array();
37 $entries = rar_list($rp);
38 foreach ($entries as $entry) {
39 $info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
40 }
41 rar_close($rp);
42 return true;
43 } else {
44 $this->error('failed to rar_open('.$info['filename'].')');
45 }
46 } else {
47 $this->error('RAR support does not appear to be available in this PHP installation');
48 }
49 } else {
50 $this->error('PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)');
51 }
52 return false;
53
54 }
55
56 }