Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: server_engines.php,v 2.16 2005/12/07 09:52:16 cybot_tm Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 /**
5 * display list of server enignes and additonal information about them
6 */
7  
8 if ( ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
9 define( 'PMA_NO_VARIABLES_IMPORT', true );
10 }
11  
12 /**
13 * requirements
14 */
15 require_once('./libraries/common.lib.php');
16  
17 /**
18 * Does the common work
19 */
20 require('./libraries/server_common.inc.php');
21 require('./libraries/storage_engines.lib.php');
22  
23  
24 /**
25 * Displays the links
26 */
27 require('./libraries/server_links.inc.php');
28  
29 /**
30 * defines
31 */
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'
36  
37 /**
38 * Function for displaying the table of an engine's parameters
39 *
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.
45 */
46 function PMA_generateEngineDetails($variables, $like = null) {
47  
48 /**
49 * Get the variables!
50 */
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];
62 }
63 }
64 PMA_DBI_free_result($res);
65 unset($res, $row, $sql_query);
66 }
67  
68 if (empty($mysql_vars)) {
69 return '<p>' . "\n"
70 . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n"
71 . '</p>' . "\n";
72 }
73  
74 $dt_table = '<table class="data">' . "\n";
75 $odd_row = false;
76 $has_content = false;
77  
78 foreach ($variables as $var => $details) {
79 if (!isset($mysql_vars[$var])) {
80 continue;
81 }
82  
83 if (!isset($details['type'])) {
84 $details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
85 }
86 $is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE
87 || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC;
88  
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";
93 }
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]) . ' ';
111 }
112 $dt_table .= '</td>' . "\n"
113 . '</tr>' . "\n";
114 $odd_row = !$odd_row;
115 $has_content = true;
116 }
117  
118 if (!$has_content) {
119 return '';
120 }
121  
122 $dt_table .= '</table>' . "\n";
123  
124 return $dt_table;
125 }
126  
127  
128 /**
129 * Did the user request information about a certain storage engine?
130 */
131 if ( empty($_REQUEST['engine'])
132 || empty($mysql_storage_engines[$_REQUEST['engine']]) ) {
133  
134 /**
135 * Displays the sub-page heading
136 */
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";
143  
144  
145 /**
146 * Displays the table header
147 */
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";
153 }
154 echo '</tr>' . "\n"
155 . '</thead>' . "\n"
156 . '<tbody>' . "\n";
157  
158  
159 /**
160 * Listing the storage engines
161 */
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";
178 }
179 echo '</tr>' . "\n";
180 $odd_row = !$odd_row;
181 }
182 unset($odd_row, $engine, $details);
183 echo '</tbody>' . "\n"
184 . '</table>' . "\n";
185  
186 } else {
187  
188 /**
189 * Displays details about a given Storage Engine
190 */
191  
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";
206 }
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";
217 }
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";
227 }
228 }
229 unset($current, $label);
230 echo ' <strong>]</strong>' . "\n"
231 . '</p>' . "\n\n";
232 }
233 unset($infoPages, $page_output);
234 if (!empty($_REQUEST['page'])) {
235 $page_output = $engine_plugin->getPage($_REQUEST['page']);
236 }
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());
244 }
245 }
246  
247 /**
248 * Sends the footer
249 */
250 require_once('./libraries/footer.inc.php');
251  
252 ?>