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