Fix reading database list with MySQL wildcards (bug #1487613).
[phpmyadmin/last10db.git] / server_engines.php
blob4575b3f1b06503667aeb8ac1303271815f67814f
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 /**
5 * display list of server enignes and additonal information about them
6 */
8 if ( ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
9 define( 'PMA_NO_VARIABLES_IMPORT', true );
12 /**
13 * requirements
15 require_once('./libraries/common.lib.php');
17 /**
18 * Does the common work
20 require('./libraries/server_common.inc.php');
21 require('./libraries/storage_engines.lib.php');
24 /**
25 * Displays the links
27 require('./libraries/server_links.inc.php');
29 /**
30 * defines
32 define('PMA_ENGINE_DETAILS_TYPE_PLAINTEXT', 0);
33 define('PMA_ENGINE_DETAILS_TYPE_SIZE', 1);
34 define('PMA_ENGINE_DETAILS_TYPE_NUMERIC', 2); //Has no effect yet...
35 define('PMA_ENGINE_DETAILS_TYPE_BOOLEAN', 3); // 'ON' or 'OFF'
37 /**
38 * Function for displaying the table of an engine's parameters
40 * @param array List of MySQL variables and corresponding localized descriptions.
41 * The array elements should have the following format:
42 * $variable => array('title' => $title, 'desc' => $description);
43 * @param string Prefix for the SHOW VARIABLES query.
44 * @return string The table that was generated based on the given information.
46 function PMA_generateEngineDetails($variables, $like = null) {
48 /**
49 * Get the variables!
51 if (!empty($variables)) {
52 $sql_query = 'SHOW '
53 . (PMA_MYSQL_INT_VERSION >= 40102 ? 'GLOBAL ' : '')
54 . 'VARIABLES'
55 . (empty($like) ? '' : ' LIKE \'' . $like . '\'')
56 . ';';
57 $res = PMA_DBI_query($sql_query);
58 $mysql_vars = array();
59 while ($row = PMA_DBI_fetch_row($res)) {
60 if (isset($variables[$row[0]])) {
61 $mysql_vars[$row[0]] = $row[1];
64 PMA_DBI_free_result($res);
65 unset($res, $row, $sql_query);
68 if (empty($mysql_vars)) {
69 return '<p>' . "\n"
70 . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n"
71 . '</p>' . "\n";
74 $dt_table = '<table class="data">' . "\n";
75 $odd_row = false;
76 $has_content = false;
78 foreach ($variables as $var => $details) {
79 if (!isset($mysql_vars[$var])) {
80 continue;
83 if (!isset($details['type'])) {
84 $details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
86 $is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE
87 || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;
89 $dt_table .= '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n"
90 . ' <td>' . "\n";
91 if (!empty($variables[$var]['desc'])) {
92 $dt_table .= ' ' . PMA_showHint($details['desc']) . "\n";
94 $dt_table .= ' </td>' . "\n"
95 . ' <th>'
96 . htmlspecialchars( empty($details['title'])
97 ? $var : $details['title'] ) . "\n"
98 . ' </th>' . "\n"
99 . ' <td class="value">';
100 switch ($details['type']) {
101 case PMA_ENGINE_DETAILS_TYPE_SIZE:
102 $parsed_size = PMA_formatByteDown($mysql_vars[$var]);
103 $dt_table .= $parsed_size[0] . '&nbsp;' . $parsed_size[1];
104 unset($parsed_size);
105 break;
106 case PMA_ENGINE_DETAILS_TYPE_NUMERIC:
107 $dt_table .= PMA_formatNumber($mysql_vars[$var]) . ' ';
108 break;
109 default:
110 $dt_table .= htmlspecialchars($mysql_vars[$var]) . ' ';
112 $dt_table .= '</td>' . "\n"
113 . '</tr>' . "\n";
114 $odd_row = !$odd_row;
115 $has_content = true;
118 if (!$has_content) {
119 return '';
122 $dt_table .= '</table>' . "\n";
124 return $dt_table;
129 * Did the user request information about a certain storage engine?
131 if ( empty($_REQUEST['engine'])
132 || empty($mysql_storage_engines[$_REQUEST['engine']]) ) {
135 * Displays the sub-page heading
137 echo '<h2>' . "\n"
138 . ($GLOBALS['cfg']['MainPageIconic']
139 ? '<img class="icon" src="' . $pmaThemeImage . 'b_engine.png"'
140 .' width="16" height="16" alt="" />' : '' )
141 . "\n" . $strStorageEngines . "\n"
142 . '</h2>' . "\n";
146 * Displays the table header
148 echo '<table>' . "\n"
149 . '<thead>' . "\n"
150 . '<tr><th>' . $strStorageEngine . '</th>' . "\n";
151 if (PMA_MYSQL_INT_VERSION >= 40102) {
152 echo ' <th>' . $strDescription . '</th>' . "\n";
154 echo '</tr>' . "\n"
155 . '</thead>' . "\n"
156 . '<tbody>' . "\n";
160 * Listing the storage engines
162 $odd_row = true;
163 foreach ($mysql_storage_engines as $engine => $details) {
164 echo '<tr class="'
165 . ($odd_row ? 'odd' : 'even')
166 . ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED'
167 ? ' disabled'
168 : '')
169 . '">' . "\n"
170 . ' <td><a href="./server_engines.php'
171 . PMA_generate_common_url(array( 'engine' => $engine )) . '">' . "\n"
172 . ' ' . htmlspecialchars($details['Engine']) . "\n"
173 . ' </a>' . "\n"
174 . ' </td>' . "\n";
175 if (PMA_MYSQL_INT_VERSION >= 40102) {
176 echo ' <td>' . htmlspecialchars($details['Comment']) . "\n"
177 . ' </td>' . "\n";
179 echo '</tr>' . "\n";
180 $odd_row = !$odd_row;
182 unset($odd_row, $engine, $details);
183 echo '</tbody>' . "\n"
184 . '</table>' . "\n";
186 } else {
189 * Displays details about a given Storage Engine
192 $engine_plugin = PMA_StorageEngine::getEngine($_REQUEST['engine']);
193 echo '<h2>' . "\n"
194 . ($GLOBALS['cfg']['MainPageIconic']
195 ? '<img class="icon" src="' . $pmaThemeImage . 'b_engine.png"'
196 .' width="16" height="16" alt="" />' : '' )
197 . ' ' . htmlspecialchars($engine_plugin->getTitle()) . "\n"
198 . ' ' . PMA_showMySQLDocu( '', $engine_plugin->getMysqlHelpPage() ) . "\n"
199 . '</h2>' . "\n\n";
200 if (PMA_MYSQL_INT_VERSION >= 40102) {
201 echo '<p>' . "\n"
202 . ' <em>' . "\n"
203 . ' ' . htmlspecialchars($engine_plugin->getComment()) . "\n"
204 . ' </em>' . "\n"
205 . '</p>' . "\n\n";
207 $infoPages = $engine_plugin->getInfoPages();
208 if (!empty($infoPages) && is_array($infoPages)) {
209 echo '<p>' . "\n"
210 . ' <strong>[</strong>' . "\n";
211 if (empty($_REQUEST['page'])) {
212 echo ' <strong>' . $strServerTabVariables . '</strong>' . "\n";
213 } else {
214 echo ' <a href="./server_engines.php'
215 . PMA_generate_common_url(array( 'engine' => $_REQUEST['engine'] )) . '">'
216 . $strServerTabVariables . '</a>' . "\n";
218 foreach ($infoPages as $current => $label) {
219 echo ' <strong>|</strong>' . "\n";
220 if (isset($_REQUEST['page']) && $_REQUEST['page'] == $current) {
221 echo ' <strong>' . $label . '</strong>' . "\n";
222 } else {
223 echo ' <a href="./server_engines.php'
224 . PMA_generate_common_url(
225 array( 'engine' => $_REQUEST['engine'], 'page' => $current ))
226 . '">' . htmlspecialchars($label) . '</a>' . "\n";
229 unset($current, $label);
230 echo ' <strong>]</strong>' . "\n"
231 . '</p>' . "\n\n";
233 unset($infoPages, $page_output);
234 if (!empty($_REQUEST['page'])) {
235 $page_output = $engine_plugin->getPage($_REQUEST['page']);
237 if (!empty($page_output)) {
238 echo $page_output;
239 } else {
240 echo '<p> ' . $engine_plugin->getSupportInformationMessage() . "\n"
241 . '</p>' . "\n"
242 . PMA_generateEngineDetails($engine_plugin->getVariables(),
243 $engine_plugin->getVariablesLikePattern());
248 * Sends the footer
250 require_once('./libraries/footer.inc.php');