diff options
author | Dieter Adriaenssens <ruleant@users.sourceforge.net> | 2012-09-05 20:15:23 +0400 |
---|---|---|
committer | Dieter Adriaenssens <ruleant@users.sourceforge.net> | 2012-09-05 20:18:35 +0400 |
commit | 853406142d29fd354fc4fe7ed0f1cf35754540a7 (patch) | |
tree | 415927bf77113702f5e17d7f7fb79a347069be80 /server_variables.php | |
parent | 9beb4b47e41182e5cbcac33a5743c5f60cd7ab56 (diff) |
improve coding style
Diffstat (limited to 'server_variables.php')
-rw-r--r-- | server_variables.php | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/server_variables.php b/server_variables.php index 5800554f84..897978cb70 100644 --- a/server_variables.php +++ b/server_variables.php @@ -1,6 +1,7 @@ <?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** + * Server variables * * @package PhpMyAdmin */ @@ -46,7 +47,11 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte' ) { - exit(implode(' ', $common_functions->formatByteDown($varValue[1], 3, 3))); + exit( + implode( + ' ', $common_functions->formatByteDown($varValue[1], 3, 3) + ) + ); } exit($varValue[1]); break; @@ -56,10 +61,24 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte' - && preg_match('/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i', $value, $matches) + && preg_match( + '/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i', + $value, + $matches + ) ) { - $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3); - $value = floatval($matches[1]) * $common_functions->pow(1024, $exp[strtolower($matches[3])]); + $exp = array( + 'kb' => 1, + 'kib' => 1, + 'mb' => 2, + 'mib' => 2, + 'gb' => 3, + 'gib' => 3 + ); + $value = floatval($matches[1]) * $common_functions->pow( + 1024, + $exp[strtolower($matches[3])] + ); } else { $value = $common_functions->sqlAddSlashes($value); } @@ -70,12 +89,15 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { $response = PMA_Response::getInstance(); if (! preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) - && PMA_DBI_query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value) + && PMA_DBI_query( + 'SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value + ) ) { // Some values are rounded down etc. $varValue = PMA_DBI_fetch_single_row( 'SHOW GLOBAL VARIABLES WHERE Variable_name="' - . $common_functions->sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM' + . $common_functions->sqlAddSlashes($_REQUEST['varName']) + . '";', 'NUM' ); $response->addJSON( 'variable', @@ -176,6 +198,14 @@ $output .= '</tbody>' $response->addHtml($output); +/** + * Format Variable + * + * @param string $name variable name + * @param numeric $value variable value + * + * @return formatted string + */ function formatVariable($name, $value) { global $VARIABLE_DOC_LINKS; @@ -186,7 +216,8 @@ function formatVariable($name, $value) if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte' ) { - return '<abbr title="' . $common_functions->formatNumber($value, 0) . '">' + return '<abbr title="' + . $common_functions->formatNumber($value, 0) . '">' . implode(' ', $common_functions->formatByteDown($value, 3, 3)) . '</abbr>'; } else { |