Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / server_variables.php
blobdcbe19267edd9bc3366a09a342d1e130e8dfd085
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 /**
20 * Does the common work
22 require './libraries/server_common.inc.php';
24 /**
25 * Required to display documentation links
27 require './libraries/server_variables_doc.php';
29 /**
30 * Ajax request
33 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
34 // Send with correct charset
35 header('Content-Type: text/html; charset=UTF-8');
37 if (isset($_REQUEST['type'])) {
38 switch($_REQUEST['type']) {
39 case 'getval':
40 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="'.PMA_sqlAddslashes($_REQUEST['varName']).'";','NUM');
41 exit($varValue[1]);
42 break;
43 case 'setval':
44 $value = PMA_sqlAddslashes($_REQUEST['varValue']);
45 if (!is_numeric($value)) $value="'".$value."'";
47 if (! preg_match("/[^a-zA-Z0-9_]+/",$_REQUEST['varName']) && PMA_DBI_query('SET GLOBAL '.$_REQUEST['varName'].' = '.$value))
48 // Some values are rounded down etc.
49 $varValue = PMA_DBI_fetch_single_row('SHOW GLOBAL VARIABLES WHERE Variable_name="'.PMA_sqlAddslashes($_REQUEST['varName']).'";','NUM');
51 exit(json_encode(array(
52 'success' => true,
53 'variable' => formatVariable($_REQUEST['varName'],$varValue[1])
56 exit(json_encode(array(
57 'success' => false,
58 'error' => __('Setting variable failed')
61 break;
66 /**
67 * Displays the links
69 require './libraries/server_links.inc.php';
72 /**
73 * Displays the sub-page heading
75 echo '<h2>' . "\n"
76 . ($cfg['MainPageIconic'] ? '<img class="icon ic_s_vars" src="themes/dot.gif" alt="" />' : '')
77 . '' . __('Server variables and settings') . "\n"
78 . PMA_showMySQLDocu('server_system_variables','server_system_variables')
79 . '</h2>' . "\n";
81 /**
82 * Sends the queries and buffers the results
84 $serverVarsSession = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1);
85 $serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1);
88 /**
89 * Displays the page
92 <script type="text/javascript">
93 pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>';
94 url_query = '<?php echo str_replace('&amp;','&',$url_query);?>';
95 isSuperuser = <?php echo PMA_isSuperuser()?'true':'false'; ?>;
96 </script>
98 <fieldset id="tableFilter" style="display:none;">
99 <legend>Filters</legend>
100 <div class="formelement">
101 <label for="filterText">Containing the word:</label>
102 <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" />
103 </div>
104 </fieldset>
105 <table id="serverVariables" class="data filteredData">
106 <thead>
107 <tr><th><?php echo __('Variable'); ?></th>
108 <th class="valueHeader">
109 <?php
110 echo __('Session value') . ' / ' . __('Global value');
112 </th>
113 <th><?php echo __('Documentation'); ?></th>
114 </tr>
115 </thead>
116 <tbody>
117 <?php
118 $odd_row = true;
119 foreach ($serverVars as $name => $value) {
121 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
122 <th nowrap="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th>
123 <td class="value"><?php echo formatVariable($name,$value); ?></td>
124 <td class="value"><?php
125 if (isset($VARIABLE_DOC_LINKS[$name])) // To display variable documentation link
126 echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
127 ?></td>
128 <?php
129 if (isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value) {
131 </tr>
132 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?> ">
133 <td>(<?php echo __('Session value'); ?>)</td>
134 <td class="value"><?php echo formatVariable($name,$serverVarsSession[$name]); ?></td>
135 <td class="value"></td>
136 <?php } ?>
137 </tr>
138 <?php
139 $odd_row = !$odd_row;
142 </tbody>
143 </table>
144 <?php
148 * Sends the footer
150 require './libraries/footer.inc.php';
152 function formatVariable($name,$value) {
153 global $VARIABLE_DOC_LINKS;
155 if (is_numeric($value)) {
156 if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte')
157 return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ',PMA_formatByteDown($value,3,3)).'</abbr>';
158 else return PMA_formatNumber($value, 0);
160 return htmlspecialchars($value);