Make this usage of $sql_backquotes less cryptic
[phpmyadmin.git] / server_variables.php
blobca39a5ed4fc895422dfe5acae39190a7570605b2
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_AddJSCode('pma_token = \'' . $_SESSION[' PMA_token '] . "';\n" .
20 'is_superuser = ' . (PMA_isSuperuser() ? 'true' : 'false') . ";\n" .
21 'url_query = \'' . str_replace('&amp;', '&', PMA_generate_common_url($db)) . "';\n");
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 exit($varValue[1]);
47 break;
48 case 'setval':
49 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
50 if (!is_numeric($value)) $value="'" . $value . "'";
52 if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
53 // Some values are rounded down etc.
54 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM');
56 exit(json_encode(array(
57 'success' => true,
58 'variable' => formatVariable($_REQUEST['varName'], $varValue[1])
63 exit(json_encode(array(
64 'success' => false,
65 'error' => __('Setting variable failed')
68 break;
73 /**
74 * Displays the links
76 require './libraries/server_links.inc.php';
79 /**
80 * Displays the sub-page heading
82 echo '<h2>' . "\n"
83 . ($cfg['MainPageIconic'] ? '<img class="icon ic_s_vars" src="themes/dot.gif" alt="" />' : '')
84 . '' . __('Server variables and settings') . "\n"
85 . PMA_showMySQLDocu('server_system_variables','server_system_variables')
86 . '</h2>' . "\n";
88 /**
89 * Sends the queries and buffers the results
91 $serverVarsSession = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1);
92 $serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1);
95 /**
96 * Displays the page
99 <fieldset id="tableFilter" style="display:none;">
100 <legend>Filters</legend>
101 <div class="formelement">
102 <label for="filterText">Containing the word:</label>
103 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
104 </div>
105 </fieldset>
106 <table id="serverVariables" class="data filteredData noclick">
107 <thead>
108 <tr><th><?php echo __('Variable'); ?></th>
109 <th class="valueHeader">
110 <?php
111 echo __('Session value') . ' / ' . __('Global value');
113 </th>
114 <th><?php echo __('Documentation'); ?></th>
115 </tr>
116 </thead>
117 <tbody>
118 <?php
119 $odd_row = true;
120 foreach ($serverVars as $name => $value) {
121 $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
122 $row_class = ($odd_row ? 'odd' : 'even') . ' ' . ($has_session_value ? 'diffSession' : '');
124 <tr class="<?php echo $row_class; ?>">
125 <th nowrap="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th>
126 <td class="value"><?php echo formatVariable($name,$value); ?></td>
127 <td class="value"><?php
128 // To display variable documentation link
129 if (isset($VARIABLE_DOC_LINKS[$name]))
130 echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
131 ?></td>
132 <?php
133 if ($has_session_value) {
135 </tr>
136 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> ">
137 <td>(<?php echo __('Session value'); ?>)</td>
138 <td class="value"><?php echo formatVariable($name,$serverVarsSession[$name]); ?></td>
139 <td class="value"></td>
140 <?php } ?>
141 </tr>
142 <?php
143 $odd_row = ! $odd_row;
146 </tbody>
147 </table>
148 <?php
150 function formatVariable($name,$value)
152 global $VARIABLE_DOC_LINKS;
154 if (is_numeric($value)) {
155 if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte')
156 return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ',PMA_formatByteDown($value,3,3)).'</abbr>';
157 else return PMA_formatNumber($value, 0);
159 return htmlspecialchars($value);
163 * Sends the footer
165 require './libraries/footer.inc.php';