diff options
author | Tyron Madlener <tyronx@gmail.com> | 2011-06-17 21:04:00 +0400 |
---|---|---|
committer | Tyron Madlener <tyronx@gmail.com> | 2011-06-17 21:04:00 +0400 |
commit | 5c44a402489d2356b997b858927af6d093a2e430 (patch) | |
tree | 565a6a4a2de04d22a40ef63d8671db2e601c3b45 /server_variables.php | |
parent | 14f8664272af543a16bb78a3c72e5cd64fae64b9 (diff) |
Bugfixes, Adjustments and Server variable editing
Diffstat (limited to 'server_variables.php')
-rw-r--r-- | server_variables.php | 106 |
1 files changed, 66 insertions, 40 deletions
diff --git a/server_variables.php b/server_variables.php index e538c9128a..16efc17a47 100644 --- a/server_variables.php +++ b/server_variables.php @@ -21,17 +21,50 @@ $GLOBALS['js_include'][] = 'server_variables.js'; */ require './libraries/server_common.inc.php'; +/** + * Required to display documentation links + */ +require './libraries/server_variables_doc.php'; /** - * Displays the links + * Ajax request */ -require './libraries/server_links.inc.php'; +if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { + // Send with correct charset + header('Content-Type: text/html; charset=UTF-8'); + + if(isset($_REQUEST['type'])) { + switch($_REQUEST['type']) { + case 'getval': + $varValue = PMA_DBI_fetch_value('SHOW GLOBAL VARIABLES WHERE Variable_name="'.mysql_real_escape_string($_REQUEST['varName']).'";',0,1); + exit($varValue); + break; + case 'setval': + if(PMA_DBI_query('SET GLOBAL '.mysql_real_escape_string($_REQUEST['varName']).' = '.mysql_real_escape_string($_REQUEST['varValue']).'')) + // Some values are rounded down etc. + $varValue = PMA_DBI_fetch_value('SHOW GLOBAL VARIABLES WHERE Variable_name="'.mysql_real_escape_string($_REQUEST['varName']).'";',0,1); + + exit(json_encode(array( + 'success' => true, + 'variable' => formatVariable($_REQUEST['varName'],$varValue) + )) + ); + exit(json_encode(array( + 'success' => false, + 'error' => __('Setting variable failed') + )) + ); + break; + } + } +} /** - * Required to display documentation links + * Displays the links */ -require './libraries/server_variables_doc.php'; +require './libraries/server_links.inc.php'; + /** * Displays the sub-page heading @@ -42,18 +75,24 @@ echo '<h2>' . "\n" . PMA_showMySQLDocu('server_system_variables','server_system_variables') . '</h2>' . "\n"; - /** * Sends the queries and buffers the results */ -$serverVars = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1); -$serverVarsGlobal = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1); +$serverVarsSession = PMA_DBI_fetch_result('SHOW SESSION VARIABLES;', 0, 1); +$serverVars = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1); /** * Displays the page */ ?> +<script type="text/javascript"> +pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>'; +url_query = '<?php echo str_replace('&','&',$url_query);?>'; +pma_theme_image = '<?php echo $GLOBALS['pmaThemeImage']; ?>'; +isSuperuser = <?php echo PMA_isSuperuser()?'true':'false'; ?>; +</script> + <fieldset id="tableFilter" style="display:none;"> <legend>Filters</legend> <div class="formelement"> @@ -61,10 +100,10 @@ $serverVarsGlobal = PMA_DBI_fetch_result('SHOW GLOBAL VARIABLES;', 0, 1); <input name="filterText" type="text" id="filterText" style="vertical-align: baseline;" /> </div> </fieldset> -<table class="data filteredData"> +<table id="serverVariables" class="data filteredData"> <thead> <tr><th><?php echo __('Variable'); ?></th> - <th> + <th class="valueHeader"> <?php echo __('Session value') . ' / ' . __('Global value'); ?> @@ -77,44 +116,20 @@ echo __('Session value') . ' / ' . __('Global value'); $odd_row = true; foreach ($serverVars as $name => $value) { ?> -<tr class="noclick <?php - echo $odd_row ? 'odd' : 'even'; - if ($serverVarsGlobal[$name] !== $value) { - echo ' marked'; - } - ?>"> - <th nowrap="nowrap"> - <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th> - <td class="value"><?php - if (is_numeric($value)) { - if(isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') - echo '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ',PMA_formatByteDown($value,3,3)).'</abbr>'; - else echo PMA_formatNumber($value, 0); - $is_numeric = true; - } else { - echo htmlspecialchars($value); - $is_numeric = false; - } - ?></td> +<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>"> + <th nowrap="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th> + <td class="value"><?php echo formatVariable($name,$value); ?></td> <td class="value"><?php if (isset($VARIABLE_DOC_LINKS[$name])) // To display variable documentation link echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]); ?></td> <?php - if ($serverVarsGlobal[$name] !== $value) { + if (isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value) { ?> </tr> -<tr class="noclick <?php - echo $odd_row ? 'odd' : 'even'; - ?> marked"> - <td>(<?php echo __('Global value'); ?>)</td> - <td class="value"><?php - if ($is_numeric) { - echo PMA_formatNumber($serverVarsGlobal[$name], 0); - } else { - echo htmlspecialchars($serverVarsGlobal[$name]); - } - ?></td> +<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?> "> + <td>(<?php echo __('Session value'); ?>)</td> + <td class="value"><?php echo formatVariable($name,$serverVarsSession[$name]); ?></td> <td class="value"></td> <?php } ?> </tr> @@ -132,4 +147,15 @@ foreach ($serverVars as $name => $value) { */ require './libraries/footer.inc.php'; +function formatVariable($name,$value) { + global $VARIABLE_DOC_LINKS; + + if (is_numeric($value)) { + if(isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') + return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ',PMA_formatByteDown($value,3,3)).'</abbr>'; + else return PMA_formatNumber($value, 0); + } + return htmlspecialchars($value); +} + ?> |