Permalink
Browse files

Use Response class for ajax responses

  • Loading branch information...
1 parent f262fd6 commit 4146f880e2d62af0a4c2a1fb053e65c66c2a6e86 @roccivic roccivic committed Nov 9, 2012
Showing with 13 additions and 11 deletions.
  1. +13 −11 server_variables.php
View
@@ -28,10 +28,11 @@
*/
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
- // Send with correct charset
+ $response = PMA_Response::getInstance();
+
if (isset($_REQUEST['type'])) {
- switch($_REQUEST['type']) {
- case 'getval':
+ if ($_REQUEST['type'] === 'getval') {
+ // Send with correct charset
header('Content-Type: text/html; charset=UTF-8');
$varValue = PMA_DBI_fetch_single_row(
'SHOW GLOBAL VARIABLES WHERE Variable_name="'
@@ -41,16 +42,19 @@
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
&& $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
) {
- exit(
+ $response->addJSON(
+ 'message',
implode(
' ', PMA_Util::formatByteDown($varValue[1], 3, 3)
)
);
+ } else {
+ $response->addJSON(
+ 'message',
+ $varValue[1]
+ );
}
- exit($varValue[1]);
- break;
-
- case 'setval':
+ } else if ($_REQUEST['type'] === 'setval') {
$value = $_REQUEST['varValue'];
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
@@ -81,7 +85,6 @@
$value="'" . $value . "'";
}
- $response = PMA_Response::getInstance();
if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])
&& PMA_DBI_query(
'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value
@@ -104,9 +107,8 @@
__('Setting variable failed')
);
}
- exit;
- break;
}
+ exit;
}
}

0 comments on commit 4146f88

Please sign in to comment.