Translation update done using Pootle.
[phpmyadmin/tyronm.git] / server_variables.php
blobaf47f1fe83fb33946fd6373e666ae4ac00a2c31f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
9 * no need for variables importing
10 * @ignore
12 if (! defined('PMA_NO_VARIABLES_IMPORT')) {
13 define('PMA_NO_VARIABLES_IMPORT', true);
15 require_once './libraries/common.inc.php';
17 $GLOBALS['js_include'][] = 'server_variables.js';
19 PMA_AddJSVar('pma_token', $_SESSION[' PMA_token ']);
20 PMA_AddJSVar('url_query', str_replace('&amp;', '&', PMA_generate_common_url($db)));
21 PMA_AddJSVar('is_superuser', PMA_isSuperuser() ? true : false);
24 /**
25 * Does the common work
27 require './libraries/server_common.inc.php';
29 /**
30 * Required to display documentation links
32 require './libraries/server_variables_doc.php';
34 /**
35 * Ajax request
38 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
39 // Send with correct charset
40 header('Content-Type: text/html; charset=UTF-8');
42 if (isset($_REQUEST['type'])) {
43 switch($_REQUEST['type']) {
44 case 'getval':
45 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM');
46 if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
47 && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte') {
48 exit(implode(' ', PMA_formatByteDown($varValue[1],3,3)));
50 exit($varValue[1]);
51 break;
53 case 'setval':
54 $value = $_REQUEST['varValue'];
56 if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
57 && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
58 && preg_match('/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i',$value,$matches)) {
59 $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
60 $value = floatval($matches[1]) * pow(1024, $exp[strtolower($matches[3])]);
61 } else {
62 $value = PMA_sqlAddslashes($value);
65 if (! is_numeric($value)) $value="'" . $value . "'";
67 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
68 // Some values are rounded down etc.
69 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM');
71 exit(json_encode(array(
72 'success' => true,
73 'variable' => formatVariable($_REQUEST['varName'], $varValue[1])
78 exit(json_encode(array(
79 'success' => false,
80 'error' => __('Setting variable failed')
83 break;
88 /**
89 * Displays the links
91 require './libraries/server_links.inc.php';
94 /**
95 * Displays the sub-page heading
97 echo '<h2>' . "\n"
98 . ($cfg['MainPageIconic'] ? '<img class="icon ic_s_vars" src="themes/dot.gif" alt="" />' : '')
99 . '' . __('Server variables and settings') . "\n"
100 . PMA_showMySQLDocu('server_system_variables','server_system_variables')
101 . '</h2>' . "\n";
104 * Sends the queries and buffers the results
106 $serverVarsSession = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1);
107 $serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1);
111 * Displays the page
114 <fieldset id="tableFilter" style="display:none;">
115 <legend>Filters</legend>
116 <div class="formelement">
117 <label for="filterText">Containing the word:</label>
118 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
119 </div>
120 </fieldset>
121 <table id="serverVariables" class="data filteredData noclick">
122 <thead>
123 <tr><th><?php echo __('Variable'); ?></th>
124 <th class="valueHeader">
125 <?php
126 echo __('Session value') . ' / ' . __('Global value');
128 </th>
129 <th><?php echo __('Documentation'); ?></th>
130 </tr>
131 </thead>
132 <tbody>
133 <?php
134 $odd_row = true;
135 foreach ($serverVars as $name => $value) {
136 $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
137 $row_class = ($odd_row ? 'odd' : 'even') . ' ' . ($has_session_value ? 'diffSession' : '');
139 <tr class="<?php echo $row_class; ?>">
140 <th nowrap="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th>
141 <td class="value"><?php echo formatVariable($name,$value); ?></td>
142 <td class="value"><?php
143 // To display variable documentation link
144 if (isset($VARIABLE_DOC_LINKS[$name]))
145 echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
146 ?></td>
147 <?php
148 if ($has_session_value) {
150 </tr>
151 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> ">
152 <td>(<?php echo __('Session value'); ?>)</td>
153 <td class="value"><?php echo formatVariable($name,$serverVarsSession[$name]); ?></td>
154 <td class="value"></td>
155 <?php } ?>
156 </tr>
157 <?php
158 $odd_row = ! $odd_row;
161 </tbody>
162 </table>
163 <?php
165 function formatVariable($name,$value)
167 global $VARIABLE_DOC_LINKS;
169 if (is_numeric($value)) {
170 if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte')
171 return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ',PMA_formatByteDown($value,3,3)).'</abbr>';
172 else return PMA_formatNumber($value, 0);
174 return htmlspecialchars($value);
178 * Sends the footer
180 require './libraries/footer.inc.php';