diff options
36 files changed, 195 insertions, 182 deletions
@@ -21,6 +21,21 @@ $Source$ * libraries/display_export.lib.php, css/phpmyadmin.css.php, themes/*/css/theme_right.css.php: 'fixed' layout of export screen for buggy safari and opera + * db_operations.php, export.php, index.php, left.php, + libraries\auth\cookie.auth.lib.php, libraries\common.lib.php, + libraries\db_details_common.inc.php, libraries\db_table_exists.lib.php, + libraries\display_export.lib.php, libraries\display_tbl.lib.php, + libraries\export\sql.php, libraries\footer.inc.php, + libraries\header.inc.php, libraries\left_header.inc.php, + libraries\mult_submits.inc.php, libraries\mysql_charsets.lib.php, + libraries\relation.lib.php, libraries\server_common.inc.php, + libraries\sql_query_form.lib.php, libraries\sqlparser.lib.php, + libraries\tbl_indexes.lib.php, libraries\tbl_move_copy.php, + libraries\url_generating.lib.php, querywindow.php, scripts\setup.php, + server_databases.php, server_privileges.php, server_processlist.php, + sql.php, tbl_addfield.php, tbl_alter.php, tbl_change.php, tbl_create.php, + tbl_indexes.php, tbl_replace.php: + allow 0 as name for database, table collumn, alias and index 2006-01-12 Marc Delisle <lem9@users.sourceforge.net> * Documentation.html: typo, thanks to Cédric Corazza diff --git a/db_operations.php b/db_operations.php index d28f967277..3f3788b7dd 100644 --- a/db_operations.php +++ b/db_operations.php @@ -33,7 +33,7 @@ if (isset($db) && $move = FALSE; } - if (!isset($newname) || empty($newname)) { + if (!isset($newname) || !strlen($newname)) { $message = $strDatabaseEmpty; } else { if ($move || diff --git a/export.php b/export.php index 0bc0ad0ded..3f3de6544a 100644 --- a/export.php +++ b/export.php @@ -23,9 +23,9 @@ require('./libraries/export/' . PMA_securePath($type) . '.php'); // Generate error url if ($export_type == 'server') { $err_url = 'server_export.php?' . PMA_generate_common_url(); -} elseif ($export_type == 'database' && !empty($db)) { +} elseif ($export_type == 'database' && isset($db) && strlen($db)) { $err_url = 'db_details_export.php?' . PMA_generate_common_url($db); -} elseif ($export_type == 'table' && !empty($db) && !empty($table)) { +} elseif ($export_type == 'table' && isset($db) && strlen($db) && isset($table) && strlen($table)) { $err_url = 'tbl_properties_export.php?' . PMA_generate_common_url($db, $table); } else { die('Bad parameters!'); @@ -79,9 +79,9 @@ foreach( $drops as $each_drop ) { } unset( $drops, $each_drop ); -if ( empty( $GLOBALS['db'] ) ) { +if ( ! isset($GLOBALS['db']) || ! strlen($GLOBALS['db']) ) { $main_target = $GLOBALS['cfg']['DefaultTabServer']; -} elseif ( empty( $GLOBALS['table'] ) ) { +} elseif ( ! isset($GLOBALS['table']) || ! strlen($GLOBALS['table']) ) { $_GET['db'] = $GLOBALS['db']; $main_target = $GLOBALS['cfg']['DefaultTabDatabase']; } else { @@ -35,7 +35,7 @@ if ($server > 0) { // it defines $num_dbs and $dblist PMA_availableDatabases(); - if ( empty( $db ) && count( $dblist ) === 1 ) { + if ( ( ! isset($db) || ! strlen($db) ) && count( $dblist ) === 1 ) { reset( $dblist ); $db = current( $dblist ); } @@ -175,7 +175,7 @@ $href_left = '<a onclick="if ( toggle(\'%d\') ) return false;"' $element_counter = 0; -if ( $GLOBALS['cfg']['LeftFrameLight'] && ! empty( $db ) ) { +if ( $GLOBALS['cfg']['LeftFrameLight'] && isset($db) && strlen($db) ) { // show selected databasename as link to DefaultTabDatabase-page // with table count in () $common_url_query = PMA_generate_common_url( $db ); diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 542b2e38c9..375ed7927b 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -467,10 +467,10 @@ function PMA_auth_set_user() // any parameters to pass? $url_params = array(); - if ( ! empty($GLOBALS['db']) ) { + if ( isset($GLOBALS['db']) && strlen($GLOBALS['db']) ) { $url_params['db'] = $GLOBALS['db']; } - if ( ! empty($GLOBALS['table']) ) { + if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) ) { $url_params['table'] = $GLOBALS['table']; } // Language change from the login panel needs to be remembered diff --git a/libraries/common.lib.php b/libraries/common.lib.php index b3a2e4d113..1ebf5ca145 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -264,7 +264,7 @@ function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink, // with regular expressions. while ($row = PMA_DBI_fetch_assoc($rs)) { // loic1: all databases cases - part 1 - if (empty($row['Db']) || $row['Db'] == '%') { + if ( !isset($row['Db']) || ! strlen($row['Db']) || $row['Db'] == '%') { $uva_mydbs['%'] = 1; break; } @@ -1151,7 +1151,7 @@ if (!defined('PMA_MINIMUM_COMMON')) { { // '0' is also empty for php :-( if ($do_it - && (!empty($a_name) || $a_name == '0') && $a_name != '*') { + && strlen($a_name) && $a_name != '*') { if (is_array($a_name)) { $result = array(); @@ -1312,7 +1312,7 @@ if (typeof(window.parent) != 'undefined' $message = PMA_sanitize($message); // Corrects the tooltip text via JS if required - if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) { + if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) { $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); if ($result) { $tbl_status = PMA_DBI_fetch_assoc($result); @@ -2152,7 +2152,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $column_for_condition = $true_column; @@ -2463,8 +2463,8 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm */ function PMA_getDbLink($database = null) { - if (empty($database)) { - if (empty($GLOBALS['db'])) { + if (!strlen($database)) { + if (!strlen($GLOBALS['db'])) { return ''; } $database = $GLOBALS['db']; @@ -2508,17 +2508,17 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm */ function PMA_setCookie($cookie, $value, $default = null) { - if (!empty($value) && null !== $default && $value === $default) { + if (strlen($value) && null !== $default && $value === $default) { // remove cookie, default value is used return PMA_removeCookie($cookie); } - if (empty($value) && isset($_COOKIE[$cookie])) { + if (! strlen($value) && isset($_COOKIE[$cookie])) { // remove cookie, value is empty return PMA_removeCookie($cookie); } - if (empty($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { + if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) { // set cookie with new value return setcookie($cookie, $value, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']); diff --git a/libraries/db_details_common.inc.php b/libraries/db_details_common.inc.php index 7e9f779c3e..68f64756a9 100644 --- a/libraries/db_details_common.inc.php +++ b/libraries/db_details_common.inc.php @@ -30,10 +30,10 @@ $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db); */ if (!isset($is_db) || !$is_db) { // Not a valid db name -> back to the welcome page - if (!empty($db)) { + if (isset($db) && strlen($db)) { $is_db = PMA_DBI_select_db($db); } - if (empty($db) || !$is_db) { + if (!isset($db) || !strlen($db) || !$is_db) { PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); exit; } diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index a5a7aaf977..ce5e33a326 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -8,10 +8,10 @@ */ if (!isset($is_db) || !$is_db) { // Not a valid db name -> back to the welcome page - if (!empty($db)) { + if (isset($db) && strlen($db)) { $is_db = @PMA_DBI_select_db($db); } - if (empty($db) || !$is_db) { + if (!isset($db) || !strlen($db) || !$is_db) { if (!defined('IS_TRANSFORMATION_WRAPPER')) { PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); } @@ -20,15 +20,15 @@ if (!isset($is_db) || !$is_db) { } // end if (ensures db exists) if (!isset($is_table) || !$is_table) { // Not a valid table name -> back to the db_details.php - if (!empty($table)) { + if (isset($table) && strlen($table)) { $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); } - if (empty($table) + if (! isset($table) && ! strlen($table) || !($is_table && @PMA_DBI_num_rows($is_table))) { $redirect = TRUE; if (!defined('IS_TRANSFORMATION_WRAPPER')) { $redirect = TRUE; - if (!empty($table)) { + if (isset($table) && strlen($table)) { PMA_DBI_free_result($is_table); // SHOW TABLES doesn't show temporary tables, so try select (as it can happen just in case temporary table, it should be fast): $is_table2 = PMA_DBI_try_query('SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, TRUE) . '`;', NULL, PMA_DBI_QUERY_STORE); diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 764636acdd..cdb913095a 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -36,7 +36,7 @@ function PMA_exportIsActive($what, $val) { <?php $hide_structure = false; $hide_sql = false; -$hide_xml = empty($db); +$hide_xml = (bool) (isset($db) && strlen($db)); if ($export_type == 'server') { echo PMA_generate_common_hidden_inputs('', '', 1); } elseif ($export_type == 'database') { @@ -769,7 +769,7 @@ function show_checked_option() { //]]> </script> -<?php if ( ! empty( $table ) && ! isset( $num_tables ) ) { ?> +<?php if ( isset($table) && strlen($table) && ! isset( $num_tables ) ) { ?> <div class="formelementrow"> <?php echo sprintf( $strDumpXRows, diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 74b9352255..a7e212531b 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -30,7 +30,7 @@ if (!isset($pos)) { * the "display printable view" option. * Of course '0'/'1' means the feature won't/will be enabled. * - * @param string the synthetic value for display_mode (see §1 a few + * @param string the synthetic value for display_mode (see �1 a few * lines above for explanations) * @param integer the total number of rows returned by the sql query * without any programmatically appended "LIMIT" clause @@ -157,7 +157,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) $the_total = $unlim_num_rows; } else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') - && (!empty($db) && !empty($table))) { + && (isset($db) && strlen($db) && !empty($table))) { $the_total = PMA_countRecords($db, $table, TRUE); } @@ -741,7 +741,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ && isset($analyzed_sql[0]['select_expr'][$i]['column']) && $analyzed_sql[0]['select_expr'][$i]['expr'] != $analyzed_sql[0]['select_expr'][$i]['column'] - && !empty($fields_meta[$i]->table)) ) { + && isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) ) { $sort_tbl = PMA_backquote($fields_meta[$i]->table) . ' . '; } else { $sort_tbl = ''; @@ -1229,7 +1229,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; @@ -1240,7 +1240,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($map[$meta->name])) { // Field to display from the foreign table? - if (!empty($map[$meta->name][2])) { + if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) @@ -1355,7 +1355,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; - if (!empty($alias)) { + if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; @@ -1366,7 +1366,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($map[$meta->name])) { // Field to display from the foreign table? - if (!empty($map[$meta->name][2])) { + if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) @@ -1756,7 +1756,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $tabs = '(\'' . join('\',\'', $target) . '\')'; if ($cfgRelation['displaywork']) { - if (empty($table)) { + if (! isset($table) || ! strlen($table)) { $exist_rel = FALSE; } else { $exist_rel = PMA_getForeigners($db, $table, '', 'both'); diff --git a/libraries/export/sql.php b/libraries/export/sql.php index e39ac6a105..daebc9f835 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -560,7 +560,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) // a binary field // Note: with mysqli, under MySQL 4.1.3, we get the flag // "binary" for those field types (I don't know why) - } else if (stristr($field_flags[$j], 'BINARY') + } elseif (stristr($field_flags[$j], 'BINARY') && isset($GLOBALS['hexforbinary']) && $fields_meta[$j]->type != 'datetime' && $fields_meta[$j]->type != 'date' diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php index c0d0839565..507c3cdbf7 100644 --- a/libraries/footer.inc.php +++ b/libraries/footer.inc.php @@ -21,7 +21,7 @@ require_once('./libraries/relation.lib.php'); // for PMA_setHistory() <script type="text/javascript" language="javascript"> //<![CDATA[ <?php - if ( ! isset( $GLOBALS['no_history'] ) && ! empty( $GLOBALS['db'] ) && empty( $GLOBALS['error_message'] ) ) { + if ( ! isset( $GLOBALS['no_history'] ) && isset( $GLOBALS['db'] ) && strlen($GLOBALS['db']) && empty( $GLOBALS['error_message'] ) ) { $table = isset( $GLOBALS['table'] ) ? $GLOBALS['table'] : ''; // updates current settings ?> diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 339ce36f70..4a725bdaf5 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -166,7 +166,7 @@ if (empty($GLOBALS['is_header_sent'])) { $GLOBALS['strServer'], 's_host.png' ); - if (!empty($GLOBALS['db'])) { + if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { echo $separator; printf( $item, @@ -176,7 +176,7 @@ if (empty($GLOBALS['is_header_sent'])) { $GLOBALS['strDatabase'], 's_db.png' ); - if (!empty($GLOBALS['table'])) { + if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) { require_once('./libraries/tbl_properties_table_info.inc.php'); echo $separator; diff --git a/libraries/left_header.inc.php b/libraries/left_header.inc.php index 03e3a2cb2c..946637230b 100644 --- a/libraries/left_header.inc.php +++ b/libraries/left_header.inc.php @@ -8,8 +8,8 @@ */ if ( empty( $query_url ) ) { - $db = empty( $db ) ? '' : $db; - $table = empty( $table ) ? '' : $table; + $db = ! isset( $db ) ? '' : $db; + $table = ! isset( $table ) ? '' : $table; $query_url = PMA_generate_common_url( $db, $table ); } diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index b6164f18c8..64d4be9400 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -8,16 +8,16 @@ */ if (!empty($submit_mult) && ($submit_mult != $strWithChecked) - && ( !empty($selected_db) - || !empty($selected_tbl) - || !empty($selected_fld) + && ( ( isset($selected_db) && strlen($selected_db) ) + || ( isset($selected_tbl) && strlen($selected_tbl) ) + || ( isset($selected_fld) && strlen($selected_fld) ) || !empty($rows_to_delete) )) { - if (!empty($selected_db)) { + if (isset($selected_db) && strlen($selected_db)) { $selected = $selected_db; $what = 'drop_db'; - } elseif (!empty($selected_tbl)) { + } elseif (isset($selected_tbl) && strlen($selected_tbl)) { if ($submit_mult == $strPrintView) { require('./tbl_printview.php'); } else { @@ -54,7 +54,7 @@ if (!empty($submit_mult) break; } // end switch } - } elseif (!empty($selected_fld)) { + } elseif (isset($selected_fld) && strlen($selected_fld)) { $selected = $selected_fld; switch ($submit_mult) { case $strDrop: @@ -126,12 +126,11 @@ if (!empty($submit_mult) if ( !empty($submit_mult) && !empty($what)) { $js_to_run = 'functions.js'; unset($message); - if (!empty($table)) { + if (isset($table) && strlen($table)) { require('./libraries/tbl_properties_common.php'); $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; require('./libraries/tbl_properties_table_info.inc.php'); - } - elseif (!empty($db)) { + } elseif (isset($db) && strlen($db)) { require('./libraries/db_details_common.inc.php'); require('./libraries/db_details_db_info.inc.php'); } @@ -155,11 +154,11 @@ if ( !empty($submit_mult) && !empty($what)) { break; case 'drop_tbl': - $current = urldecode($sval); - if (!empty($views) && in_array($current, $views)) { + $current = urldecode($sval); + if (!empty($views) && in_array($current, $views)) { $full_query_views .= (empty($full_query_views) ? 'DROP VIEW ' : ', ') . PMA_backquote(htmlspecialchars($current)); - } else { + } else { $full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ') . PMA_backquote(htmlspecialchars($current)); } @@ -215,12 +214,12 @@ if ( !empty($submit_mult) && !empty($what)) { } if ($what == 'drop_tbl') { if (!empty($full_query)) { - $full_query .= ';<br />' . "\n"; - } - if (!empty($full_query_views)) { - $full_query .= $full_query_views . ';<br />' . "\n"; - } - unset($full_query_views); + $full_query .= ';<br />' . "\n"; + } + if (!empty($full_query_views)) { + $full_query .= $full_query_views . ';<br />' . "\n"; + } + unset($full_query_views); } // Displays the form @@ -317,10 +316,10 @@ elseif ($mult_btn == $strYes) { case 'drop_tbl': PMA_relationsCleanupTable($db, $selected[$i]); - $current = urldecode($selected[$i]); - if (!empty($views) && in_array($current, $views)) { - $sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ') - . PMA_backquote($current); + $current = urldecode($selected[$i]); + if (!empty($views) && in_array($current, $views)) { + $sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ') + . PMA_backquote($current); } else { $sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ') . PMA_backquote($current); @@ -407,9 +406,9 @@ elseif ($mult_btn == $strYes) { if ($query_type == 'drop_tbl') { if (!empty($sql_query)) { - $sql_query .= ';'; - } else if (!empty($sql_query_views)) { - $sql_query = $sql_query_views . ';'; + $sql_query .= ';'; + } elseif (!empty($sql_query_views)) { + $sql_query = $sql_query_views . ';'; unset($sql_query_views); } } @@ -419,11 +418,11 @@ elseif ($mult_btn == $strYes) { } elseif (!$run_parts) { PMA_DBI_select_db($db); $result = PMA_DBI_query($sql_query); - if (!empty($sql_query_views)) { - $sql_query .= ' ' . $sql_query_views . ';'; - PMA_DBI_query($sql_query_views); - unset($sql_query_views); - } + if (!empty($sql_query_views)) { + $sql_query .= ' ' . $sql_query_views . ';'; + PMA_DBI_query($sql_query_views); + unset($sql_query_views); + } } } ?> diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 1f4f3f22eb..ba75d66a9e 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -122,7 +122,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ // for databases. PMA_DBI_select_db( $db ); $return = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE "collation_database"', 0, 1 ); - if ( ! empty( $GLOBALS['db'] ) && $db !== $GLOBALS['db'] ) { + if ( isset( $GLOBALS['db'] ) && $db !== $GLOBALS['db'] ) { PMA_DBI_select_db( $GLOBALS['db'] ); } return $return; diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 7e39b149c7..a2d06f950f 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -295,7 +295,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') { FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\' AND master_table = \'' . PMA_sqlAddslashes($table) . '\' '; - if (!empty($column)) { + if (isset($column) && strlen($column)) { $rel_query .= ' AND master_field = \'' . PMA_sqlAddslashes($column) . '\''; } $relations = PMA_query_as_cu($rel_query); @@ -311,7 +311,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') { unset($relations); } - if (($source == 'both' || $source == 'innodb') && !empty($table)) { + if (($source == 'both' || $source == 'innodb') && isset($table) && strlen($table)) { $show_create_table_query = 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table); $show_create_table_res = PMA_DBI_query($show_create_table_query); @@ -372,7 +372,8 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both') { if (isset($GLOBALS['information_schema_relations'][$table])) { foreach ($GLOBALS['information_schema_relations'][$table] as $field => $relations) { - if ((empty($column) || $column == $field) && empty($foreign[$field])) { + if ( ( ! isset($column) || ! strlen($column) || $column == $field ) + && ( ! isset($foreign[$field]) || ! strlen($foreign[$field]) ) ) { $foreign[$field] = $relations; } } @@ -513,7 +514,7 @@ function PMA_getComments($db, $table = '') { $comment[$col] = $row['comment']; // if this version supports native comments and this function // was called with a table parameter - if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($table)) { + if (PMA_MYSQL_INT_VERSION >= 40100 && isset($table) && strlen($table)) { // if native comment found, use it instead of pmadb if (!empty($native_comment[$col])) { $comment[$col] = $native_comment[$col]; @@ -579,7 +580,7 @@ function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode='aut } // native mode is only for column comments so we need a table name - if ($mode == 'native' && !empty($table)) { + if ($mode == 'native' && isset($table) && strlen($table)) { $query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . PMA_generateAlterTable($col, $col, '', '', '', '', FALSE, '', FALSE, '', $comment, '', ''); PMA_DBI_try_query($query, NULL, PMA_DBI_QUERY_STORE); diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index 8366c8ccfc..342d276633 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -20,7 +20,7 @@ if (empty($viewing_mode)) { /** * Set parameters for links */ -$url_query = PMA_generate_common_url((!empty($db) ? $db : '')); +$url_query = PMA_generate_common_url((isset($db) ? $db : '')); /** * Defines the urls to return to in case of error in a sql statement diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php index 5bb15c3be8..c5fe924949 100644 --- a/libraries/sql_query_form.lib.php +++ b/libraries/sql_query_form.lib.php @@ -81,12 +81,11 @@ function PMA_sqlQueryForm( $query = true, $display_tab = false ) { $table = ''; $db = ''; - if ( empty( $GLOBALS['db'] ) ) { + if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) { // prepare for server related $goto = empty( $GLOBALS['goto'] ) ? 'server_sql.php' : $GLOBALS['goto']; - } - elseif ( empty( $GLOBALS['table'] ) ) { + } elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) { // prepare for db related $db = $GLOBALS['db']; $goto = empty( $GLOBALS['goto'] ) ? @@ -198,13 +197,12 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) { $table = ''; $db = ''; $fields_list = array(); - if ( empty( $GLOBALS['db'] ) ) { + if ( ! isset( $GLOBALS['db'] ) || ! strlen($GLOBALS['db']) ) { // prepare for server related $legend = sprintf( $GLOBALS['strRunSQLQueryOnServer'], htmlspecialchars( $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) ); - } - elseif ( empty( $GLOBALS['table'] ) ) { + } elseif ( ! isset( $GLOBALS['table'] ) || ! strlen($GLOBALS['table']) ) { // prepare for db related $db = $GLOBALS['db']; // if you want navigation: @@ -288,7 +286,7 @@ function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) { foreach ( $fields_list as $field ) { echo '<option value="' .PMA_backquote( htmlspecialchars( $field['Field'] ) ) . '"'; - if ( ! empty( $field['Field'] ) && isset($field['Comment']) ) { + if ( isset( $field['Field'] ) && strlen($field['Field']) && isset($field['Comment']) ) { echo ' title="' . htmlspecialchars( $field['Comment'] ) . '"'; } echo '>' . htmlspecialchars( $field['Field'] ) . '</option>' . "\n"; diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index a25c19210e..6bc9c13371 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -1094,7 +1094,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { 'column' => '' ); - if (!empty($alias_for_select_expr)) { + if (isset($alias_for_select_expr) && strlen($alias_for_select_expr)) { // we had found an alias for this select expression $subresult['select_expr'][$current_select_expr]['alias'] = $alias_for_select_expr; unset($alias_for_select_expr); @@ -1156,7 +1156,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { 'table_alias' => '', 'table_true_name' => '' ); - if (!empty($alias_for_table_ref)) { + if (isset($alias_for_table_ref) && strlen($alias_for_table_ref)) { $subresult['table_ref'][$current_table_ref]['table_alias'] = $alias_for_table_ref; unset($alias_for_table_ref); } @@ -1193,7 +1193,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $alias = $subresult['table_ref'][$tr]['table_alias']; $truename = $subresult['table_ref'][$tr]['table_true_name']; for ($se=0; $se <= $current_select_expr; $se++) { - if (!empty($alias) && $subresult['select_expr'][$se]['table_true_name'] + if (isset($alias) && strlen($alias) && $subresult['select_expr'][$se]['table_true_name'] == $alias) { $subresult['select_expr'][$se]['table_true_name'] = $truename; diff --git a/libraries/tbl_indexes.lib.php b/libraries/tbl_indexes.lib.php index 413e40d37e..16f5953acc 100644 --- a/libraries/tbl_indexes.lib.php +++ b/libraries/tbl_indexes.lib.php @@ -215,7 +215,8 @@ function PMA_show_indexes($table, &$indexes, &$indexes_info, &$indexes_data, $di echo ' <tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n"; } - if (!empty($indexes_data[$index_name][$seq_index]['Sub_part'])) { + if ( isset($indexes_data[$index_name][$seq_index]['Sub_part']) + && strlen($indexes_data[$index_name][$seq_index]['Sub_part']) ) { echo ' <td>' . $col_name . '</td>' . "\n"; echo ' <td align="right">' . "\n" . ' ' . $indexes_data[$index_name][$seq_index]['Sub_part'] . "\n" diff --git a/libraries/tbl_move_copy.php b/libraries/tbl_move_copy.php index 621c96e529..de3b9a886b 100644 --- a/libraries/tbl_move_copy.php +++ b/libraries/tbl_move_copy.php @@ -97,7 +97,9 @@ function PMA_table_move_copy($source_db, $source_table, $target_db, $target_tabl } $source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table); - if (empty($target_db)) $target_db = $source_db; + if ( ! isset($target_db) || ! strlen($target_db) ) { + $target_db = $source_db; + } // Doing a select_db could avoid some problems with replicated databases, // when moving table from replicated one to not replicated one diff --git a/libraries/url_generating.lib.php b/libraries/url_generating.lib.php index 2d5886e77b..6dd07b97c2 100644 --- a/libraries/url_generating.lib.php +++ b/libraries/url_generating.lib.php @@ -39,10 +39,10 @@ function PMA_generate_common_hidden_inputs( $db = '', $table = '', $indent = 0, $skip =& $_skip; } else { $params = array(); - if ( ! empty( $db ) ) { + if ( isset($db) && strlen($db) ) { $params['db'] = $db; } - if ( ! empty( $table ) ) { + if ( isset($table) && strlen($table) ) { $params['table'] = $table; } } @@ -138,10 +138,10 @@ function PMA_generate_common_url ($db = '', $table = '', $delim = '&') $questionmark = '?'; } else { $params = array(); - if ( ! empty( $db ) ) { + if ( isset($db) && strlen($db) ) { $params['db'] = $db; } - if ( ! empty( $table ) ) { + if ( isset($table) && strlen($table) ) { $params['table'] = $table; } $questionmark = ''; diff --git a/querywindow.php b/querywindow.php index 7719320879..13f5bb4223 100644 --- a/querywindow.php +++ b/querywindow.php @@ -8,7 +8,7 @@ require_once('./libraries/common.lib.php'); * Gets the variables sent to this script, retains the db name that may have * been defined as startup option and include a core library */ -if (!empty($db)) { +if (isset($db) && strlen($db)) { $db_start = $db; } @@ -235,13 +235,11 @@ require_once './libraries/bookmark.lib.php'; if (isset($no_js) && $no_js) { // ... we redirect to appropriate query sql page // works only full if $db and $table is also stored/grabbed from $_COOKIE - if ( ! empty( $table ) ) { + if ( isset( $table ) && strlen($table) ) { require './tbl_properties.php'; - } - elseif ( ! empty( $db ) ) { + } elseif ( isset($db) && strlen($db) ) { require './db_details.php'; - } - else { + } else { require './server_sql.php'; } exit; @@ -342,8 +340,8 @@ foreach ( $_input_query_history as $sql => $history ) { } unset( $_input_query_history, $sql, $history ); ?> - <input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" /> - <input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" /> + <input type="hidden" name="db" value="<?php echo (! isset($db) ? '' : htmlspecialchars($db)); ?>" /> + <input type="hidden" name="table" value="<?php echo (! isset($table) ? '' : htmlspecialchars($table)); ?>" /> <input type="hidden" name="query_history_latest" value="" /> <input type="hidden" name="query_history_latest_db" value="" /> diff --git a/scripts/setup.php b/scripts/setup.php index 680d027d24..bbc2bf9e15 100644 --- a/scripts/setup.php +++ b/scripts/setup.php @@ -1217,7 +1217,7 @@ switch ($action) { message('error', 'Empty username while using config authentication method!'); $err = TRUE; } - if (!empty($new_server['pmadb'])) { + if ( isset($new_server['pmadb']) && strlen($new_server['pmadb'])) { // Just use defaults, should be okay for most users $pmadb = array(); $pmadb['bookmarktable'] = 'pma_bookmark'; diff --git a/server_databases.php b/server_databases.php index ffe68a5fee..56f4bea1d1 100644 --- a/server_databases.php +++ b/server_databases.php @@ -75,7 +75,7 @@ if (isset($drop_selected_dbs_x)) { } if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg['AllowUserDropDatabase'])) { - if (empty($selected_db) && ! (isset($query_type) && !empty($selected))) { + if ((! isset($selected_db) || ! strlen($selected_db)) && ! (isset($query_type) && !empty($selected))) { $message = $strNoDatabasesSelected; } else { $action = 'server_databases.php'; diff --git a/server_privileges.php b/server_privileges.php index b6e33978c4..7a4d67f830 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -14,11 +14,11 @@ require('./libraries/server_common.inc.php'); /** * Checks if a dropdown box has been used for selecting a database / table */ -if (!empty($pred_dbname)) { +if (isset($pred_dbname) && strlen($pred_dbname)) { $dbname = $pred_dbname; unset($pred_dbname); } -if (!empty($pred_tablename)) { +if (isset($pred_tablename) && strlen($pred_tablename)) { $tablename = $pred_tablename; unset($pred_tablename); } @@ -140,7 +140,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) } else { $privs[] = $current_grant[1]; } - } else if (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) { + } elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) { if ($enableHTML) { $priv_string = '<dfn title="' . $current_grant[2] . '">' . $current_grant[1] . '</dfn>'; } else { @@ -946,10 +946,10 @@ if (!empty($update_privs)) { // // It looks curious but reflects the way MySQL works - if (empty($dbname)) { + if (! isset($dbname) || ! strlen($dbname)) { $db_and_table = '*.*'; } else { - if ( !empty( $tablename ) ) { + if ( isset( $tablename ) && strlen($tablename) ) { $db_and_table = PMA_backquote( PMA_unescape_mysql_wildcards( $dbname ) ) . '.'; $db_and_table .= PMA_backquote( $tablename ); } else { @@ -973,7 +973,7 @@ if (!empty($update_privs)) { // FIXME: similar code appears twice in this script if ( ( isset($Grant_priv) && $Grant_priv == 'Y') - || ( empty($dbname) && PMA_MYSQL_INT_VERSION >= 40002 + || ( ( ! isset($dbname) || ! strle($dbname) ) && PMA_MYSQL_INT_VERSION >= 40002 && ( isset($max_questions) || isset($max_connections) || isset($max_updates) || isset($max_user_connections)))) { @@ -1022,10 +1022,10 @@ if (!empty($update_privs)) { */ if (!empty($revokeall)) { - if (empty($dbname)) { + if ( ! isset($dbname) || ! strlen($dbname) ) { $db_and_table = '*.*'; } else { - if ( empty( $tablename ) ) { + if ( ! isset( $tablename ) || ! strlen($tablename) ) { $db_and_table = PMA_backquote( $dbname ) . '.'; $db_and_table .= '*'; } else { @@ -1046,7 +1046,7 @@ if (!empty($revokeall)) { } $sql_query = $sql_query0 . (isset($sql_query1) ? ' ' . $sql_query1 : ''); $message = sprintf($GLOBALS['strRevokeMessage'], '\'' . $username . '\'@\'' . $hostname . '\''); - if (empty($tablename)) { + if ( ! isset($tablename) || ! strlen($tablename) ) { unset($dbname); } else { unset($tablename); @@ -1242,7 +1242,7 @@ $link_revoke .= '</a>'; /** * Displays the page */ -if ( empty( $adduser ) && empty( $checkprivs ) ) { +if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) ) { if ( ! isset( $username ) ) { // No username is given --> display the overview echo '<h2>' . "\n" @@ -1545,14 +1545,14 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { echo '<h2>' . "\n" . ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_usredit.png" width="16" height="16" alt="" />' : '' ) . $GLOBALS['strUser'] . ' <i><a href="server_privileges.php?' . $GLOBALS['url_query'] . '&username=' . urlencode($username) . '&hostname=' . urlencode($hostname) . '">\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'</a></i>' . "\n"; - if ( ! empty( $dbname ) ) { + if ( isset( $dbname ) && strlen($dbname) ) { if ( $dbname_is_wildcard ) { echo ' - ' . $GLOBALS['strDatabases']; } else { echo ' - ' . $GLOBALS['strDatabase']; } echo ' <i><a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['url_query'] . '&db=' . urlencode($dbname) . '&reload=1">' . htmlspecialchars($dbname) . '</a></i>' . "\n"; - if ( ! empty( $tablename ) ) { + if ( isset( $tablename ) && strlen($tablename) ) { echo ' - ' . $GLOBALS['strTable'] . ' <i><a href="' . $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query'] . '&db=' . urlencode($dbname) . '&table=' . urlencode($tablename) . '&reload=1">' . htmlspecialchars($tablename) . '</a></i>' . "\n"; } } @@ -1570,16 +1570,18 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { . PMA_generate_common_hidden_inputs('', '', 3) . '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"; - if ( ! empty( $dbname ) ) { + if ( isset( $dbname ) && strlen($dbname) ) { echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n"; - if ( ! empty( $tablename ) ) { + if ( isset( $tablename ) && strlen($tablename) ) { echo ' <input type="hidden" name="tablename" value="' . htmlspecialchars($tablename) . '" />' . "\n"; } } - PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3); + PMA_displayPrivTable((( ! isset( $dbname ) || ! strlen($dbname) ) ? '*' : $dbname), + ((( ! isset( $dbname ) || ! strlen($dbname) ) || ( ! isset( $tablename ) || ! strlen($tablename) )) ? '*' : $tablename), + TRUE, 3); echo '</form>' . "\n"; - if ( empty( $tablename ) && empty( $dbname_is_wildcard ) ) { + if ( ( ! isset( $tablename ) || ! strlen($tablename) ) && empty( $dbname_is_wildcard ) ) { // no table name was given, display all table specific rights // but only if $dbname contains no wildcards @@ -1590,13 +1592,13 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { . '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset>' . "\n" - . '<legend>' . (empty($dbname) ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges']) . '</legend>' . "\n" + . '<legend>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strDbPrivileges'] : $GLOBALS['strTblPrivileges']) . '</legend>' . "\n" . '<table class="data">' . "\n" . '<thead>' . "\n" - . '<tr><th>' . (empty($dbname) ? $GLOBALS['strDatabase'] : $GLOBALS['strTable']) . '</th>' . "\n" + . '<tr><th>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strDatabase'] : $GLOBALS['strTable']) . '</th>' . "\n" . ' <th>' . $GLOBALS['strPrivileges'] . '</th>' . "\n" . ' <th>' . $GLOBALS['strGrantOption'] . '</th>' . "\n" - . ' <th>' . (empty($dbname) ? $GLOBALS['strTblPrivileges'] : $GLOBALS['strColumnPrivileges']) . '</th>' . "\n" + . ' <th>' . (( ! isset( $dbname ) || ! strlen($dbname) ) ? $GLOBALS['strTblPrivileges'] : $GLOBALS['strColumnPrivileges']) . '</th>' . "\n" . ' <th colspan="2">' . $GLOBALS['strAction'] . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n" @@ -1613,7 +1615,7 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { // we also want privielgs for this user not in table `db` but in other table $tables = PMA_DBI_fetch_result('SHOW TABLES FROM `mysql`;'); - if ( empty( $dbname ) ) { + if ( ( ! isset( $dbname ) || ! strlen($dbname) ) ) { // no db name given, so we want all privs for the given user @@ -1775,14 +1777,14 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { $found_rows = array(); //while ( $row = PMA_DBI_fetch_assoc( $res ) ) { foreach ( $db_rights as $row ) { - $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name']; + $found_rows[] = ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $row['Table_name']; echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . '">' . "\n" - . ' <td>' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n" + . ' <td>' . htmlspecialchars(( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $row['Table_name']) . '</td>' . "\n" . ' <td><tt>' . "\n" . ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n" . ' </tt></td>' . "\n" - . ' <td>' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . '</td>' . "\n" + . ' <td>' . (((( ! isset( $dbname ) || ! strlen($dbname) ) && $row['Grant_priv'] == 'Y') || (isset($dbname) && strlen($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . '</td>' . "\n" . ' <td>'; if ( ! empty( $row['Table_privs'] ) || ! empty ( $row['Column_priv'] ) ) { echo $GLOBALS['strYes']; @@ -1793,15 +1795,15 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { . ' <td>'; printf( $link_edit, urlencode( $username ), urlencode( $hostname ), - urlencode( empty($dbname) ? $row['Db'] : $dbname ), - urlencode( empty($dbname) ? '' : $row['Table_name'] ) ); + urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $dbname ), + urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? '' : $row['Table_name'] ) ); echo '</td>' . "\n" . ' <td>'; - if ( ! empty( $row['can_delete'] ) || ! empty( $row['Table_name'] ) ) { + if ( ! empty( $row['can_delete'] ) || isset( $row['Table_name'] ) && strlen($row['Table_name']) ) { printf( $link_revoke, urlencode( $username ), urlencode( $hostname ), - urlencode( empty( $dbname ) ? $row['Db'] : $dbname ), - urlencode( empty( $dbname ) ? '' : $row['Table_name'] ) ); + urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? $row['Db'] : $dbname ), + urlencode( ( ! isset( $dbname ) || ! strlen($dbname) ) ? '' : $row['Table_name'] ) ); } echo '</td>' . "\n" . '</tr>' . "\n"; @@ -1812,7 +1814,7 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { echo '</tbody>' . "\n" . '</table>' . "\n"; - if (empty($dbname)) { + if ( ! isset( $dbname ) || ! strlen($dbname) ) { // no database name was give, display select db @@ -1869,7 +1871,7 @@ if ( empty( $adduser ) && empty( $checkprivs ) ) { . '</form>' . "\n"; } - if ( empty($dbname) && ! $user_does_not_exists ) { + if ( ( ! isset( $dbname ) || ! strlen($dbname) ) && ! $user_does_not_exists ) { echo '<form action="server_privileges.php" method="post" onsubmit="return checkPassword(this);">' . "\n" . PMA_generate_common_hidden_inputs('', '', 3) . '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n" diff --git a/server_processlist.php b/server_processlist.php index 25d61c4f83..ace89b263c 100644 --- a/server_processlist.php +++ b/server_processlist.php @@ -77,7 +77,7 @@ foreach ( $serverProcesses AS $process ) { <td class="value"><?php echo $process['Id']; ?></td> <td><?php echo $process['User']; ?></td> <td><?php echo $process['Host']; ?></td> - <td><?php echo (empty($process['db']) ? '<i>' . $strNone . '</i>' : $process['db']); ?></td> + <td><?php echo (( ! isset( $process['db'] ) || ! strlen($process['db']) ) ? '<i>' . $strNone . '</i>' : $process['db']); ?></td> <td><?php echo $process['Command']; ?></td> <td class="value"><?php echo $process['Time']; ?></td> <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td> @@ -24,7 +24,7 @@ if (!empty($goto)) { } // end if (security checkings) if (empty($goto)) { - $goto = (empty($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable']; + $goto = (! isset($table) || ! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable']; $is_gotofile = TRUE; } // end if if (!isset($err_url)) { @@ -156,11 +156,10 @@ if ($is_select) { if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) { $table = $analyzed_sql[0]['table_ref'][0]['table_true_name']; } - if (isset($analyzed_sql[0]['table_ref'][0]['db']) - && !empty($analyzed_sql[0]['table_ref'][0]['db'])) { + if ( isset($analyzed_sql[0]['table_ref'][0]['db']) + && strlen($analyzed_sql[0]['table_ref'][0]['db']) ) { $db = $analyzed_sql[0]['table_ref'][0]['db']; - } - else { + } else { $db = $prev_db; } // Nijel: don't change reload, if we already decided to reload in import @@ -189,7 +188,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) { $goto = $back; } if ($is_gotofile) { - if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) { + if (strpos(' ' . $goto, 'db_details') == 1 && isset($table) && strlen($table) ) { unset($table); } $active_page = $goto; @@ -577,9 +576,9 @@ else { if (isset($purge) && $purge == '1') { require_once('./libraries/relation_cleanup.lib.php'); - if (isset($table) && isset($db) && !empty($table) && !empty($db)) { + if (isset($table) && isset($db) && strlen($table) && strlen($db)) { PMA_relationsCleanupTable($db, $table); - } elseif (isset($db) && !empty($db)) { + } elseif (isset($db) && strlen($db)) { PMA_relationsCleanupDatabase($db); } else { // garvin: VOID. No DB/Table gets deleted. @@ -589,7 +588,7 @@ else { // garvin: If a column gets dropped, do relation magic. if (isset($cpurge) && $cpurge == '1' && isset($purgekey) && isset($db) && isset($table) - && !empty($db) && !empty($table) && !empty($purgekey)) { + && strlen($db) && strlen($table) && !empty($purgekey)) { require_once('./libraries/relation_cleanup.lib.php'); PMA_relationsCleanupColumn($db, $table, $purgekey); @@ -694,23 +693,21 @@ else { } else { $js_to_run = 'functions.js'; unset($message); - if (!empty($table)) { + if (isset($table) && strlen($table)) { require('./libraries/tbl_properties_common.php'); $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; require('./libraries/tbl_properties_table_info.inc.php'); require('./libraries/tbl_properties_links.inc.php'); - } - elseif (!empty($db)) { + } elseif (isset($db) && strlen($db)) { require('./libraries/db_details_common.inc.php'); require('./libraries/db_details_db_info.inc.php'); - } - else { + } else { require('./libraries/server_common.inc.php'); require('./libraries/server_links.inc.php'); } } - if (!empty($db)) { + if (isset($db) && strlen($db)) { require_once('./libraries/relation.lib.php'); $cfgRelation = PMA_getRelationsParam(); } diff --git a/tbl_addfield.php b/tbl_addfield.php index 80d606dfe7..db42fa4f18 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -93,12 +93,12 @@ if (isset($submit_num_fields)) { $primary_cnt = count($field_primary); for ($i = 0; $i < $primary_cnt; $i++) { $j = $field_primary[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $primary .= PMA_backquote($field_name[$j]) . ', '; } } // end for $primary = preg_replace('@, $@', '', $primary); - if (!empty($primary)) { + if (strlen($primary)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ');'; $result = PMA_DBI_query($sql_query); $sql_query_cpy .= "\n" . $sql_query . ';'; @@ -111,12 +111,12 @@ if (isset($submit_num_fields)) { $index_cnt = count($field_index); for ($i = 0; $i < $index_cnt; $i++) { $j = $field_index[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $index .= PMA_backquote($field_name[$j]) . ', '; } } // end for $index = preg_replace('@, $@', '', $index); - if (!empty($index)) { + if (strlen($index)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')'; $result = PMA_DBI_query($sql_query); $sql_query_cpy .= "\n" . $sql_query . ';'; @@ -129,12 +129,12 @@ if (isset($submit_num_fields)) { $unique_cnt = count($field_unique); for ($i = 0; $i < $unique_cnt; $i++) { $j = $field_unique[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $unique .= PMA_backquote($field_name[$j]) . ', '; } } // end for $unique = preg_replace('@, $@', '', $unique); - if (!empty($unique)) { + if (strlen($unique)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')'; $result = PMA_DBI_query($sql_query); $sql_query_cpy .= "\n" . $sql_query . ';'; @@ -151,7 +151,7 @@ if (isset($submit_num_fields)) { $fulltext .= PMA_backquote($field_name[$j]) . ', '; } // end for $fulltext = preg_replace('@, $@', '', $fulltext); - if (!empty($fulltext)) { + if (strlen($fulltext)) { $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')'; $result = PMA_DBI_query($sql_query); $sql_query_cpy .= "\n" . $sql_query . ';'; @@ -167,7 +167,7 @@ if (isset($submit_num_fields)) { // garvin: Update comment table, if a comment was set. if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork'] && PMA_MYSQL_INT_VERSION < 40100) { foreach ($field_comments AS $fieldindex => $fieldcomment) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, '', 'pmadb'); } } @@ -176,7 +176,7 @@ if (isset($submit_num_fields)) { // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { foreach ($field_mimetype AS $fieldindex => $mimetype) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } diff --git a/tbl_alter.php b/tbl_alter.php index 49fdb3b27d..1999574d32 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -83,7 +83,7 @@ if (isset($do_save_data)) { // garvin: Update comment table, if a comment was set. if (PMA_MYSQL_INT_VERSION < 40100 && isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { foreach ($field_comments AS $fieldindex => $fieldcomment) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex], 'pmadb'); } } @@ -130,7 +130,7 @@ if (isset($do_save_data)) { // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { foreach ($field_mimetype AS $fieldindex => $mimetype) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } diff --git a/tbl_change.php b/tbl_change.php index 245bc66c82..036175fc3e 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -376,7 +376,7 @@ foreach ($loop_array AS $vrowcount => $vrow) { } } // UPDATE case with an empty and not NULL value under PHP4 - else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) { + elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) { $vrow[$rowfield] = date('Y-m-d H:i:s', time()); } // end if... else if... } diff --git a/tbl_create.php b/tbl_create.php index 59991efd23..793e955e99 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -78,13 +78,13 @@ if (isset($submit_num_fields)) { $primary_cnt = (isset($field_primary) ? count($field_primary) : 0); for ($i = 0; $i < $primary_cnt; $i++) { $j = $field_primary[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $primary .= PMA_backquote($field_name[$j]) . ', '; } } // end for unset($primary_cnt); $primary = preg_replace('@, $@', '', $primary); - if (!empty($primary)) { + if (strlen($primary)) { $sql_query .= ', PRIMARY KEY (' . $primary . ')'; $query_cpy .= ',' . "\n" . ' PRIMARY KEY (' . $primary . ')'; } @@ -95,13 +95,13 @@ if (isset($submit_num_fields)) { $index_cnt = (isset($field_index) ? count($field_index) : 0); for ($i = 0;$i < $index_cnt; $i++) { $j = $field_index[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $index .= PMA_backquote($field_name[$j]) . ', '; } } // end for unset($index_cnt); $index = preg_replace('@, $@', '', $index); - if (!empty($index)) { + if (strlen($index)) { $sql_query .= ', INDEX (' . $index . ')'; $query_cpy .= ',' . "\n" . ' INDEX (' . $index . ')'; } @@ -112,13 +112,13 @@ if (isset($submit_num_fields)) { $unique_cnt = (isset($field_unique) ? count($field_unique) : 0); for ($i = 0; $i < $unique_cnt; $i++) { $j = $field_unique[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $unique .= PMA_backquote($field_name[$j]) . ', '; } } // end for unset($unique_cnt); $unique = preg_replace('@, $@', '', $unique); - if (!empty($unique)) { + if (strlen($unique)) { $sql_query .= ', UNIQUE (' . $unique . ')'; $query_cpy .= ',' . "\n" . ' UNIQUE (' . $unique . ')'; } @@ -129,13 +129,13 @@ if (isset($submit_num_fields)) { $fulltext_cnt = (isset($field_fulltext) ? count($field_fulltext) : 0); for ($i = 0; $i < $fulltext_cnt; $i++) { $j = $field_fulltext[$i]; - if (!empty($field_name[$j])) { + if (isset($field_name[$j]) && strlen($field_name[$j])) { $fulltext .= PMA_backquote($field_name[$j]) . ', '; } } // end for $fulltext = preg_replace('@, $@', '', $fulltext); - if (!empty($fulltext)) { + if (strlen($fulltext)) { $sql_query .= ', FULLTEXT (' . $fulltext . ')'; $query_cpy .= ',' . "\n" . ' FULLTEXT (' . $fulltext . ')'; } @@ -178,7 +178,7 @@ if (isset($submit_num_fields)) { // garvin: Update comment table, if a comment was set. if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork'] && PMA_MYSQL_INT_VERSION < 40100) { foreach ($field_comments AS $fieldindex => $fieldcomment) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, '', 'pmadb'); } } @@ -187,7 +187,7 @@ if (isset($submit_num_fields)) { // garvin: Update comment table for mime types [MIME] if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { foreach ($field_mimetype AS $fieldindex => $mimetype) { - if (!empty($field_name[$fieldindex])) { + if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } @@ -218,11 +218,11 @@ if ($abort == FALSE) { PMA_mysqlDie($strTableEmpty, '', '', $err_url); } // No valid number of fields - else if (empty($num_fields) || !is_int($num_fields)) { + elseif (empty($num_fields) || !is_int($num_fields)) { PMA_mysqlDie($strFieldsEmpty, '', '', $err_url); } // Does table exist? - else if (!(PMA_DBI_get_fields($db, $table) === FALSE)) { + elseif (!(PMA_DBI_get_fields($db, $table) === FALSE)) { PMA_mysqlDie(sprintf($strTableAlreadyExists, htmlspecialchars($table)), '', '', $err_url); } // Table name and number of fields are valid -> show the form diff --git a/tbl_indexes.php b/tbl_indexes.php index 55b7b87834..53472423b0 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -21,10 +21,10 @@ $index_types_cnt = count($index_types); */ if (!defined('PMA_IDX_INCLUDED')) { // Not a valid db name -> back to the welcome page - if ( !empty($db) ) { + if ( isset($db) && strlen($db) ) { $is_db = PMA_DBI_select_db($db); } - if ( empty($db) || !$is_db ) { + if ( !isset($db) || !strlen($db) || !$is_db ) { $uri_params = array( 'reload' => '1' ); if ( isset($message) ) { $uri_params['message'] = $message; @@ -34,11 +34,11 @@ if (!defined('PMA_IDX_INCLUDED')) { exit; } // Not a valid table name -> back to the default db_details sub-page - if ( !empty($table) ) { + if ( isset($table) && strlen($table) ) { $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); } - if ( empty($table) + if ( ! isset($table) || ! strlen($table) || !( $is_table && PMA_DBI_num_rows($is_table) ) ) { $uri_params = array( 'reload' => '1', 'db' => $db ); if ( isset($message) ) { diff --git a/tbl_replace.php b/tbl_replace.php index 0e1d6df128..bbe5adffa7 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -70,7 +70,7 @@ if (isset($after_insert) && $after_insert == 'new_insert') { $goto .= '&primary_key[]=' . urlencode(PMA_getUvaCondition($res, count($row), $meta, $row)); } } -} else if ($goto == 'sql.php') { +} elseif ($goto == 'sql.php') { $goto = 'sql.php?' . PMA_generate_common_url($db, $table, '&') . '&pos=' . $pos @@ -79,11 +79,11 @@ if (isset($after_insert) && $after_insert == 'new_insert') { . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode($sql_query); -} else if (!empty($goto)) { +} elseif (!empty($goto)) { // Security checkings $is_gotofile = preg_replace('@^([^?]+).*$@', '\\1', $goto); if (!@file_exists('./' . $is_gotofile)) { - $goto = (empty($table)) ? 'db_details.php' : 'tbl_properties.php'; + $goto = (! isset($table) || ! strlen($table)) ? 'db_details.php' : 'tbl_properties.php'; $is_gotofile = TRUE; } else { $is_gotofile = ($is_gotofile == $goto); @@ -261,7 +261,7 @@ if ($total_affected_rows != 0) { $message .= $last_message; if ($is_gotofile) { - if ($goto == 'db_details.php' && !empty($table)) { + if ($goto == 'db_details.php' && isset($table)) { unset($table); } $js_to_run = 'functions.js'; |