Skip to content

Commit

Permalink
Coding style improvements (Inline control structures are discouraged)
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuracj committed Apr 25, 2012
1 parent d6e05d7 commit 4ff76ff
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 44 deletions.
37 changes: 22 additions & 15 deletions libraries/auth/swekey/swekey.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,26 @@
*/

global $gSwekeyCheckServer;
if (! isset($gSwekeyCheckServer))
if (! isset($gSwekeyCheckServer)) {
$gSwekeyCheckServer = SWEKEY_DEFAULT_CHECK_SERVER;
}

global $gSwekeyRndTokenServer;
if (! isset($gSwekeyRndTokenServer))
if (! isset($gSwekeyRndTokenServer)) {
$gSwekeyRndTokenServer = SWEKEY_DEFAULT_RND_SERVER;
}

global $gSwekeyStatusServer;
if (! isset($gSwekeyStatusServer))
if (! isset($gSwekeyStatusServer)) {
$gSwekeyStatusServer = SWEKEY_DEFAULT_STATUS_SERVER;
}

global $gSwekeyCA;

global $gSwekeyTokenCacheEnabled;
if (! isset($gSwekeyTokenCacheEnabled))
if (! isset($gSwekeyTokenCacheEnabled)) {
$gSwekeyTokenCacheEnabled = true;
}

/**
* Change the address of the Check server.
Expand All @@ -81,10 +85,11 @@
function Swekey_SetCheckServer($server)
{
global $gSwekeyCheckServer;
if (empty($server))
if (empty($server)) {
$gSwekeyCheckServer = SWEKEY_DEFAULT_CHECK_SERVER;
else
} else {
$gSwekeyCheckServer = $server;
}
}

/**
Expand All @@ -97,10 +102,11 @@ function Swekey_SetCheckServer($server)
function Swekey_SetRndTokenServer($server)
{
global $gSwekeyRndTokenServer;
if (empty($server))
if (empty($server)) {
$gSwekeyRndTokenServer = SWEKEY_DEFAULT_RND_SERVER;
else
} else {
$gSwekeyRndTokenServer = $server;
}
}

/**
Expand All @@ -113,10 +119,11 @@ function Swekey_SetRndTokenServer($server)
function Swekey_SetStatusServer($server)
{
global $gSwekeyStatusServer;
if (empty($server))
if (empty($server)) {
$gSwekeyStatusServer = SWEKEY_DEFAULT_STATUS_SERVER;
else
} else {
$gSwekeyStatusServer = $server;
}
}

/**
Expand All @@ -128,7 +135,7 @@ function Swekey_SetStatusServer($server)
function Swekey_SetCAFile($cafile)
{
global $gSwekeyCA;
$gSwekeyCA = $cafile;
$gSwekeyCA = $cafile;
}

/**
Expand Down Expand Up @@ -402,9 +409,9 @@ function Swekey_GetFastHalfRndToken()
function Swekey_GetFastRndToken()
{
$res = Swekey_GetFastHalfRndToken();
if (strlen($res) == 64)
if (strlen($res) == 64) {
return substr($res, 0, 32).strtoupper(md5("Musbe Authentication Key" + mt_rand() + date(DATE_ATOM)));

}
return "";
}

Expand Down Expand Up @@ -485,9 +492,9 @@ function Swekey_GetStatus($id)
{
global $gSwekeyStatusServer;
$res = Swekey_HttpGet($gSwekeyStatusServer.'/GET-STATUS/'.$id, $response_code);
if ($response_code == 200)
if ($response_code == 200) {
return intval($res);

}
return SWEKEY_STATUS_UNKOWN;
}

Expand Down
4 changes: 3 additions & 1 deletion libraries/import/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@
}
// Was not the quote escaped?
$j = $pos - 1;
while ($buffer[$j] == '\\') $j--;
while ($buffer[$j] == '\\') {
$j--;
}
// Even count means it was not escaped
$endq = (((($pos - 1) - $j) % 2) == 0);
// Skip the string
Expand Down
3 changes: 2 additions & 1 deletion libraries/replication.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ function PMA_replication_master_replicated_dbs($link = null)

$tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $link);
while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
if (PMA_is_system_schema($tmp_row[0]))
if (PMA_is_system_schema($tmp_row[0])) {
continue;
}
if (count($do_db) == 0) {
if (array_search($tmp_row[0], $ignore_db) !== false) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions libraries/sysinfo.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ function memory()
$mem['MemUsed'] = $mem['MemTotal'] - $mem['MemFree'] - $mem['Cached'] - $mem['Buffers'];
$mem['SwapUsed'] = $mem['SwapTotal'] - $mem['SwapFree'] - $mem['SwapCached'];

foreach ($mem as $idx=>$value)
foreach ($mem as $idx=>$value) {
$mem[$idx] = intval($value);

}
return $mem;
}
}
6 changes: 4 additions & 2 deletions pmd_relation_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
// improve: check all other requirements for InnoDB relations
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($T1) . ';');
$index_array1 = array(); // will be use to emphasis prim. keys in the table view
while ($row = PMA_DBI_fetch_assoc($result))
while ($row = PMA_DBI_fetch_assoc($result)) {
$index_array1[$row['Column_name']] = 1;
}
PMA_DBI_free_result($result);

$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($T2) . ';');
$index_array2 = array(); // will be used to emphasis prim. keys in the table view
while ($row = PMA_DBI_fetch_assoc($result))
while ($row = PMA_DBI_fetch_assoc($result)) {
$index_array2[$row['Column_name']] = 1;
}
PMA_DBI_free_result($result);

if (! empty($index_array1[$F1]) && ! empty($index_array2[$F2])) {
Expand Down
8 changes: 4 additions & 4 deletions prefs_manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@
<?php echo PMA_generate_common_hidden_inputs() . "\n"; ?>
<input type="hidden" name="json" value="<?php echo htmlspecialchars($json) ?>" />
<input type="hidden" name="fix_errors" value="1" />
<?php if (!empty($_POST['import_merge'])): ?>
<?php if (! empty($_POST['import_merge'])) { ?>
<input type="hidden" name="import_merge" value="1" />
<?php endif; ?>
<?php if ($return_url): ?>
<?php } ?>
<?php if ($return_url) { ?>
<input type="hidden" name="return_url" value="<?php echo htmlspecialchars($return_url) ?>" />
<?php endif; ?>
<?php } ?>
<p><?php echo __('Do you want to import remaining settings?') ?></p>
<input type="submit" name="submit_import" value="<?php echo __('Yes') ?>" />
<input type="submit" name="submit_ignore" value="<?php echo __('No') ?>" />
Expand Down
14 changes: 8 additions & 6 deletions server_databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@
}

foreach ($replication_types as $type) {
if ($type=="master")
$name = __('Master replication');
elseif ($type == "slave")
$name = __('Slave replication');
if (${"server_{$type}_status"})
echo ' <th>'. $name .'</th>' . "\n";
if ($type=="master") {
$name = __('Master replication');
} elseif ($type == "slave") {
$name = __('Slave replication');
}
if (${"server_{$type}_status"}) {
echo ' <th>'. $name .'</th>' . "\n";
}
}

if ($is_superuser && ! PMA_DRIZZLE) {
Expand Down
9 changes: 6 additions & 3 deletions server_variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@
<td class="value"><?php echo formatVariable($name, $value); ?></td>
<td class="value"><?php
// To display variable documentation link
if (isset($VARIABLE_DOC_LINKS[$name]))
if (isset($VARIABLE_DOC_LINKS[$name])) {
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 ($has_session_value) {
Expand All @@ -177,9 +178,11 @@ 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')
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);
} else {
return PMA_formatNumber($value, 0);
}
}
return htmlspecialchars($value);
}
Expand Down
8 changes: 4 additions & 4 deletions setup/frames/index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@
);
?>
<div class="form">
<?php if ($cf->getServerCount() > 0): ?>
<?php if ($cf->getServerCount() > 0) { ?>
<table cellspacing="0" class="datatable" style="table-layout: fixed">
<tr>
<th>#</th>
<th><?php echo __('Name') ?></th>
<th><?php echo __('Authentication type') ?></th>
<th colspan="2">DSN</th>
</tr>
<?php foreach ($cf->getServers() as $id => $server): ?>
<?php foreach ($cf->getServers() as $id => $server) { ?>
<tr>
<td><?php echo $id ?></td>
<td><?php echo htmlspecialchars($cf->getServerName($id)) ?></td>
Expand All @@ -149,9 +149,9 @@
</small>
</td>
</tr>
<?php endforeach; ?>
<?php } ?>
</table>
<?php else: ?>
<?php } ?>
<table width="100%">
<tr>
<td>
Expand Down
5 changes: 3 additions & 2 deletions tbl_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@
$tmp_geom_func = isset($geom_func[$i]) ? $geom_func[$i] : null;
$whereClause = PMA_tbl_search_getWhereClause($fields[$i], $names[$i], $types[$i], $collations[$i], $func_type, $unaryFlag, $tmp_geom_func);

if($whereClause)
if ($whereClause) {
$w[] = $whereClause;
} // end for
}
} // end while
if ($w) {
$sql_query .= ' WHERE ' . implode(' AND ', $w);
}
Expand Down
10 changes: 6 additions & 4 deletions tbl_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,11 @@ function PMA_filter_tracking($data, $filter_ts_from, $filter_ts_to, $filter_user
if ($delete_id == (int)$delete_id) {
unset($data['ddlog'][$delete_id]);

if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog'])) {
$msg = PMA_Message::success(__('Tracking data definition successfully deleted'));
else
} else {
$msg = PMA_Message::rawError(__('Query error'));
}
$msg->display();
}
}
Expand All @@ -422,10 +423,11 @@ function PMA_filter_tracking($data, $filter_ts_from, $filter_ts_to, $filter_user
if ($delete_id == (int)$delete_id) {
unset($data['dmlog'][$delete_id]);

if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog'])) {
$msg = PMA_Message::success(__('Tracking data manipulation successfully deleted'));
else
} else {
$msg = PMA_Message::rawError(__('Query error'));
}
$msg->display();
}
}
Expand Down

0 comments on commit 4ff76ff

Please sign in to comment.