1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Holds the PhpMyAdmin\Controllers\Server\PluginsController |
6
|
|
|
* |
7
|
|
|
* @package PhpMyAdmin\Controllers |
8
|
|
|
*/ |
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace PhpMyAdmin\Controllers\Server; |
12
|
|
|
|
13
|
|
|
use PhpMyAdmin\Controllers\Controller; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Handles viewing server plugin details |
17
|
|
|
* |
18
|
|
|
* @package PhpMyAdmin\Controllers |
19
|
|
|
*/ |
20
|
|
|
class PluginsController extends Controller |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var array plugin details |
24
|
|
|
*/ |
25
|
|
|
private $plugins; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Constructs PluginsController |
29
|
|
|
* |
30
|
|
|
* @param \PhpMyAdmin\Response $response Response object |
31
|
|
|
* @param \PhpMyAdmin\DatabaseInterface $dbi DatabaseInterface object |
32
|
|
|
*/ |
33
|
|
|
public function __construct($response, $dbi) |
34
|
|
|
{ |
35
|
|
|
parent::__construct($response, $dbi); |
36
|
|
|
$this->setPlugins(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Index action |
41
|
|
|
* |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
public function index(): string |
45
|
|
|
{ |
46
|
|
|
include ROOT_PATH . 'libraries/server_common.inc.php'; |
47
|
|
|
|
48
|
|
|
$header = $this->response->getHeader(); |
49
|
|
|
$scripts = $header->getScripts(); |
50
|
|
|
$scripts->addFile('vendor/jquery/jquery.tablesorter.js'); |
51
|
|
|
$scripts->addFile('server_plugins.js'); |
52
|
|
|
|
53
|
|
|
$pluginsTypeClean = []; |
54
|
|
|
foreach (array_keys($this->plugins) as $pluginType) { |
55
|
|
|
$pluginsTypeClean[$pluginType] = preg_replace( |
56
|
|
|
'/[^a-z]/', |
57
|
|
|
'', |
58
|
|
|
mb_strtolower($pluginType) |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
return $this->template->render('server/plugins/index', [ |
62
|
|
|
'plugins' => $this->plugins, |
63
|
|
|
'plugins_type_clean' => $pluginsTypeClean, |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Sets details about server plugins |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
private function setPlugins(): void |
73
|
|
|
{ |
74
|
|
|
$sql = "SELECT plugin_name, |
75
|
|
|
plugin_type, |
76
|
|
|
(plugin_status = 'ACTIVE') AS is_active, |
77
|
|
|
plugin_type_version, |
78
|
|
|
plugin_author, |
79
|
|
|
plugin_description, |
80
|
|
|
plugin_license |
81
|
|
|
FROM information_schema.plugins |
82
|
|
|
ORDER BY plugin_type, plugin_name"; |
83
|
|
|
|
84
|
|
|
$res = $this->dbi->query($sql); |
85
|
|
|
$this->plugins = []; |
86
|
|
|
while ($row = $this->dbi->fetchAssoc($res)) { |
|
|
|
|
87
|
|
|
$this->plugins[$row['plugin_type']][] = $row; |
88
|
|
|
} |
89
|
|
|
$this->dbi->freeResult($res); |
|
|
|
|
90
|
|
|
ksort($this->plugins); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|