From 2260e1081463c5e05df12ecd30346c362a9fb91b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 15:02:46 +0530 Subject: [PATCH 01/10] Proper indentation for switch-case statement --- db_structure.php | 146 +++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/db_structure.php b/db_structure.php index 8673471ab0..239cff4b23 100644 --- a/db_structure.php +++ b/db_structure.php @@ -139,83 +139,83 @@ foreach ($tables as $keyname => $each_table) { switch ( $each_table['ENGINE']) { // MyISAM, ISAM or Heap table: Row count, data size and index size // are accurate; data size is accurate for ARCHIVE - case 'MyISAM' : - case 'ISAM' : - case 'HEAP' : - case 'MEMORY' : - case 'ARCHIVE' : - case 'Aria' : - case 'Maria' : - if ($db_is_information_schema) { - $each_table['Rows'] = PMA_Table::countRecords($db, - $each_table['Name']); - } + case 'MyISAM' : + case 'ISAM' : + case 'HEAP' : + case 'MEMORY' : + case 'ARCHIVE' : + case 'Aria' : + case 'Maria' : + if ($db_is_information_schema) { + $each_table['Rows'] = PMA_Table::countRecords($db, + $each_table['Name']); + } - if ($is_show_stats) { - $tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['Index_length']); - $sum_size += $tblsize; - list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); - if (isset($each_table['Data_free']) && $each_table['Data_free'] > 0) { - list($formatted_overhead, $overhead_unit) = PMA_formatByteDown($each_table['Data_free'], 3, ($each_table['Data_free'] > 0) ? 1 : 0); - $overhead_size += $each_table['Data_free']; - } + if ($is_show_stats) { + $tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['Index_length']); + $sum_size += $tblsize; + list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); + if (isset($each_table['Data_free']) && $each_table['Data_free'] > 0) { + list($formatted_overhead, $overhead_unit) = PMA_formatByteDown($each_table['Data_free'], 3, ($each_table['Data_free'] > 0) ? 1 : 0); + $overhead_size += $each_table['Data_free']; } - break; - case 'InnoDB' : - case 'PBMS' : - // InnoDB table: Row count is not accurate but data and index sizes are. - // PBMS table in Drizzle: TABLE_ROWS is taken from table cache, so it may be unavailable + } + break; + case 'InnoDB' : + case 'PBMS' : + // InnoDB table: Row count is not accurate but data and index sizes are. + // PBMS table in Drizzle: TABLE_ROWS is taken from table cache, so it may be unavailable - if (($each_table['ENGINE'] == 'InnoDB' && $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) - || !isset($each_table['TABLE_ROWS'])) { - $each_table['COUNTED'] = true; - $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, - $each_table['TABLE_NAME'], $force_exact = true, - $is_view = false); - } else { - $each_table['COUNTED'] = false; - } + if (($each_table['ENGINE'] == 'InnoDB' && $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) + || !isset($each_table['TABLE_ROWS'])) { + $each_table['COUNTED'] = true; + $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, + $each_table['TABLE_NAME'], $force_exact = true, + $is_view = false); + } else { + $each_table['COUNTED'] = false; + } - // Drizzle doesn't provide data and index length, check for null - if ($is_show_stats && $each_table['Data_length'] !== null) { - $tblsize = $each_table['Data_length'] + $each_table['Index_length']; - $sum_size += $tblsize; - list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); - } - //$display_rows = ' - '; - break; - // Mysql 5.0.x (and lower) uses MRG_MyISAM and MySQL 5.1.x (and higher) uses MRG_MYISAM - // Both are aliases for MERGE - case 'MRG_MyISAM' : - case 'MRG_MYISAM' : - case 'MERGE' : - case 'BerkeleyDB' : - // Merge or BerkleyDB table: Only row count is accurate. - if ($is_show_stats) { - $formatted_size = ' - '; - $unit = ''; - } - break; - // for a view, the ENGINE is sometimes reported as null, - // or on some servers it's reported as "SYSTEM VIEW" - case null : - case 'SYSTEM VIEW' : - case 'FunctionEngine' : - // if table is broken, Engine is reported as null, so one more test - if ($each_table['TABLE_TYPE'] == 'VIEW') { - // countRecords() takes care of $cfg['MaxExactCountViews'] - $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, - $each_table['TABLE_NAME'], $force_exact = true, - $is_view = true); - $table_is_view = true; - } - break; - default : - // Unknown table type. - if ($is_show_stats) { - $formatted_size = 'unknown'; - $unit = ''; - } + // Drizzle doesn't provide data and index length, check for null + if ($is_show_stats && $each_table['Data_length'] !== null) { + $tblsize = $each_table['Data_length'] + $each_table['Index_length']; + $sum_size += $tblsize; + list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); + } + //$display_rows = ' - '; + break; + // Mysql 5.0.x (and lower) uses MRG_MyISAM and MySQL 5.1.x (and higher) uses MRG_MYISAM + // Both are aliases for MERGE + case 'MRG_MyISAM' : + case 'MRG_MYISAM' : + case 'MERGE' : + case 'BerkeleyDB' : + // Merge or BerkleyDB table: Only row count is accurate. + if ($is_show_stats) { + $formatted_size = ' - '; + $unit = ''; + } + break; + // for a view, the ENGINE is sometimes reported as null, + // or on some servers it's reported as "SYSTEM VIEW" + case null : + case 'SYSTEM VIEW' : + case 'FunctionEngine' : + // if table is broken, Engine is reported as null, so one more test + if ($each_table['TABLE_TYPE'] == 'VIEW') { + // countRecords() takes care of $cfg['MaxExactCountViews'] + $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, + $each_table['TABLE_NAME'], $force_exact = true, + $is_view = true); + $table_is_view = true; + } + break; + default : + // Unknown table type. + if ($is_show_stats) { + $formatted_size = 'unknown'; + $unit = ''; + } } // end switch if (! PMA_Table::isMerge($db, $each_table['TABLE_NAME'])) { From 5959ae1c5a9fb19e5fbb736f91919684f36b0454 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 15:09:48 +0530 Subject: [PATCH 02/10] Coding style improvements --- db_structure.php | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/db_structure.php b/db_structure.php index 239cff4b23..c76e374bf1 100644 --- a/db_structure.php +++ b/db_structure.php @@ -22,7 +22,8 @@ $GLOBALS['js_include'][] = 'jquery/timepicker.js'; if (empty($is_info)) { // Drops/deletes/etc. multiple tables if required if ((!empty($submit_mult) && isset($selected_tbl)) - || isset($mult_btn)) { + || isset($mult_btn) + ) { $action = 'db_structure.php'; $err_url = 'db_structure.php?'. PMA_generate_common_url($db); @@ -96,7 +97,10 @@ if (isset($_REQUEST['sort_order'])) { $_url_params['sort_order'] = $_REQUEST['sort_order']; } -PMA_listNavigator($total_num_tables, $pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']); +PMA_listNavigator( + $total_num_tables, $pos, $_url_params, 'db_structure.php', + 'frame_content', $GLOBALS['cfg']['MaxTableList'] +); ?>
@@ -110,7 +114,9 @@ $sum_size = (double) 0; $overhead_size = (double) 0; $overhead_check = ''; $checked = !empty($checkall) ? ' checked="checked"' : ''; -$num_columns = $cfg['PropertiesNumColumns'] > 1 ? ceil($num_tables / $cfg['PropertiesNumColumns']) + 1 : 0; +$num_columns = $cfg['PropertiesNumColumns'] > 1 + ? ceil($num_tables / $cfg['PropertiesNumColumns']) + 1 + : 0; $row_count = 0; @@ -147,8 +153,9 @@ foreach ($tables as $keyname => $each_table) { case 'Aria' : case 'Maria' : if ($db_is_information_schema) { - $each_table['Rows'] = PMA_Table::countRecords($db, - $each_table['Name']); + $each_table['Rows'] = PMA_Table::countRecords( + $db, $each_table['Name'] + ); } if ($is_show_stats) { @@ -166,12 +173,15 @@ foreach ($tables as $keyname => $each_table) { // InnoDB table: Row count is not accurate but data and index sizes are. // PBMS table in Drizzle: TABLE_ROWS is taken from table cache, so it may be unavailable - if (($each_table['ENGINE'] == 'InnoDB' && $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) - || !isset($each_table['TABLE_ROWS'])) { + if (($each_table['ENGINE'] == 'InnoDB' + && $each_table['TABLE_ROWS'] < $GLOBALS['cfg']['MaxExactCount']) + || !isset($each_table['TABLE_ROWS']) + ) { $each_table['COUNTED'] = true; - $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, - $each_table['TABLE_NAME'], $force_exact = true, - $is_view = false); + $each_table['TABLE_ROWS'] = PMA_Table::countRecords( + $db, $each_table['TABLE_NAME'], + $force_exact = true, $is_view = false + ); } else { $each_table['COUNTED'] = false; } @@ -204,9 +214,10 @@ foreach ($tables as $keyname => $each_table) { // if table is broken, Engine is reported as null, so one more test if ($each_table['TABLE_TYPE'] == 'VIEW') { // countRecords() takes care of $cfg['MaxExactCountViews'] - $each_table['TABLE_ROWS'] = PMA_Table::countRecords($db, - $each_table['TABLE_NAME'], $force_exact = true, - $is_view = true); + $each_table['TABLE_ROWS'] = PMA_Table::countRecords( + $db, $each_table['TABLE_NAME'], + $force_exact = true, $is_view = true + ); $table_is_view = true; } break; @@ -287,7 +298,8 @@ foreach ($tables as $keyname => $each_table) { . ' ' . PMA_backquote($each_table['TABLE_NAME']); $drop_message = sprintf( $table_is_view ? __('View %s has been dropped') : __('Table %s has been dropped'), - str_replace(' ', ' ', htmlspecialchars($each_table['TABLE_NAME']))); + str_replace(' ', ' ', htmlspecialchars($each_table['TABLE_NAME'])) + ); } $tracking_icon = ''; @@ -299,8 +311,10 @@ foreach ($tables as $keyname => $each_table) { } } - if ($num_columns > 0 && $num_tables > $num_columns - && (($row_count % $num_columns) == 0)) { + if ($num_columns > 0 + && $num_tables > $num_columns + && ($row_count % $num_columns) == 0 + ) { $row_count = 1; $odd_row = true; ?> From 1f26c2f84181deab4cfcafe3a862520c5ee456e3 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 15:29:09 +0530 Subject: [PATCH 03/10] Wrap some long lines --- db_structure.php | 62 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/db_structure.php b/db_structure.php index c76e374bf1..b46fe297b4 100644 --- a/db_structure.php +++ b/db_structure.php @@ -265,7 +265,8 @@ foreach ($tables as $keyname => $each_table) { $row_count++; if ($table_is_view) { - $hidden_fields[] = ''; + $hidden_fields[] = ''; } if ($each_table['TABLE_ROWS'] > 0 || $table_is_view) { @@ -305,9 +306,13 @@ foreach ($tables as $keyname => $each_table) { $tracking_icon = ''; if (PMA_Tracker::isActive()) { if (PMA_Tracker::isTracked($GLOBALS["db"], $truename)) { - $tracking_icon = '' . __('Tracking is active.') . ''; + $tracking_icon = ''
+                . __('Tracking is active.') . ''; } elseif (PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) { - $tracking_icon = '' . __('Tracking is not active.') . ''; + $tracking_icon = ''
+                . __('Tracking is not active.') . ''; } } @@ -339,17 +344,23 @@ foreach ($tables as $keyname => $each_table) { } foreach ($server_slave_Wild_Do_Table as $db_table) { $table_part = PMA_extract_db_or_table($db_table, 'table'); - if (($db == PMA_extract_db_or_table($db_table, 'db')) && (preg_match("@^" . substr($table_part, 0, strlen($table_part) - 1) . "@", $truename))) { + if (($db == PMA_extract_db_or_table($db_table, 'db')) + && (preg_match("@^" . substr($table_part, 0, strlen($table_part) - 1) . "@", $truename)) + ) { $do = true; } } //////////////////////////////////////////////////////////////////// - if ((strlen(array_search($truename, $server_slave_Ignore_Table)) > 0) || (strlen(array_search($db, $server_slave_Ignore_DB)) > 0)) { + if ((strlen(array_search($truename, $server_slave_Ignore_Table)) > 0) + || (strlen(array_search($db, $server_slave_Ignore_DB)) > 0) + ) { $ignored = true; } foreach ($server_slave_Wild_Ignore_Table as $db_table) { $table_part = PMA_extract_db_or_table($db_table, 'table'); - if (($db == PMA_extract_db_or_table($db_table)) && (preg_match("@^" . substr($table_part, 0, strlen($table_part) - 1) . "@", $truename))) { + if (($db == PMA_extract_db_or_table($db_table)) + && (preg_match("@^" . substr($table_part, 0, strlen($table_part) - 1) . "@", $truename)) + ) { $ignored = true; } } @@ -364,7 +375,13 @@ foreach ($tables as $keyname => $each_table) { - ' : ''. $do ? ' REPLICATED' : ''; ?> + ' + : ''. + $do + ? ' REPLICATED' + : ''; ?> @@ -394,10 +411,20 @@ foreach ($tables as $keyname => $each_table) { if ($table_is_view) { // Drizzle views use FunctionEngine, and the only place where they are available are I_S and D_D // schemas, where we do exact counting - if ($each_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] && $each_table['ENGINE'] != 'FunctionEngine') { + if ($each_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] + && $each_table['ENGINE'] != 'FunctionEngine' + ) { $row_count_pre = '~'; $sum_row_count_pre = '~'; - $show_superscript = PMA_showHint(PMA_sanitize(sprintf(__('This view has at least this number of rows. Please refer to %sdocumentation%s.'), '[a@./Documentation.html#cfg_MaxExactCountViews@_blank]', '[/a]'))); + $show_superscript = PMA_showHint( + PMA_sanitize( + sprintf( + __('This view has at least this number of rows. Please refer to %sdocumentation%s.'), + '[a@./Documentation.html#cfg_MaxExactCountViews@_blank]', + '[/a]' + ) + ) + ); } } elseif ($each_table['ENGINE'] == 'InnoDB' && (! $each_table['COUNTED'])) { // InnoDB table: we did not get an accurate row count @@ -451,10 +478,13 @@ if ($is_show_stats) { 1)) { $default_engine = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'storage_engine\';', 0, 1); echo ' ' . "\n" . ' ' .$default_engine . '' . "\n"; + . sprintf(__('%s is the default storage engine on this MySQL server.'), $default_engine) + . '">' .$default_engine . '' . "\n"; // we got a case where $db_collation was empty echo ' ' . "\n"; if (! empty($db_collation)) { @@ -559,7 +590,10 @@ if (!$db_is_information_schema && !$cfg['DisableMultiTableMaintenance']) {
From e27ba519c5265109d6e3ad629297d057b2c53496 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 14 Sep 2011 07:44:09 -0400 Subject: [PATCH 04/10] 3.4.5 release --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ca343327a8..d05c29a72a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,7 @@ phpMyAdmin - ChangeLog - bug #3403165 [interface] Collation not displayed for long enum fields - bug #3399951 [export] Config for export compression not used -3.4.5.0 (not yet released) +3.4.5.0 (2011-09-14) - bug #3375325 [interface] Page list in navigation frame looks odd - bug #3313235 [interface] Error div misplaced - bug #3374802 [interface] Comment on a column breaks inline editing From d3bd40b56d619f0672e323844095cc8b36e9e49e Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 22:43:48 +0530 Subject: [PATCH 05/10] bug #3400690 [privileges] DB-specific privileges won't submit Db/table specific privileges has not been ajaxified. So skip it for now. --- ChangeLog | 1 + js/server_privileges.js | 2 +- server_privileges.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d05c29a72a..83aa38d49f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ phpMyAdmin - ChangeLog - bug #3404886 [navi] Edit SQL statement after error - bug #3403165 [interface] Collation not displayed for long enum fields - bug #3399951 [export] Config for export compression not used +- bug #3400690 [privileges] DB-specific privileges won't submit 3.4.5.0 (2011-09-14) - bug #3375325 [interface] Page list in navigation frame looks odd diff --git a/js/server_privileges.js b/js/server_privileges.js index f178c6ce92..fe0f69fe0b 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -346,7 +346,7 @@ $(document).ready(function() { * @memberOf jQuery * @name edit_user_submit */ - $("#edit_user_dialog").find("form").live('submit', function(event) { + $("#edit_user_dialog").find("form:not(#db_or_table_specific_priv)").live('submit', function(event) { /** @lends jQuery */ event.preventDefault(); diff --git a/server_privileges.php b/server_privileges.php index 81de01f7e7..12fb1db7d6 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1790,7 +1790,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // but only if $dbname contains no wildcards // table header - echo '
' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '') . '' . "\n" . '' . "\n" From f76e4277d0f22d57a75a90342e3cac647b96ee54 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 22:55:43 +0530 Subject: [PATCH 06/10] File is being conditionally included; use "include" instead --- server_privileges.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server_privileges.php b/server_privileges.php index 37ef25e245..926c6a1b96 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -113,13 +113,13 @@ if (isset($dbname)) { * Checks if the user is allowed to do what he tries to... */ if (!$is_superuser) { - require './libraries/server_links.inc.php'; + include './libraries/server_links.inc.php'; echo '

' . "\n" . PMA_getIcon('b_usrlist.png') . __('Privileges') . "\n" . '

' . "\n"; PMA_Message::error(__('No Privileges'))->display(); - require './libraries/footer.inc.php'; + include './libraries/footer.inc.php'; } $random_n = mt_rand(0,1000000); // a random number that will be appended to the id of the user forms @@ -1521,10 +1521,10 @@ if (isset($viewing_mode) && $viewing_mode == 'db') { // Gets the database structure $sub_part = '_structure'; - require './libraries/db_info.inc.php'; + include './libraries/db_info.inc.php'; echo "\n"; } else { - require './libraries/server_links.inc.php'; + include './libraries/server_links.inc.php'; } @@ -2158,7 +2158,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } if (! isset($dbname) && ! $user_does_not_exists) { - require_once './libraries/display_change_password.lib.php'; + include_once './libraries/display_change_password.lib.php'; echo '' . "\n" . PMA_generate_common_hidden_inputs('', '') From 100d7a04cfab62bedca957028b6c333d6c145bc6 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 23:02:02 +0530 Subject: [PATCH 07/10] Fix doc blocks --- server_privileges.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/server_privileges.php b/server_privileges.php index 926c6a1b96..69009365bd 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -134,8 +134,9 @@ $random_n = mt_rand(0,1000000); // a random number that will be appended to the * no escaping (for example test_db) but in mysql.db you'll see test\_db * for a db-specific privilege. * - * @param string $dbname Database name - * @param string $tablename Table name + * @param string $dbname Database name + * @param string $tablename Table name + * * @return string the escaped (if necessary) database.table */ function PMA_wildcardEscapeForGrant($dbname, $tablename) @@ -158,7 +159,8 @@ function PMA_wildcardEscapeForGrant($dbname, $tablename) /** * Generates a condition on the user name * - * @param string the user's initial + * @param string $initial the user's initial + * * @return string the generated condition */ function PMA_rangeOfUsers($initial = '') @@ -409,6 +411,7 @@ function PMA_display_column_privs($columns, $row, $name_for_select, * @param string $db the database * @param string $table the table * @param boolean $submit wheather to display the submit button or not + * * @global array $cfg the phpMyAdmin configuration * @global ressource $user_link the database connection * @@ -740,8 +743,9 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) * Displays the fields used by the "new user" form as well as the * "change login information / copy user" form. * - * @param string $mode are we creating a new user or are we just - * changing one? (allowed values: 'new', 'change') + * @param string $mode are we creating a new user or are we just + * changing one? (allowed values: 'new', 'change') + * * @global array $cfg the phpMyAdmin configuration * @global ressource $user_link the database connection * @@ -1442,8 +1446,8 @@ $link_export = '
' . "\n"; - $sql_query = - 'SELECT *,' . + $sql_query = 'SELECT *,' . " IF(`Password` = _latin1 '', 'N', 'Y') AS 'Password'" . ' FROM `mysql`.`user`'; @@ -1868,8 +1869,10 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } echo PMA_generate_common_hidden_inputs($_params); - PMA_displayPrivTable(PMA_ifSetOr($dbname, '*', 'length'), - PMA_ifSetOr($tablename, '*', 'length')); + PMA_displayPrivTable( + PMA_ifSetOr($dbname, '*', 'length'), + PMA_ifSetOr($tablename, '*', 'length') + ); echo '' . "\n"; @@ -1896,8 +1899,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . '' . "\n" . '' . "\n"; - $user_host_condition = - ' WHERE `User`' + $user_host_condition = ' WHERE `User`' . ' = \'' . PMA_sqlAddSlashes($username) . "'" . ' AND `Host`' . ' = \'' . PMA_sqlAddSlashes($hostname) . "'"; @@ -1946,7 +1948,8 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // as we are in the db specific rights display we want // all db names escaped, also from other sources $db_rights_row['Db'] = PMA_escape_mysql_wildcards( - $db_rights_row['Db']); + $db_rights_row['Db'] + ); $db_rights[$db_rights_row['Db']] = $db_rights_row; } @@ -2015,8 +2018,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs PMA_DBI_free_result($db_rights_result); unset($db_rights_sql, $db_rights_sqls, $db_rights_result, $db_rights_row); - $sql_query = - 'SELECT `Table_name`,' + $sql_query = 'SELECT `Table_name`,' .' `Table_priv`,' .' IF(`Column_priv` = _latin1 \'\', 0, 1)' .' AS \'Column_priv\'' @@ -2064,17 +2066,23 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } echo '' . "\n" . ' '; - printf($link_edit, htmlspecialchars(urlencode($username)), + printf( + $link_edit, + htmlspecialchars(urlencode($username)), urlencode(htmlspecialchars($hostname)), urlencode((! isset($dbname)) ? $row['Db'] : htmlspecialchars($dbname)), - urlencode((! isset($dbname)) ? '' : $row['Table_name'])); + urlencode((! isset($dbname)) ? '' : $row['Table_name']) + ); echo '' . "\n" . ' '; if (! empty($row['can_delete']) || isset($row['Table_name']) && strlen($row['Table_name'])) { - printf($link_revoke, htmlspecialchars(urlencode($username)), + printf( + $link_revoke, + htmlspecialchars(urlencode($username)), urlencode(htmlspecialchars($hostname)), urlencode((! isset($dbname)) ? $row['Db'] : htmlspecialchars($dbname)), - urlencode((! isset($dbname)) ? '' : $row['Table_name'])); + urlencode((! isset($dbname)) ? '' : $row['Table_name']) + ); } echo '' . "\n" . '' . "\n"; @@ -2209,7 +2217,10 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs '2' => __('Grant all privileges on wildcard name (username\\_%)')); if (! empty($dbname) ) { - $choices['3'] = sprintf( __('Grant all privileges on database "%s"'), htmlspecialchars($dbname)); + $choices['3'] = sprintf( + __('Grant all privileges on database "%s"'), + htmlspecialchars($dbname) + ); $default_choice = 3; echo '' . "\n"; } @@ -2295,8 +2306,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . ' AND `Trigger_priv` = \'N\''; } - $sql_query = - '(SELECT ' . $list_of_privileges . ', `Db`' + $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' .' FROM `mysql`.`db`' .' WHERE \'' . PMA_sqlAddSlashes($checkprivs) . "'" .' LIKE `Db`' @@ -2362,7 +2372,8 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs urlencode($current_user), urlencode($current_host), urlencode(! isset($current['Db']) || $current['Db'] == '*' ? '' : $current['Db']), - ''); + '' + ); $user_form .= '' . "\n" . ' ' . "\n"; } From ef4e13d459d45e957076d50ec7a04169572f63dc Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 14 Sep 2011 23:30:16 +0530 Subject: [PATCH 09/10] Proper indentation --- server_privileges.php | 214 +++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/server_privileges.php b/server_privileges.php index 2d67d84c5d..58114a25d0 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -378,31 +378,31 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false) function PMA_display_column_privs($columns, $row, $name_for_select, $priv_for_header, $name, $name_for_dfn, $name_for_current) { - echo '
' . "\n" - . '
' . "\n" - . ' ' . "\n"; - foreach ($columns as $current_column => $current_column_privileges) { - echo ' ' . "\n"; + foreach ($columns as $current_column => $current_column_privileges) { + echo ' ' . "\n"; + } - echo ' ' . "\n" - . ' ' . __('Or') . '' . "\n" - . ' ' . "\n" - . '
' . "\n"; + echo ' ' . "\n" + . ' ' . __('Or') . '' . "\n" + . ' ' . "\n" + . ' ' . "\n"; } // end function @@ -734,7 +734,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) . $row['max_user_connections'] . '" size="11" maxlength="11" title="' . __('Limits the number of simultaneous connections the user may have.') . '" />' . "\n" . ' ' . "\n" . ' ' . "\n"; - } + } // for Safari 2.0.2 echo '
' . "\n"; } @@ -828,16 +828,16 @@ function PMA_displayLoginInformationFields($mode = 'new') // when we start editing a user, $GLOBALS['pred_hostname'] is not defined if (! isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) { switch (strtolower($GLOBALS['hostname'])) { - case 'localhost': - case '127.0.0.1': - $GLOBALS['pred_hostname'] = 'localhost'; - break; - case '%': - $GLOBALS['pred_hostname'] = 'any'; - break; - default: - $GLOBALS['pred_hostname'] = 'userdefined'; - break; + case 'localhost': + case '127.0.0.1': + $GLOBALS['pred_hostname'] = 'localhost'; + break; + case '%': + $GLOBALS['pred_hostname'] = 'any'; + break; + default: + $GLOBALS['pred_hostname'] = 'userdefined'; + break; } } echo '

' . "\n" . PMA_getIcon('b_usrlist.png') @@ -122,7 +122,7 @@ if (!$is_superuser) { include './libraries/footer.inc.php'; } -$random_n = mt_rand(0,1000000); // a random number that will be appended to the id of the user forms +$random_n = mt_rand(0, 1000000); // a random number that will be appended to the id of the user forms /** * Escapes wildcard in a database+table specification @@ -167,7 +167,7 @@ function PMA_rangeOfUsers($initial = '') { // strtolower() is used because the User field // might be BINARY, so LIKE would be case sensitive - if (!empty($initial)) { + if (! empty($initial)) { $ret = " WHERE `User` LIKE '" . PMA_sqlAddSlashes($initial, true) . "%'" . " OR `User` LIKE '" . PMA_sqlAddSlashes(strtolower($initial), true) . "%'"; } else { @@ -309,7 +309,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false) __('Allows executing stored routines.')), ); - if (!empty($row) && isset($row['Table_priv'])) { + if (! empty($row) && isset($row['Table_priv'])) { $row1 = PMA_DBI_fetch_single_row( 'SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';', 'ASSOC', $GLOBALS['userlink'] @@ -327,10 +327,10 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false) $privs = array(); $allPrivileges = true; foreach ($grants as $current_grant) { - if ((!empty($row) && isset($row[$current_grant[0]])) + if ((! empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]])) ) { - if ((!empty($row) && $row[$current_grant[0]] == 'Y') + if ((! empty($row) && $row[$current_grant[0]] == 'Y') || (empty($row) && ($GLOBALS[$current_grant[0]] == 'Y' || (is_array($GLOBALS[$current_grant[0]]) @@ -342,7 +342,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = false) } else { $privs[] = $current_grant[1]; } - } elseif (!empty($GLOBALS[$current_grant[0]]) + } elseif (! empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) { if ($enableHTML) { @@ -695,7 +695,7 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) . ' ' . "\n" . ' ' . "\n" @@ -848,7 +848,7 @@ function PMA_displayLoginInformationFields($mode = 'new') . ((isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost') ? ' selected="selected"' : '') . '>' . __('Local') . '' . "\n"; - if (!empty($thishost)) { + if (! empty($thishost)) { echo ' '."\n" + .' ' . "\n" .'' . "\n" .'' . htmlspecialchars($hostname) . '' . "\n"; $new_user_string .= ''; - if (!empty($password) || isset($pma_pw)) { + if (! empty($password) || isset($pma_pw)) { $new_user_string .= __('Yes'); } else { $new_user_string .= '' . __('No') . ''; @@ -1485,8 +1485,8 @@ if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_RE $new_user_string .=''; - $new_user_string .= ''.sprintf($link_edit, urlencode($username), urlencode($hostname), '', '' ).''."\n"; - $new_user_string .= ''.sprintf($link_export, urlencode($username), urlencode($hostname), (isset($initial) ? $initial : '')).''."\n"; + $new_user_string .= '' . sprintf($link_edit, urlencode($username), urlencode($hostname), '', '') . '' . "\n"; + $new_user_string .= '' . sprintf($link_export, urlencode($username), urlencode($hostname), (isset($initial) ? $initial : '')) . '' . "\n"; $new_user_string .= ''; @@ -1506,7 +1506,7 @@ if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_RE if (isset($update_privs)) { $extra_data['db_specific_privs'] = false; if (isset($dbname_is_wildcard)) { - $extra_data['db_specific_privs'] = !$dbname_is_wildcard; + $extra_data['db_specific_privs'] = ! $dbname_is_wildcard; } $new_privileges = join(', ', PMA_extractPrivInfo('', true)); @@ -1579,7 +1579,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $sql_query = 'SELECT * FROM `mysql`.`user`'; $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE); - if (!$res) { + if (! $res) { PMA_Message::error(__('No Privileges'))->display(); PMA_DBI_free_result($res); unset($res); @@ -1802,7 +1802,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $flushnote->addParam('', false); $flushnote->addParam('', false); $flushnote->display(); - } + } } else { @@ -1817,7 +1817,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '

' . "\n" . PMA_getIcon('b_usredit.png') . __('Edit Privileges') . ': ' - . __('User') ; + . __('User'); if (isset($dbname)) { echo ' ' . __('Add privileges on the following database') . ':' . "\n"; - if (!empty($pred_db_array)) { + if (! empty($pred_db_array)) { echo ' ' . "\n" . ' ' . "\n"; foreach ($pred_tbl_array as $current_table) {