From 94c6836f8b16129a64383ac03beb4a9639ba9559 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Mon, 5 Sep 2011 14:28:17 +0200 Subject: [PATCH] fix coding style : control structures --- db_datadict.php | 2 +- db_operations.php | 9 ++-- db_printview.php | 5 +-- db_search.php | 3 +- export.php | 25 +++++------ libraries/auth/swekey/swekey.auth.lib.php | 45 ++++++++----------- libraries/common.inc.php | 3 +- libraries/database_interface.lib.php | 4 +- libraries/db_links.inc.php | 3 +- tbl_chart.php | 2 +- tbl_export.php | 2 +- tbl_relation.php | 2 +- tbl_replace.php | 2 +- tbl_select.php | 11 ++--- tbl_structure.php | 6 +-- tbl_tracking.php | 2 +- test/classes/PMA_Config_test.php | 34 ++++++-------- .../common/PMA_quoting_slashing_test.php | 2 +- test/libraries/core/PMA_getLinks_test.php | 3 +- .../core/PMA_headerLocation_test_disabled.php | 6 +-- test/selenium/PmaSeleniumLoginTest.php | 2 +- 21 files changed, 71 insertions(+), 102 deletions(-) diff --git a/db_datadict.php b/db_datadict.php index f580e21e5a..fc5de9046c 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -59,7 +59,7 @@ PMA_DBI_select_db($db); $tables = PMA_DBI_get_tables($db); $count = 0; -foreach($tables as $table) { +foreach ($tables as $table) { $comments = PMA_getComments($db, $table); echo '
' . "\n"; diff --git a/db_operations.php b/db_operations.php index 0bd9eef585..c9430d1352 100644 --- a/db_operations.php +++ b/db_operations.php @@ -161,9 +161,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { // for importing via the mysql client or our Import feature) $triggers = PMA_DBI_get_triggers($db, $each_table, ''); - if (! PMA_Table::moveCopy($db, $each_table, $newname, $each_table, - isset($this_what) ? $this_what : 'data', $move, 'db_copy')) - { + if (! PMA_Table::moveCopy( + $db, $each_table, $newname, $each_table, + isset($this_what) ? $this_what : 'data', $move, 'db_copy') + ) { $_error = true; // $sql_query is filled by PMA_Table::moveCopy() $sql_query = $back . $sql_query; @@ -273,7 +274,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $message = PMA_Message::success(__('Database %s has been renamed to %s')); $message->addParam($db); $message->addParam($newname); - } elseif (! $_error) { + } elseif (! $_error) { $message = PMA_Message::success(__('Database %s has been copied to %s')); $message->addParam($db); $message->addParam($newname); diff --git a/db_printview.php b/db_printview.php index e25341128f..2ede085bdb 100644 --- a/db_printview.php +++ b/db_printview.php @@ -92,9 +92,8 @@ echo '
'; // 1. No table if ($num_tables == 0) { echo __('No tables found in database.'); -} -// 2. Shows table informations on mysql >= 3.23.03 -else { +} else { +// 2. Shows table information ?> diff --git a/db_search.php b/db_search.php index c76e5d80dc..a9817ba2cc 100644 --- a/db_search.php +++ b/db_search.php @@ -258,8 +258,7 @@ if (isset($_REQUEST['submit_search'])) { */ if ($GLOBALS['is_ajax_request'] == true) { exit; -} -else { +} else { echo '';//end searchresults div } diff --git a/export.php b/export.php index aa64600459..e26427d536 100644 --- a/export.php +++ b/export.php @@ -155,9 +155,8 @@ function PMA_exportOutputHandler($line) // as bzipped if ($GLOBALS['compression'] == 'bzip' && @function_exists('bzcompress')) { $dump_buffer = bzcompress($dump_buffer); - } - // as a gzipped file - elseif ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) { + } elseif ($GLOBALS['compression'] == 'gzip' && @function_exists('gzencode')) { + // as a gzipped file // without the optional parameter level because it bug $dump_buffer = gzencode($dump_buffer); } @@ -632,15 +631,13 @@ if (!empty($asfile)) { $zipfile -> addFile($dump_buffer, substr($filename, 0, -4)); $dump_buffer = $zipfile -> file(); } - } - // 2. as a bzipped file - elseif ($compression == 'bzip') { + } elseif ($compression == 'bzip') { + // 2. as a bzipped file if (@function_exists('bzcompress')) { $dump_buffer = bzcompress($dump_buffer); } - } - // 3. as a gzipped file - elseif ($compression == 'gzip') { + } elseif ($compression == 'gzip') { + // 3. as a gzipped file if (@function_exists('gzencode') && !@ini_get('zlib.output_compression')) { // without the optional parameter level because it bug $dump_buffer = gzencode($dump_buffer); @@ -672,13 +669,11 @@ if (!empty($asfile)) { } else { echo $dump_buffer; } -} -/** - * Displays the dump... - */ -else { +} else { /** - * Close the html tags and add the footers in dump is displayed on screen + * Displays the dump... + * + * Close the html tags and add the footers if dump is displayed on screen */ echo '' . "\n" . ' ' . "\n"; diff --git a/libraries/auth/swekey/swekey.auth.lib.php b/libraries/auth/swekey/swekey.auth.lib.php index db60e13401..c748a53efc 100644 --- a/libraries/auth/swekey/swekey.auth.lib.php +++ b/libraries/auth/swekey/swekey.auth.lib.php @@ -23,13 +23,11 @@ function Swekey_auth_check() $_SESSION['SWEKEY']['VALID_SWEKEYS'] = array(); $valid_swekeys = explode("\n", @file_get_contents($confFile)); foreach ($valid_swekeys as $line) { - if (preg_match("/^[0-9A-F]{32}:.+$/", $line) != false) - { + if (preg_match("/^[0-9A-F]{32}:.+$/", $line) != false) { $items = explode(":", $line); if (count($items) == 2) $_SESSION['SWEKEY']['VALID_SWEKEYS'][$items[0]] = trim($items[1]); - } - else if (preg_match("/^[A-Z_]+=.*$/", $line) != false) { + } elseif (preg_match("/^[A-Z_]+=.*$/", $line) != false) { $items = explode("=", $line); $_SESSION['SWEKEY']['CONF_'.trim($items[0])] = trim($items[1]); } @@ -125,8 +123,7 @@ function Swekey_auth_error() Swekey_EnableTokenCache($_SESSION['SWEKEY']['CONF_ENABLE_TOKEN_CACHE']); $caFile = $_SESSION['SWEKEY']['CONF_CA_FILE']; - if (empty($caFile)) - { + if (empty($caFile)) { $caFile = __FILE__; $pos = strrpos($caFile, '/'); if ($pos === false) @@ -137,10 +134,11 @@ function Swekey_auth_error() // echo "\n"; } - if (file_exists($caFile)) + if (file_exists($caFile)) { Swekey_SetCAFile($caFile); - else if (! empty($caFile) && (substr($_SESSION['SWEKEY']['CONF_SERVER_CHECK'], 0, 8) == "https://")) + } elseif (! empty($caFile) && (substr($_SESSION['SWEKEY']['CONF_SERVER_CHECK'], 0, 8) == "https://")) { return "Internal Error: CA File $caFile not found"; + } $result = null; $swekey_id = $_GET['swekey_id']; @@ -150,21 +148,18 @@ function Swekey_auth_error() unset($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']); if (! isset($_SESSION['SWEKEY']['RND_TOKEN'])) { unset($swekey_id); - } - else { + } else { if (strlen($swekey_id) == 32) { $res = Swekey_CheckOtp($swekey_id, $_SESSION['SWEKEY']['RND_TOKEN'], $swekey_otp); unset($_SESSION['SWEKEY']['RND_TOKEN']); if (! $res) { $result = __('Hardware authentication failed') . ' (' . Swekey_GetLastError() . ')'; - } - else { + } else { $_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY'] = $swekey_id; $_SESSION['SWEKEY']['FORCE_USER'] = $_SESSION['SWEKEY']['VALID_SWEKEYS'][$swekey_id]; return null; } - } - else { + } else { $result = __('No valid authentication key plugged'); if ($_SESSION['SWEKEY']['CONF_DEBUG']) { @@ -173,9 +168,9 @@ function Swekey_auth_error() unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file } } - } - else + } else { unset($_SESSION['SWEKEY']); + } $_SESSION['SWEKEY']['RND_TOKEN'] = Swekey_GetFastRndToken(); if (strlen($_SESSION['SWEKEY']['RND_TOKEN']) != 64) { @@ -186,12 +181,9 @@ function Swekey_auth_error() if (! isset($swekey_id)) { ?> '. "\n"); diff --git a/test/libraries/core/PMA_headerLocation_test_disabled.php b/test/libraries/core/PMA_headerLocation_test_disabled.php index b2f522db3b..147386ad81 100644 --- a/test/libraries/core/PMA_headerLocation_test_disabled.php +++ b/test/libraries/core/PMA_headerLocation_test_disabled.php @@ -105,8 +105,7 @@ class PMA_headerLocation_test extends PHPUnit_Extensions_OutputTestCase if (defined('PMA_IS_IIS')) { $this->oldIISvalue = PMA_IS_IIS; runkit_constant_redefine('PMA_IS_IIS', NULL); - } - else { + } else { runkit_constant_add('PMA_IS_IIS', NULL); } @@ -116,8 +115,7 @@ class PMA_headerLocation_test extends PHPUnit_Extensions_OutputTestCase if (defined('SID')) { $this->oldSIDvalue = SID; runkit_constant_redefine('SID', NULL); - } - else { + } else { runkit_constant_add('SID', NULL); } diff --git a/test/selenium/PmaSeleniumLoginTest.php b/test/selenium/PmaSeleniumLoginTest.php index dc0fc802d6..1a5d22d622 100644 --- a/test/selenium/PmaSeleniumLoginTest.php +++ b/test/selenium/PmaSeleniumLoginTest.php @@ -21,7 +21,7 @@ class PmaSeleniumLoginTest extends PmaSeleniumTestCase $this->doLogin(); // Check if login error happend - if ($this->isElementPresent("//html/body/div/div[@class='error']")){ + if ($this->isElementPresent("//html/body/div/div[@class='error']")) { $this->fail($this->getText("//html/body/div/div[@class='error']")); }