diff --git a/db_datadict.php b/db_datadict.php index 10fff3805..69cd5d0cc 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -31,7 +31,7 @@ PMA_checkParameters(array('db')); /** * Defines the url to return to in case of error in a sql statement */ -if (isset($table)) { +if (strlen($table)) { $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table); } else { $err_url = 'db_sql.php?' . PMA_generate_common_url($db); diff --git a/db_operations.php b/db_operations.php index 4d697bff4..a8fc2d99d 100644 --- a/db_operations.php +++ b/db_operations.php @@ -22,7 +22,7 @@ require_once './libraries/mysql_charsets.lib.php'; /** * Rename/move or copy database */ -if (isset($db) && +if (strlen($db) && ((isset($db_rename) && $db_rename == 'true') || (isset($db_copy) && $db_copy == 'true'))) { @@ -340,7 +340,7 @@ if (!$is_information_schema) { // MySQL supports setting default charsets / collations for databases since // version 4.1.1. echo '
' . "\n" - . PMA_generate_common_hidden_inputs($db, isset($table) ? $table : '') + . PMA_generate_common_hidden_inputs($db, $table) . '
' . "\n" . ' '; if ($cfg['PropertiesIconic']) { @@ -372,7 +372,7 @@ if (!$is_information_schema) { // not sure about leaving the PDF dialog for information_schema -if ($num_tables > 0 && isset($table)) { +if ($num_tables > 0 && strlen($table)) { $takeaway = $url_query . '&table=' . urlencode($table); } else { $takeaway = ''; diff --git a/index.php b/index.php index 0d837b671..0580ede6e 100644 --- a/index.php +++ b/index.php @@ -73,9 +73,9 @@ foreach ($drops as $each_drop) { } unset($drops, $each_drop); -if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) { +if (! strlen($GLOBALS['db'])) { $main_target = $GLOBALS['cfg']['DefaultTabServer']; -} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { +} elseif (! strlen($GLOBALS['table'])) { $_GET['db'] = $GLOBALS['db']; $main_target = $GLOBALS['cfg']['DefaultTabDatabase']; } else { diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index 512de4e44..d6b251a19 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -505,10 +505,10 @@ function PMA_auth_set_user() // any parameters to pass? $url_params = array(); - if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { + if (strlen($GLOBALS['db'])) { $url_params['db'] = $GLOBALS['db']; } - if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) { + if (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 e7f8441c8..6a2fcfd24 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -490,8 +490,8 @@ function PMA_mysqlDie($error_message = '', $the_query = '', if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); } - if ($is_modify_link && isset($db)) { - if (isset($table)) { + if ($is_modify_link && strlen($db)) { + if (strlen($table)) { $doedit_goto = ''; } else { $doedit_goto = ''; @@ -920,7 +920,7 @@ function PMA_reloadNavigation() // Reloads the navigation frame via JavaScript if required if (isset($GLOBALS['reload']) && $GLOBALS['reload']) { echo "\n"; - $reload_url = './navigation.php?' . PMA_generate_common_url((isset($GLOBALS['db']) ? $GLOBALS['db'] : ''), '', '&'); + $reload_url = './navigation.php?' . PMA_generate_common_url($GLOBALS['db'], '', '&'); ?> - +
' . "\n"; } - if (isset($GLOBALS['db'])) { + if (strlen($GLOBALS['db'])) { echo ' ' . "\n"; } - if (isset($GLOBALS['table'])) { + if (strlen($GLOBALS['table'])) { echo ' ' . "\n"; } diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index c5203aff2..0347b09fe 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -170,7 +170,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) if (isset($unlim_num_rows) && $unlim_num_rows != '') { $the_total = $unlim_num_rows; } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') - && (isset($db) && strlen($db) && !empty($table))) { + && (strlen($db) && !empty($table))) { $the_total = PMA_Table::countRecords($db, $table, true); } @@ -1800,7 +1800,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) } // 2.3 Displays the navigation bars - if (!isset($table) || strlen(trim($table)) == 0) { + if (! strlen($table)) { if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') { // table does not always contain a real table name, @@ -1838,7 +1838,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $tabs = '(\'' . join('\',\'', $target) . '\')'; if ($cfgRelation['displaywork']) { - if (! isset($table) || ! strlen($table)) { + if (! strlen($table)) { $exist_rel = false; } else { $exist_rel = PMA_getForeigners($db, $table, '', 'both'); diff --git a/libraries/export/xml.php b/libraries/export/xml.php index 289b22b69..009c17d82 100644 --- a/libraries/export/xml.php +++ b/libraries/export/xml.php @@ -9,7 +9,7 @@ /** * */ -if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { /* Can't do server export */ +if (strlen($GLOBALS['db'])) { /* Can't do server export */ if (isset($plugin_list)) { $plugin_list['xml'] = array( diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php index 93e0d2a64..170374dea 100644 --- a/libraries/footer.inc.php +++ b/libraries/footer.inc.php @@ -133,7 +133,7 @@ if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special']) . ' title="' . $GLOBALS['strOpenNewWindow'] . '" target="_blank">'; /* echo '' . "\n"; - if ($visible && - ((isset($_REQUEST['tbl_group']) - && (strpos($_REQUEST['tbl_group'], $group) === 0 + if ($visible + && ((isset($_REQUEST['tbl_group']) + && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) - || - (isset($GLOBALS['table']) - && strpos($GLOBALS['table'], $group) === 0))) { + || strpos($GLOBALS['table'], $group) === 0)) { printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full); printf($img_minus, $element_counter); @@ -521,9 +519,7 @@ function PMA_displayTableList($tables, $visible = false, ((isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) - || - (isset($GLOBALS['table']) - && strpos($GLOBALS['table'], $group) === 0))) { + || strpos($GLOBALS['table'], $group) === 0)) { PMA_displayTableList($table, true, $tab_group_full . $group, $table_db); } else { diff --git a/sql.php b/sql.php index c7edd0de7..5eff555b3 100644 --- a/sql.php +++ b/sql.php @@ -36,13 +36,13 @@ if (!empty($goto)) { } // end if (security checkings) if (empty($goto)) { - $goto = (! isset($table) || ! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable']; + $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable']; $is_gotofile = true; } // end if if (!isset($err_url)) { $err_url = (!empty($back) ? $back : $goto) - . '?' . PMA_generate_common_url(isset($db) ? $db : '') - . ((strpos(' ' . $goto, 'db_') != 1 && isset($table)) ? '&table=' . urlencode($table) : ''); + . '?' . PMA_generate_common_url($db) + . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&table=' . urlencode($table) : ''); } // end if // Coming from a bookmark dialog @@ -57,7 +57,7 @@ if (isset($fields['dbase'])) { // Default to browse if no query set an we have table // (needed for browsing from DefaultTabTable) -if (! isset($sql_query) && isset($table) && isset($db)) { +if (! isset($sql_query) && strlen($table) && strlen($db)) { require_once './libraries/bookmark.lib.php'; $book_sql_query = PMA_queryBookmarks($db, $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', @@ -158,8 +158,8 @@ if (isset($btnDrop) && $btnDrop == $strNo) { $goto = $back; } if ($is_gotofile) { - if (strpos(' ' . $goto, 'db_') == 1 && isset($table) && strlen($table)) { - unset($table); + if (strpos(' ' . $goto, 'db_') == 1 && strlen($table)) { + $table = ''; } $active_page = $goto; require './' . PMA_securePath($goto); @@ -197,7 +197,7 @@ if ($do_confirm) { echo '

' . $strDropDatabaseStrongWarning . '

'; } echo '' . "\n" - .PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); + .PMA_generate_common_hidden_inputs($db, $table); ?> @@ -324,7 +324,7 @@ if (isset($pos) $full_sql_query = $sql_query; } // end if...else -if (isset($db)) { +if (strlen($db)) { PMA_DBI_select_db($db); } @@ -388,7 +388,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { // This could happen if the user sends a query like "USE `database`;" $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';'); $row = PMA_DBI_fetch_row($res); - if (isset($db) && is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) { + if (strlen($db) && is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) { $db = $row[0]; $reload = 1; } @@ -561,9 +561,9 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { if (isset($purge) && $purge == '1') { require_once './libraries/relation_cleanup.lib.php'; - if (isset($table) && isset($db) && strlen($table) && strlen($db)) { + if (strlen($table) && strlen($db)) { PMA_relationsCleanupTable($db, $table); - } elseif (isset($db) && strlen($db)) { + } elseif (strlen($db)) { PMA_relationsCleanupDatabase($db); } else { // garvin: VOID. No DB/Table gets deleted. @@ -572,7 +572,6 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { // garvin: If a column gets dropped, do relation magic. if (isset($cpurge) && $cpurge == '1' && isset($purgekey) - && isset($db) && isset($table) && strlen($db) && strlen($table) && !empty($purgekey)) { require_once './libraries/relation_cleanup.lib.php'; PMA_relationsCleanupColumn($db, $table, $purgekey); @@ -628,14 +627,14 @@ if ($num_rows < 1 || $is_affected) { $is_db = $is_table = false; include 'libraries/db_table_exists.lib.php'; if (strpos($goto, 'tbl_') === 0 && ! $is_table) { - if (isset($table)) { - unset($table); + if (strlen($table)) { + $table = ''; } $goto = 'db_sql.php'; } if (strpos($goto, 'db_') === 0 && ! $is_db) { - if (isset($db)) { - unset($db); + if (strlen($db)) { + $db = ''; } $goto = 'main.php'; } @@ -666,12 +665,12 @@ else { } else { $js_to_run = 'functions.js'; unset($message); - if (isset($table) && strlen($table)) { + if (strlen($table)) { require './libraries/tbl_common.php'; $url_query .= '&goto=tbl_sql.php&back=tbl_sql.php'; require './libraries/tbl_info.inc.php'; require './libraries/tbl_links.inc.php'; - } elseif (isset($db) && strlen($db)) { + } elseif (strlen($db)) { require './libraries/db_common.inc.php'; require './libraries/db_info.inc.php'; } else { @@ -680,7 +679,7 @@ else { } } - if (isset($db) && strlen($db)) { + if (strlen($db)) { require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); } @@ -711,7 +710,7 @@ else { } // hide edit and delete links for information_schema - if (PMA_MYSQL_INT_VERSION >= 50002 && isset($db) && $db == 'information_schema') { + if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') { $disp_mode = 'nnnn110111'; } diff --git a/tbl_indexes.php b/tbl_indexes.php index 22fb49c98..f846c2484 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -19,10 +19,10 @@ require_once './libraries/tbl_indexes.lib.php'; */ if (!defined('PMA_IDX_INCLUDED')) { // Not a valid db name -> back to the welcome page - if ( isset($db) && strlen($db) ) { + if (strlen($db)) { $is_db = PMA_DBI_select_db($db); } - if ( !isset($db) || !strlen($db) || !$is_db ) { + if (!strlen($db) || !$is_db) { $uri_params = array( 'reload' => '1' ); if ( isset($message) ) { $uri_params['message'] = $message; @@ -32,11 +32,11 @@ if (!defined('PMA_IDX_INCLUDED')) { exit; } // Not a valid table name -> back to the default db sub-page - if ( isset($table) && strlen($table) ) { + if (strlen($table) ) { $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', null, PMA_DBI_QUERY_STORE); } - if ( ! isset($table) || ! strlen($table) + if (! strlen($table) || !( $is_table && PMA_DBI_num_rows($is_table) ) ) { $uri_params = array( 'reload' => '1', 'db' => $db ); if ( isset($message) ) { diff --git a/tbl_printview.php b/tbl_printview.php index b71a9be5c..e3e9178d2 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -38,7 +38,7 @@ $cfgRelation = PMA_getRelationsParam(); /** * Defines the url to return to in case of error in a sql statement */ -if (isset($table)) { +if (strlen($table)) { $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table); } else { $err_url = 'db_sql.php?' . PMA_generate_common_url($db); @@ -57,7 +57,7 @@ PMA_DBI_select_db($db); */ if (isset($selected_tbl) && is_array($selected_tbl)) { $the_tables = $selected_tbl; -} elseif (isset($table)) { +} elseif (strlen($table)) { $the_tables[] = $table; } $multi_tables = (count($the_tables) > 1); diff --git a/tbl_replace.php b/tbl_replace.php index ee9a98b99..3aa262518 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -115,13 +115,13 @@ if (isset($_REQUEST['after_insert']) } else { $goto_include = $GLOBALS['goto']; } - if ($GLOBALS['goto'] == 'db_sql.php' && isset($GLOBALS['table'])) { - unset($GLOBALS['table']); + if ($GLOBALS['goto'] == 'db_sql.php' && strlen($GLOBALS['table'])) { + $GLOBALS['table'] = ''; } } if (! $goto_include) { - if (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { + if (! strlen($GLOBALS['table'])) { $goto_include = 'db_sql.php'; } else { $goto_include = 'tbl_sql.php';