do NEVER unset $table or $db;

no need to test for isset() on $db and $table;
always test with strlen() for valid $table or $db;
This commit is contained in:
Sebastian Mendel
2007-03-30 09:12:05 +00:00
parent 711eb76ce3
commit 008734f8b0
23 changed files with 82 additions and 91 deletions

View File

@@ -31,7 +31,7 @@ PMA_checkParameters(array('db'));
/** /**
* Defines the url to return to in case of error in a sql statement * 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); $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
} else { } else {
$err_url = 'db_sql.php?' . PMA_generate_common_url($db); $err_url = 'db_sql.php?' . PMA_generate_common_url($db);

View File

@@ -22,7 +22,7 @@ require_once './libraries/mysql_charsets.lib.php';
/** /**
* Rename/move or copy database * Rename/move or copy database
*/ */
if (isset($db) && if (strlen($db) &&
((isset($db_rename) && $db_rename == 'true') || ((isset($db_rename) && $db_rename == 'true') ||
(isset($db_copy) && $db_copy == 'true'))) { (isset($db_copy) && $db_copy == 'true'))) {
@@ -340,7 +340,7 @@ if (!$is_information_schema) {
// MySQL supports setting default charsets / collations for databases since // MySQL supports setting default charsets / collations for databases since
// version 4.1.1. // version 4.1.1.
echo '<form method="post" action="./db_operations.php">' . "\n" echo '<form method="post" action="./db_operations.php">' . "\n"
. PMA_generate_common_hidden_inputs($db, isset($table) ? $table : '') . PMA_generate_common_hidden_inputs($db, $table)
. '<fieldset>' . "\n" . '<fieldset>' . "\n"
. ' <legend>'; . ' <legend>';
if ($cfg['PropertiesIconic']) { if ($cfg['PropertiesIconic']) {
@@ -372,7 +372,7 @@ if (!$is_information_schema) {
// not sure about leaving the PDF dialog for 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 . '&amp;table=' . urlencode($table); $takeaway = $url_query . '&amp;table=' . urlencode($table);
} else { } else {
$takeaway = ''; $takeaway = '';

View File

@@ -73,9 +73,9 @@ foreach ($drops as $each_drop) {
} }
unset($drops, $each_drop); unset($drops, $each_drop);
if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) { if (! strlen($GLOBALS['db'])) {
$main_target = $GLOBALS['cfg']['DefaultTabServer']; $main_target = $GLOBALS['cfg']['DefaultTabServer'];
} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { } elseif (! strlen($GLOBALS['table'])) {
$_GET['db'] = $GLOBALS['db']; $_GET['db'] = $GLOBALS['db'];
$main_target = $GLOBALS['cfg']['DefaultTabDatabase']; $main_target = $GLOBALS['cfg']['DefaultTabDatabase'];
} else { } else {

View File

@@ -505,10 +505,10 @@ function PMA_auth_set_user()
// any parameters to pass? // any parameters to pass?
$url_params = array(); $url_params = array();
if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { if (strlen($GLOBALS['db'])) {
$url_params['db'] = $GLOBALS['db']; $url_params['db'] = $GLOBALS['db'];
} }
if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) { if (strlen($GLOBALS['table'])) {
$url_params['table'] = $GLOBALS['table']; $url_params['table'] = $GLOBALS['table'];
} }
// Language change from the login panel needs to be remembered // Language change from the login panel needs to be remembered

View File

@@ -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 if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select
echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
} }
if ($is_modify_link && isset($db)) { if ($is_modify_link && strlen($db)) {
if (isset($table)) { if (strlen($table)) {
$doedit_goto = '<a href="tbl_sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">'; $doedit_goto = '<a href="tbl_sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
} else { } else {
$doedit_goto = '<a href="db_sql.php?' . PMA_generate_common_url($db) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">'; $doedit_goto = '<a href="db_sql.php?' . PMA_generate_common_url($db) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
@@ -920,7 +920,7 @@ function PMA_reloadNavigation()
// Reloads the navigation frame via JavaScript if required // Reloads the navigation frame via JavaScript if required
if (isset($GLOBALS['reload']) && $GLOBALS['reload']) { if (isset($GLOBALS['reload']) && $GLOBALS['reload']) {
echo "\n"; 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'], '', '&');
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
//<![CDATA[ //<![CDATA[
@@ -963,7 +963,7 @@ function PMA_showMessage($message, $sql_query = null)
// Corrects the tooltip text via JS if required // Corrects the tooltip text via JS if required
// @todo this is REALLY the wrong place to do this - very unexpected here // @todo this is REALLY the wrong place to do this - very unexpected here
if ( isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) { if (strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
$result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
if ($result) { if ($result) {
$tbl_status = PMA_DBI_fetch_assoc($result); $tbl_status = PMA_DBI_fetch_assoc($result);
@@ -985,7 +985,7 @@ function PMA_showMessage($message, $sql_query = null)
// Checks if the table needs to be repaired after a TRUNCATE query. // Checks if the table needs to be repaired after a TRUNCATE query.
// @todo this should only be done if isset($GLOBALS['sql_query']), what about $GLOBALS['display_query']??? // @todo this should only be done if isset($GLOBALS['sql_query']), what about $GLOBALS['display_query']???
// @todo this is REALLY the wrong place to do this - very unexpected here // @todo this is REALLY the wrong place to do this - very unexpected here
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) if (strlen($GLOBALS['table']) && strlen($GLOBALS['sql_query'])
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
if (!isset($tbl_status)) { if (!isset($tbl_status)) {
$result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
@@ -1021,7 +1021,7 @@ function PMA_showMessage($message, $sql_query = null)
if ($cfg['ShowSQL'] == true && ! empty($sql_query)) { if ($cfg['ShowSQL'] == true && ! empty($sql_query)) {
// Basic url query part // Basic url query part
$url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); $url_qpart = '?' . PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']);
// Html format the query to be displayed // Html format the query to be displayed
// The nl2br function isn't used because its result isn't a valid // The nl2br function isn't used because its result isn't a valid
@@ -1095,7 +1095,7 @@ function PMA_showMessage($message, $sql_query = null)
// (don't go to default pages, we must go to the page // (don't go to default pages, we must go to the page
// where the query box is available) // where the query box is available)
$edit_target = isset($GLOBALS['db']) ? (isset($GLOBALS['table']) ? 'tbl_sql.php' : 'db_sql.php') : 'server_sql.php'; $edit_target = strlen($GLOBALS['db']) ? (strlen($GLOBALS['table']) ? 'tbl_sql.php' : 'db_sql.php') : 'server_sql.php';
if (isset($cfg['SQLQuery']['Edit']) if (isset($cfg['SQLQuery']['Edit'])
&& ($cfg['SQLQuery']['Edit'] == true) && ($cfg['SQLQuery']['Edit'] == true)

View File

@@ -35,10 +35,10 @@ $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
*/ */
if (!isset($is_db) || !$is_db) { if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page // 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); $is_db = PMA_DBI_select_db($db);
} }
if (!isset($db) || !strlen($db) || !$is_db) { if (! strlen($db) || !$is_db) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit; exit;
} }

View File

@@ -11,7 +11,7 @@
* *
*/ */
if (empty($is_db)) { if (empty($is_db)) {
if (isset($db) && strlen($db)) { if (strlen($db)) {
$is_db = @PMA_DBI_select_db($db); $is_db = @PMA_DBI_select_db($db);
} else { } else {
$is_db = false; $is_db = false;
@@ -40,7 +40,7 @@ if (empty($is_db)) {
if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) { if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) {
// Not a valid table name -> back to the db_sql.php // Not a valid table name -> back to the db_sql.php
if (isset($table) && strlen($table)) { if (strlen($table)) {
$_result = PMA_DBI_try_query( $_result = PMA_DBI_try_query(
'SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', 'SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, true) . '\';',
null, PMA_DBI_QUERY_STORE); null, PMA_DBI_QUERY_STORE);
@@ -52,7 +52,7 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) {
if (! $is_table) { if (! $is_table) {
if (! defined('IS_TRANSFORMATION_WRAPPER')) { if (! defined('IS_TRANSFORMATION_WRAPPER')) {
if (isset($table) && strlen($table)) { if (strlen($table)) {
// SHOW TABLES doesn't show temporary tables, so try select // SHOW TABLES doesn't show temporary tables, so try select
// (as it can happen just in case temporary table, it should be // (as it can happen just in case temporary table, it should be
// fast): // fast):

View File

@@ -102,7 +102,7 @@ echo PMA_pluginGetJavascript($export_list);
//]]> //]]>
</script> </script>
<?php if ( isset($table) && strlen($table) && ! isset( $num_tables ) ) { ?> <?php if ( strlen($table) && ! isset( $num_tables ) ) { ?>
<div class="formelementrow"> <div class="formelementrow">
<?php <?php
echo sprintf( $strDumpXRows, echo sprintf( $strDumpXRows,

View File

@@ -37,11 +37,11 @@ function PMA_select_language($use_fieldset = FALSE) {
echo ' <input type="hidden" name="convcharset" value="' echo ' <input type="hidden" name="convcharset" value="'
. htmlspecialchars($GLOBALS['convcharset']) . '" />' . "\n"; . htmlspecialchars($GLOBALS['convcharset']) . '" />' . "\n";
} }
if (isset($GLOBALS['db'])) { if (strlen($GLOBALS['db'])) {
echo ' <input type="hidden" name="db" value="' echo ' <input type="hidden" name="db" value="'
. htmlspecialchars($GLOBALS['db']) . '" />' . "\n"; . htmlspecialchars($GLOBALS['db']) . '" />' . "\n";
} }
if (isset($GLOBALS['table'])) { if (strlen($GLOBALS['table'])) {
echo ' <input type="hidden" name="table" value="' echo ' <input type="hidden" name="table" value="'
. htmlspecialchars($GLOBALS['table']) . '" />' . "\n"; . htmlspecialchars($GLOBALS['table']) . '" />' . "\n";
} }

View File

@@ -170,7 +170,7 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
if (isset($unlim_num_rows) && $unlim_num_rows != '') { if (isset($unlim_num_rows) && $unlim_num_rows != '') {
$the_total = $unlim_num_rows; $the_total = $unlim_num_rows;
} elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') } 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); $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 // 2.3 Displays the navigation bars
if (!isset($table) || strlen(trim($table)) == 0) { if (! strlen($table)) {
if (isset($analyzed_sql[0]['query_type']) if (isset($analyzed_sql[0]['query_type'])
&& $analyzed_sql[0]['query_type'] == 'SELECT') { && $analyzed_sql[0]['query_type'] == 'SELECT') {
// table does not always contain a real table name, // 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) . '\')'; $tabs = '(\'' . join('\',\'', $target) . '\')';
if ($cfgRelation['displaywork']) { if ($cfgRelation['displaywork']) {
if (! isset($table) || ! strlen($table)) { if (! strlen($table)) {
$exist_rel = false; $exist_rel = false;
} else { } else {
$exist_rel = PMA_getForeigners($db, $table, '', 'both'); $exist_rel = PMA_getForeigners($db, $table, '', 'both');

View File

@@ -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)) { if (isset($plugin_list)) {
$plugin_list['xml'] = array( $plugin_list['xml'] = array(

View File

@@ -133,7 +133,7 @@ if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special'])
. ' title="' . $GLOBALS['strOpenNewWindow'] . '" target="_blank">'; . ' title="' . $GLOBALS['strOpenNewWindow'] . '" target="_blank">';
/* /*
echo '<a href="index.php?target=' . basename(PMA_getenv('SCRIPT_NAME')); echo '<a href="index.php?target=' . basename(PMA_getenv('SCRIPT_NAME'));
$url = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); $url = PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']);
if (!empty($url)) { if (!empty($url)) {
echo '&amp;' . $url; echo '&amp;' . $url;
} }

View File

@@ -42,8 +42,8 @@ if (empty($GLOBALS['is_header_sent'])) {
isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '', isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '', isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
!empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''), !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),
isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['db'],
isset($GLOBALS['table']) ? $GLOBALS['table'] : '', $GLOBALS['table'],
'phpMyAdmin ' . PMA_VERSION, 'phpMyAdmin ' . PMA_VERSION,
), ),
!empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] : !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
@@ -200,7 +200,7 @@ if (empty($GLOBALS['is_header_sent'])) {
$GLOBALS['strServer'], $GLOBALS['strServer'],
's_host.png' ); 's_host.png' );
if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { if (strlen($GLOBALS['db'])) {
echo $separator; echo $separator;
printf( $item, printf( $item,
@@ -210,7 +210,7 @@ if (empty($GLOBALS['is_header_sent'])) {
$GLOBALS['strDatabase'], $GLOBALS['strDatabase'],
's_db.png' ); 's_db.png' );
if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) { if (strlen($GLOBALS['table'])) {
require_once './libraries/tbl_info.inc.php'; require_once './libraries/tbl_info.inc.php';
echo $separator; echo $separator;

View File

@@ -128,11 +128,11 @@ if (!empty($submit_mult)
if ( !empty($submit_mult) && !empty($what)) { if ( !empty($submit_mult) && !empty($what)) {
$js_to_run = 'functions.js'; $js_to_run = 'functions.js';
unset($message); unset($message);
if (isset($table) && strlen($table)) { if (strlen($table)) {
require('./libraries/tbl_common.php'); require('./libraries/tbl_common.php');
$url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php'; $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
require('./libraries/tbl_info.inc.php'); require('./libraries/tbl_info.inc.php');
} elseif (isset($db) && strlen($db)) { } elseif (strlen($db)) {
require('./libraries/db_common.inc.php'); require('./libraries/db_common.inc.php');
require('./libraries/db_info.inc.php'); require('./libraries/db_info.inc.php');
} }

View File

@@ -28,7 +28,7 @@ if (empty($viewing_mode)) {
/** /**
* Set parameters for links * Set parameters for links
*/ */
$url_query = PMA_generate_common_url((isset($db) ? $db : '')); $url_query = PMA_generate_common_url($db);
/** /**
* Defines the urls to return to in case of error in a sql statement * Defines the urls to return to in case of error in a sql statement

View File

@@ -86,11 +86,11 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
$table = ''; $table = '';
$db = ''; $db = '';
if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) { if (! strlen($GLOBALS['db'])) {
// prepare for server related // prepare for server related
$goto = empty($GLOBALS['goto']) ? $goto = empty($GLOBALS['goto']) ?
'server_sql.php' : $GLOBALS['goto']; 'server_sql.php' : $GLOBALS['goto'];
} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { } elseif (! strlen($GLOBALS['table'])) {
// prepare for db related // prepare for db related
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
$goto = empty($GLOBALS['goto']) ? $goto = empty($GLOBALS['goto']) ?
@@ -218,12 +218,12 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
$table = ''; $table = '';
$db = ''; $db = '';
$fields_list = array(); $fields_list = array();
if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) { if (! strlen($GLOBALS['db'])) {
// prepare for server related // prepare for server related
$legend = sprintf($GLOBALS['strRunSQLQueryOnServer'], $legend = sprintf($GLOBALS['strRunSQLQueryOnServer'],
htmlspecialchars( htmlspecialchars(
$GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'])); $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']));
} elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { } elseif (! strlen($GLOBALS['table'])) {
// prepare for db related // prepare for db related
$db = $GLOBALS['db']; $db = $GLOBALS['db'];
// if you want navigation: // if you want navigation:
@@ -414,7 +414,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
*/ */
function PMA_sqlQueryFormBookmark() function PMA_sqlQueryFormBookmark()
{ {
$bookmark_list = PMA_listBookmarks(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', $GLOBALS['cfg']['Bookmark'] ); $bookmark_list = PMA_listBookmarks($GLOBALS['db'], $GLOBALS['cfg']['Bookmark'] );
if (! $bookmark_list || count($bookmark_list) < 1) { if (! $bookmark_list || count($bookmark_list) < 1) {
return; return;
} }

View File

@@ -37,10 +37,10 @@ function PMA_generate_common_hidden_inputs($db = '', $table = '', $indent = 0, $
$skip =& $_skip; $skip =& $_skip;
} else { } else {
$params = array(); $params = array();
if (isset($db) && strlen($db)) { if (strlen($db)) {
$params['db'] = $db; $params['db'] = $db;
} }
if (isset($table) && strlen($table)) { if (strlen($table)) {
$params['table'] = $table; $params['table'] = $table;
} }
} }
@@ -142,10 +142,10 @@ function PMA_generate_common_url ($db = '', $table = '', $delim = '&amp;')
$questionmark = '?'; $questionmark = '?';
} else { } else {
$params = array(); $params = array();
if (isset($db) && strlen($db)) { if (strlen($db)) {
$params['db'] = $db; $params['db'] = $db;
} }
if (isset($table) && strlen($table)) { if (strlen($table)) {
$params['table'] = $table; $params['table'] = $table;
} }
$questionmark = ''; $questionmark = '';

View File

@@ -18,12 +18,8 @@ if (!defined('PMA_DISPLAY_HEADING')) {
require_once './libraries/common.inc.php'; require_once './libraries/common.inc.php';
// Handles some variables that may have been sent by the calling script // Handles some variables that may have been sent by the calling script
if (isset($db)) { $GLOBALS['db'] = '';
unset($db); $GLOBALS['table'] = '';
}
if (isset($table)) {
unset($table);
}
$show_query = '1'; $show_query = '1';
require_once './libraries/header.inc.php'; require_once './libraries/header.inc.php';

View File

@@ -207,7 +207,7 @@ $href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
$element_counter = 0; $element_counter = 0;
if ($GLOBALS['cfg']['LeftFrameLight'] && isset($GLOBALS['db']) && strlen($GLOBALS['db'])) { if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
// show selected databasename as link to DefaultTabDatabase-page // show selected databasename as link to DefaultTabDatabase-page
// with table count in () // with table count in ()
$common_url_query = PMA_generate_common_url($GLOBALS['db']); $common_url_query = PMA_generate_common_url($GLOBALS['db']);
@@ -477,13 +477,11 @@ function PMA_displayTableList($tables, $visible = false,
$element_counter++; $element_counter++;
echo '<li>' . "\n"; echo '<li>' . "\n";
if ($visible && if ($visible
((isset($_REQUEST['tbl_group']) && ((isset($_REQUEST['tbl_group'])
&& (strpos($_REQUEST['tbl_group'], $group) === 0 && (strpos($_REQUEST['tbl_group'], $group) === 0
|| strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
|| || strpos($GLOBALS['table'], $group) === 0)) {
(isset($GLOBALS['table'])
&& strpos($GLOBALS['table'], $group) === 0))) {
printf($href_left, $element_counter, printf($href_left, $element_counter,
$GLOBALS['common_url_query'] . '&amp;tbl_group=' . $tab_group_full); $GLOBALS['common_url_query'] . '&amp;tbl_group=' . $tab_group_full);
printf($img_minus, $element_counter); printf($img_minus, $element_counter);
@@ -521,9 +519,7 @@ function PMA_displayTableList($tables, $visible = false,
((isset($_REQUEST['tbl_group']) ((isset($_REQUEST['tbl_group'])
&& (strpos($_REQUEST['tbl_group'], $group) === 0 && (strpos($_REQUEST['tbl_group'], $group) === 0
|| strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($_REQUEST['tbl_group'], $sep . $group) !== false))
|| || strpos($GLOBALS['table'], $group) === 0)) {
(isset($GLOBALS['table'])
&& strpos($GLOBALS['table'], $group) === 0))) {
PMA_displayTableList($table, true, PMA_displayTableList($table, true,
$tab_group_full . $group, $table_db); $tab_group_full . $group, $table_db);
} else { } else {

39
sql.php
View File

@@ -36,13 +36,13 @@ if (!empty($goto)) {
} // end if (security checkings) } // end if (security checkings)
if (empty($goto)) { if (empty($goto)) {
$goto = (! isset($table) || ! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable']; $goto = (! strlen($table)) ? $cfg['DefaultTabDatabase'] : $cfg['DefaultTabTable'];
$is_gotofile = true; $is_gotofile = true;
} // end if } // end if
if (!isset($err_url)) { if (!isset($err_url)) {
$err_url = (!empty($back) ? $back : $goto) $err_url = (!empty($back) ? $back : $goto)
. '?' . PMA_generate_common_url(isset($db) ? $db : '') . '?' . PMA_generate_common_url($db)
. ((strpos(' ' . $goto, 'db_') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : ''); . ((strpos(' ' . $goto, 'db_') != 1 && strlen($table)) ? '&amp;table=' . urlencode($table) : '');
} // end if } // end if
// Coming from a bookmark dialog // Coming from a bookmark dialog
@@ -57,7 +57,7 @@ if (isset($fields['dbase'])) {
// Default to browse if no query set an we have table // Default to browse if no query set an we have table
// (needed for browsing from DefaultTabTable) // (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'; require_once './libraries/bookmark.lib.php';
$book_sql_query = PMA_queryBookmarks($db, $book_sql_query = PMA_queryBookmarks($db,
$GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'',
@@ -158,8 +158,8 @@ if (isset($btnDrop) && $btnDrop == $strNo) {
$goto = $back; $goto = $back;
} }
if ($is_gotofile) { if ($is_gotofile) {
if (strpos(' ' . $goto, 'db_') == 1 && isset($table) && strlen($table)) { if (strpos(' ' . $goto, 'db_') == 1 && strlen($table)) {
unset($table); $table = '';
} }
$active_page = $goto; $active_page = $goto;
require './' . PMA_securePath($goto); require './' . PMA_securePath($goto);
@@ -197,7 +197,7 @@ if ($do_confirm) {
echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>'; echo '<h1 class="warning">' . $strDropDatabaseStrongWarning . '</h1>';
} }
echo '<form action="sql.php" method="post">' . "\n" echo '<form action="sql.php" method="post">' . "\n"
.PMA_generate_common_hidden_inputs($db, (isset($table)?$table:'')); .PMA_generate_common_hidden_inputs($db, $table);
?> ?>
<input type="hidden" name="sql_query" value="<?php echo urlencode($sql_query); ?>" /> <input type="hidden" name="sql_query" value="<?php echo urlencode($sql_query); ?>" />
<input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" /> <input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
@@ -324,7 +324,7 @@ if (isset($pos)
$full_sql_query = $sql_query; $full_sql_query = $sql_query;
} // end if...else } // end if...else
if (isset($db)) { if (strlen($db)) {
PMA_DBI_select_db($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`;" // This could happen if the user sends a query like "USE `database`;"
$res = PMA_DBI_query('SELECT DATABASE() AS \'db\';'); $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
$row = PMA_DBI_fetch_row($res); $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]; $db = $row[0];
$reload = 1; $reload = 1;
} }
@@ -561,9 +561,9 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
if (isset($purge) && $purge == '1') { if (isset($purge) && $purge == '1') {
require_once './libraries/relation_cleanup.lib.php'; 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); PMA_relationsCleanupTable($db, $table);
} elseif (isset($db) && strlen($db)) { } elseif (strlen($db)) {
PMA_relationsCleanupDatabase($db); PMA_relationsCleanupDatabase($db);
} else { } else {
// garvin: VOID. No DB/Table gets deleted. // 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. // garvin: If a column gets dropped, do relation magic.
if (isset($cpurge) && $cpurge == '1' && isset($purgekey) if (isset($cpurge) && $cpurge == '1' && isset($purgekey)
&& isset($db) && isset($table)
&& strlen($db) && strlen($table) && !empty($purgekey)) { && strlen($db) && strlen($table) && !empty($purgekey)) {
require_once './libraries/relation_cleanup.lib.php'; require_once './libraries/relation_cleanup.lib.php';
PMA_relationsCleanupColumn($db, $table, $purgekey); PMA_relationsCleanupColumn($db, $table, $purgekey);
@@ -628,14 +627,14 @@ if ($num_rows < 1 || $is_affected) {
$is_db = $is_table = false; $is_db = $is_table = false;
include 'libraries/db_table_exists.lib.php'; include 'libraries/db_table_exists.lib.php';
if (strpos($goto, 'tbl_') === 0 && ! $is_table) { if (strpos($goto, 'tbl_') === 0 && ! $is_table) {
if (isset($table)) { if (strlen($table)) {
unset($table); $table = '';
} }
$goto = 'db_sql.php'; $goto = 'db_sql.php';
} }
if (strpos($goto, 'db_') === 0 && ! $is_db) { if (strpos($goto, 'db_') === 0 && ! $is_db) {
if (isset($db)) { if (strlen($db)) {
unset($db); $db = '';
} }
$goto = 'main.php'; $goto = 'main.php';
} }
@@ -666,12 +665,12 @@ else {
} else { } else {
$js_to_run = 'functions.js'; $js_to_run = 'functions.js';
unset($message); unset($message);
if (isset($table) && strlen($table)) { if (strlen($table)) {
require './libraries/tbl_common.php'; require './libraries/tbl_common.php';
$url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php'; $url_query .= '&amp;goto=tbl_sql.php&amp;back=tbl_sql.php';
require './libraries/tbl_info.inc.php'; require './libraries/tbl_info.inc.php';
require './libraries/tbl_links.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_common.inc.php';
require './libraries/db_info.inc.php'; require './libraries/db_info.inc.php';
} else { } else {
@@ -680,7 +679,7 @@ else {
} }
} }
if (isset($db) && strlen($db)) { if (strlen($db)) {
require_once './libraries/relation.lib.php'; require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
} }
@@ -711,7 +710,7 @@ else {
} }
// hide edit and delete links for information_schema // 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'; $disp_mode = 'nnnn110111';
} }

View File

@@ -19,10 +19,10 @@ require_once './libraries/tbl_indexes.lib.php';
*/ */
if (!defined('PMA_IDX_INCLUDED')) { if (!defined('PMA_IDX_INCLUDED')) {
// Not a valid db name -> back to the welcome page // 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); $is_db = PMA_DBI_select_db($db);
} }
if ( !isset($db) || !strlen($db) || !$is_db ) { if (!strlen($db) || !$is_db) {
$uri_params = array( 'reload' => '1' ); $uri_params = array( 'reload' => '1' );
if ( isset($message) ) { if ( isset($message) ) {
$uri_params['message'] = $message; $uri_params['message'] = $message;
@@ -32,11 +32,11 @@ if (!defined('PMA_IDX_INCLUDED')) {
exit; exit;
} }
// Not a valid table name -> back to the default db sub-page // 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 \'' $is_table = PMA_DBI_query('SHOW TABLES LIKE \''
. PMA_sqlAddslashes($table, TRUE) . '\'', null, PMA_DBI_QUERY_STORE); . 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) ) ) { || !( $is_table && PMA_DBI_num_rows($is_table) ) ) {
$uri_params = array( 'reload' => '1', 'db' => $db ); $uri_params = array( 'reload' => '1', 'db' => $db );
if ( isset($message) ) { if ( isset($message) ) {

View File

@@ -38,7 +38,7 @@ $cfgRelation = PMA_getRelationsParam();
/** /**
* Defines the url to return to in case of error in a sql statement * 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); $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
} else { } else {
$err_url = 'db_sql.php?' . PMA_generate_common_url($db); $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)) { if (isset($selected_tbl) && is_array($selected_tbl)) {
$the_tables = $selected_tbl; $the_tables = $selected_tbl;
} elseif (isset($table)) { } elseif (strlen($table)) {
$the_tables[] = $table; $the_tables[] = $table;
} }
$multi_tables = (count($the_tables) > 1); $multi_tables = (count($the_tables) > 1);

View File

@@ -115,13 +115,13 @@ if (isset($_REQUEST['after_insert'])
} else { } else {
$goto_include = $GLOBALS['goto']; $goto_include = $GLOBALS['goto'];
} }
if ($GLOBALS['goto'] == 'db_sql.php' && isset($GLOBALS['table'])) { if ($GLOBALS['goto'] == 'db_sql.php' && strlen($GLOBALS['table'])) {
unset($GLOBALS['table']); $GLOBALS['table'] = '';
} }
} }
if (! $goto_include) { if (! $goto_include) {
if (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) { if (! strlen($GLOBALS['table'])) {
$goto_include = 'db_sql.php'; $goto_include = 'db_sql.php';
} else { } else {
$goto_include = 'tbl_sql.php'; $goto_include = 'tbl_sql.php';