diff --git a/tbl_properties.php3 b/tbl_properties.php3 index 10123b657..d3fc40d6e 100755 --- a/tbl_properties.php3 +++ b/tbl_properties.php3 @@ -3,10 +3,30 @@ /** - * Gets some core libraries and diplays headers + * Gets some core libraries, ensures the database and the table exist (else + * move to the "parent" script) and diplays headers */ require('./grab_globals.inc.php3'); require('./lib.inc.php3'); +// Not a valid db name -> back to the welcome page +if (!empty($db)) { + $is_db = @mysql_select_db($db); +} +if (empty($db) || !$is_db) { + header('Location: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); + exit(); +} +// Not a valid table name -> back to the db_details.php3 +if (!empty($table)) { + $is_table = @mysql_query('SHOW TABLES LIKE \'' . sql_addslashes($table, TRUE) . '\''); +} +if (empty($table) || !@mysql_numrows($is_table)) { + header('Location: ' . $cfgPmaAbsoluteUri . 'db_details.php3?lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); + exit(); +} else if (isset($is_table)) { + mysql_free_result($is_table); +} +// Displays headers if (!isset($message)) { $js_to_run = 'functions.js'; include('./header.inc.php3'); @@ -46,29 +66,6 @@ if (isset($show_query) && $show_query == 'y') { unset($sql_query); -/** - * Selects the db that will be used during this script execution - */ -// Not a valid db name -> back to the welcome page -if (!empty($db)) { - $is_db = @mysql_select_db($db); -} -if (empty($db) || !$is_db) { - header('Location: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . '&reload=true'); - exit(); -} -// Not a valid table name -> back to the db_details.php3 -if (!empty($table)) { - $is_table = @mysql_query('SHOW TABLES LIKE \'' . sql_addslashes($table, TRUE) . '\''); -} -if (empty($table) || !@mysql_numrows($is_table)) { - header('Location: ' . $cfgPmaAbsoluteUri . 'db_details.php3?lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&reload=true'); - exit(); -} else if (isset($is_table)) { - mysql_free_result($is_table); -} - - /** * Set parameters for links */ @@ -138,8 +135,8 @@ if ($num_rows > 0) { ] [ - ] - [ ] + [ ]
@@ -153,8 +150,8 @@ if ($num_rows > 0) { [ ] [ ] - [ ] - [ ] * + [ ] @@ -179,7 +176,7 @@ $prev_key = ''; $prev_seq = 0; $i = 0; $pk_array = array(); // will be use to emphasis prim. keys in the table view -while($row = mysql_fetch_array($result)) { +while ($row = mysql_fetch_array($result)) { $ret_keys[] = $row; // Unset the 'Seq_in_index' value if it's not a composite index - part 1 if ($i > 0 && $row['Key_name'] != $prev_key && $prev_seq == 1) { @@ -193,7 +190,7 @@ while($row = mysql_fetch_array($result)) { $pk_array[$row['Column_name']] = 1; } $i++; -} +} // end while // Unset the 'Seq_in_index' value if it's not a composite index - part 2 if ($i > 0 && $row['Key_name'] != $prev_key && $prev_seq == 1) { unset($ret_keys[$i-1]['Seq_in_index']); @@ -230,7 +227,7 @@ $fields_cnt = mysql_num_rows($result);