Skip to content

Commit

Permalink
Use Response class for ajax responses
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Nov 9, 2012
1 parent f262fd6 commit 4146f88
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions server_variables.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
*/ */


if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
// Send with correct charset $response = PMA_Response::getInstance();

if (isset($_REQUEST['type'])) { if (isset($_REQUEST['type'])) {
switch($_REQUEST['type']) { if ($_REQUEST['type'] === 'getval') {
case 'getval': // Send with correct charset
header('Content-Type: text/html; charset=UTF-8'); header('Content-Type: text/html; charset=UTF-8');
$varValue = PMA_DBI_fetch_single_row( $varValue = PMA_DBI_fetch_single_row(
'SHOW GLOBAL VARIABLES WHERE Variable_name="' 'SHOW GLOBAL VARIABLES WHERE Variable_name="'
Expand All @@ -41,16 +42,19 @@
if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
&& $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte' && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte'
) { ) {
exit( $response->addJSON(
'message',
implode( implode(
' ', PMA_Util::formatByteDown($varValue[1], 3, 3) ' ', PMA_Util::formatByteDown($varValue[1], 3, 3)
) )
); );
} else {
$response->addJSON(
'message',
$varValue[1]
);
} }
exit($varValue[1]); } else if ($_REQUEST['type'] === 'setval') {
break;

case 'setval':
$value = $_REQUEST['varValue']; $value = $_REQUEST['varValue'];


if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3])
Expand Down Expand Up @@ -81,7 +85,6 @@
$value="'" . $value . "'"; $value="'" . $value . "'";
} }


$response = PMA_Response::getInstance();
if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName'])
&& PMA_DBI_query( && PMA_DBI_query(
'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value 'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value
Expand All @@ -104,9 +107,8 @@
__('Setting variable failed') __('Setting variable failed')
); );
} }
exit;
break;
} }
exit;
} }
} }


Expand Down

0 comments on commit 4146f88

Please sign in to comment.