Better descriptions for Drizzle column types
[phpmyadmin.git] / server_variables.php
blob32d29dfa43e4a85a647716804642053c097d9173
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 require_once 'libraries/common.inc.php';
10 $GLOBALS['js_include'][] = 'server_variables.js';
12 PMA_AddJSVar('pma_token', $_SESSION[' PMA_token ']);
13 PMA_AddJSVar('url_query', str_replace('&amp;', '&', PMA_generate_common_url($db)));
14 PMA_AddJSVar('is_superuser', PMA_isSuperuser() ? true : false);
17 /**
18 * Does the common work
20 require 'libraries/server_common.inc.php';
22 /**
23 * Required to display documentation links
25 require 'libraries/server_variables_doc.php';
27 /**
28 * Ajax request
31 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
32 // Send with correct charset
33 header('Content-Type: text/html; charset=UTF-8');
35 if (isset($_REQUEST['type'])) {
36 switch($_REQUEST['type']) {
37 case 'getval':
38 $varValue = PMA_DBI_fetch_single_row(
39 'SHOW GLOBAL VARIABLES WHERE Variable_name="'
40 . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM'
42 if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
43 && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
44 ) {
45 exit(implode(' ', PMA_formatByteDown($varValue[1], 3, 3)));
47 exit($varValue[1]);
48 break;
50 case 'setval':
51 $value = $_REQUEST['varValue'];
53 if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
54 && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
55 && preg_match('/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i', $value, $matches)
56 ) {
57 $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
58 $value = floatval($matches[1]) * pow(1024, $exp[strtolower($matches[3])]);
59 } else {
60 $value = PMA_sqlAddslashes($value);
63 if (! is_numeric($value)) {
64 $value="'" . $value . "'";
67 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])
68 && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)
69 ) {
70 // Some values are rounded down etc.
71 $varValue = PMA_DBI_fetch_single_row(
72 'SHOW GLOBAL VARIABLES WHERE Variable_name="'
73 . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM'
76 exit(
77 json_encode(
78 array(
79 'success' => true,
80 'variable' => formatVariable($_REQUEST['varName'], $varValue[1])
86 exit(
87 json_encode(
88 array(
89 'success' => false,
90 'error' => __('Setting variable failed')
94 break;
99 /**
100 * Displays the links
102 require 'libraries/server_links.inc.php';
106 * Displays the sub-page heading
108 echo '<h2>' . PMA_getImage('s_vars.png')
109 . '' . __('Server variables and settings') . "\n"
110 . PMA_showMySQLDocu('server_system_variables', 'server_system_variables')
111 . '</h2>' . "\n";
114 * Sends the queries and buffers the results
116 $serverVarsSession = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1);
117 $serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1);
121 * Displays the page
124 <fieldset id="tableFilter" style="display:none;">
125 <legend><?php echo __('Filters'); ?></legend>
126 <div class="formelement">
127 <label for="filterText"><?php echo __('Containing the word:'); ?></label>
128 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
129 </div>
130 </fieldset>
131 <table id="serverVariables" class="data filteredData noclick">
132 <thead>
133 <tr><th><?php echo __('Variable'); ?></th>
134 <th class="valueHeader">
135 <?php
136 echo __('Session value') . ' / ' . __('Global value');
138 </th>
139 <th><?php echo __('Documentation'); ?></th>
140 </tr>
141 </thead>
142 <tbody>
143 <?php
144 $odd_row = true;
145 foreach ($serverVars as $name => $value) {
146 $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
147 $row_class = ($odd_row ? 'odd' : 'even') . ' ' . ($has_session_value ? 'diffSession' : '');
149 <tr class="<?php echo $row_class; ?>">
150 <th class="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th>
151 <td class="value"><?php echo formatVariable($name, $value); ?></td>
152 <td class="value"><?php
153 // To display variable documentation link
154 if (isset($VARIABLE_DOC_LINKS[$name])) {
155 echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
157 ?></td>
158 <?php
159 if ($has_session_value) {
161 </tr>
162 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> ">
163 <td>(<?php echo __('Session value'); ?>)</td>
164 <td class="value"><?php echo formatVariable($name, $serverVarsSession[$name]); ?></td>
165 <td class="value"></td>
166 <?php } ?>
167 </tr>
168 <?php
169 $odd_row = ! $odd_row;
172 </tbody>
173 </table>
174 <?php
176 function formatVariable($name, $value)
178 global $VARIABLE_DOC_LINKS;
180 if (is_numeric($value)) {
181 if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') {
182 return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ', PMA_formatByteDown($value, 3, 3)).'</abbr>';
183 } else {
184 return PMA_formatNumber($value, 0);
187 return htmlspecialchars($value);
191 * Sends the footer
193 require 'libraries/footer.inc.php';