2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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('&', '&', PMA_generate_common_url($db)));
14 PMA_AddJSVar('is_superuser', PMA_isSuperuser() ?
true : false);
18 * Does the common work
20 require 'libraries/server_common.inc.php';
23 * Required to display documentation links
25 require 'libraries/server_variables_doc.php';
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']) {
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'
45 exit(implode(' ', PMA_formatByteDown($varValue[1], 3, 3)));
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)
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])]);
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)
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'
80 'variable' => formatVariable($_REQUEST['varName'], $varValue[1])
90 'error' => __('Setting variable failed')
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')
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);
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;" />
131 <table id
="serverVariables" class="data filteredData noclick">
133 <tr
><th
><?php
echo __('Variable'); ?
></th
>
134 <th
class="valueHeader">
136 echo __('Session value') . ' / ' . __('Global value');
139 <th
><?php
echo __('Documentation'); ?
></th
>
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]);
159 if ($has_session_value) {
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
>
169 $odd_row = ! $odd_row;
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>';
184 return PMA_formatNumber($value, 0);
187 return htmlspecialchars($value);
193 require 'libraries/footer.inc.php';