-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
server_plugins.lib.php
124 lines (113 loc) · 3.38 KB
/
server_plugins.lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* functions for displaying server plugins
*
* @usedby server_plugins.php
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Returns the common SQL used to retrieve plugin data
*
* @return string SQL
*/
function PMA_getServerPluginSQL()
{
return "SELECT plugin_name, plugin_type, (plugin_status = 'ACTIVE') AS is_active,
plugin_type_version, plugin_author, plugin_description, plugin_license
FROM information_schema.plugins
ORDER BY plugin_type, plugin_name";
}
/**
* Returns details about server plugins
*
* @return array server plugins data
*/
function PMA_getServerPlugins()
{
$sql = PMA_getServerPluginSQL();
$res = $GLOBALS['dbi']->query($sql);
$plugins = array();
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
$plugins[$row['plugin_type']][] = $row;
}
$GLOBALS['dbi']->freeResult($res);
ksort($plugins);
return $plugins;
}
/**
* Returns the html for plugin Tab.
*
* @param Array $plugins list
*
* @return string
*/
function PMA_getPluginTab($plugins)
{
$html = '<br /><div id="plugins_plugins">';
$html .= '<div id="sectionlinks">';
foreach ($plugins as $plugin_type => $plugin_list) {
$key = 'plugins-'
. preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
$html .= '<a href="#' . $key . '">'
. htmlspecialchars($plugin_type) . '</a>' . "\n";
}
$html .= '</div>';
$html .= '<br />';
foreach ($plugins as $plugin_type => $plugin_list) {
$key = 'plugins-'
. preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
sort($plugin_list);
$html .= '<table class="data_full_width" id="' . $key . '">';
$html .= '<caption class="tblHeaders">';
$html .= htmlspecialchars($plugin_type);
$html .= '</caption>';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>' . __('Plugin') . '</th>';
$html .= '<th>' . __('Description') . '</th>';
$html .= '<th>' . __('Version') . '</th>';
$html .= '<th>' . __('Author') . '</th>';
$html .= '<th>' . __('License') . '</th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
$html .= PMA_getPluginList($plugin_list);
$html .= '</tbody>';
$html .= '</table>';
}
$html .= '</div>';
return $html;
}
/**
* Returns the html for plugin List.
*
* @param Array $plugin_list list
*
* @return string
*/
function PMA_getPluginList($plugin_list)
{
$html = "";
$odd_row = false;
foreach ($plugin_list as $plugin) {
$odd_row = !$odd_row;
$html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
$html .= '<th>';
$html .= htmlspecialchars($plugin['plugin_name']);
if (! $plugin['is_active']) {
$html .= ' <small class="attention">' . __('disabled') . '</small>';
}
$html .= '</th>';
$html .= '<td>' . htmlspecialchars($plugin['plugin_description']) . '</td>';
$html .= '<td>' . htmlspecialchars($plugin['plugin_type_version']) . '</td>';
$html .= '<td>' . htmlspecialchars($plugin['plugin_author']) . '</td>';
$html .= '<td>' . htmlspecialchars($plugin['plugin_license']) . '</td>';
$html .= '</tr>';
}
return $html;
}