2 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * no need for variables importing
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('&', '&', PMA_generate_common_url($db)));
21 PMA_AddJSVar('is_superuser', PMA_isSuperuser() ?
true : false);
25 * Does the common work
27 require './libraries/server_common.inc.php';
30 * Required to display documentation links
32 require './libraries/server_variables_doc.php';
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']) {
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)));
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])]);
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(
73 'variable' => formatVariable($_REQUEST['varName'], $varValue[1])
78 exit(json_encode(array(
80 'error' => __('Setting variable failed')
91 require './libraries/server_links.inc.php';
95 * Displays the sub-page heading
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')
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);
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;" />
121 <table id
="serverVariables" class="data filteredData noclick">
123 <tr
><th
><?php
echo __('Variable'); ?
></th
>
124 <th
class="valueHeader">
126 echo __('Session value') . ' / ' . __('Global value');
129 <th
><?php
echo __('Documentation'); ?
></th
>
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]);
148 if ($has_session_value) {
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
>
158 $odd_row = ! $odd_row;
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);
180 require './libraries/footer.inc.php';