ix some errors about whether to display table name or not at the top of the page

This commit is contained in:
Loïc Chapeaux
2001-08-28 16:09:35 +00:00
parent d99ac01040
commit 172baede1a
4 changed files with 22 additions and 9 deletions

View File

@@ -104,7 +104,7 @@ if ($sql_query != '') {
if (get_magic_quotes_gpc() == 1) { if (get_magic_quotes_gpc() == 1) {
$sql_query = addslashes($sql_query); $sql_query = addslashes($sql_query);
} }
if (eregi('^(DROP|CREATE) +(TABLE|DATABASE) +(.+)', $sql_query)) { if (eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $sql_query)) {
$reload = 'true'; $reload = 'true';
} }
include('./sql.php3'); include('./sql.php3');
@@ -122,7 +122,7 @@ if ($sql_query != '') {
break; break;
} }
} }
if (!isset($reload) && eregi('^(DROP|CREATE) +(TABLE|DATABASE) +(.+)', $a_sql_query)) { if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
$reload = 'true'; $reload = 'true';
} }
} // end for } // end for

View File

@@ -60,8 +60,7 @@ A:hover.nav {font-family: <?php echo $right_font_family; ?>; color: #FF0000}
<?php <?php
if (isset($db)) { if (isset($db)) {
echo '<h1> ' . $strDatabase . ' ' . htmlspecialchars($db); echo '<h1> ' . $strDatabase . ' ' . htmlspecialchars($db);
if (!empty($table) if (!empty($table)) {
&& (!isset($btnDrop) || $btnDrop == $strNo)) {
echo ' - ' . $strTable . ' ' . htmlspecialchars($table); echo ' - ' . $strTable . ' ' . htmlspecialchars($table);
} }
echo '</h1>' . "\n"; echo '</h1>' . "\n";

View File

@@ -79,7 +79,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) {
*/ */
$do_confirm = ($cfgConfirm $do_confirm = ($cfgConfirm
&& !isset($btnDrop) && !isset($btnDrop)
&& eregi('DROP +(TABLE|DATABASE)|ALTER TABLE +[[:alnum:]_`]* +DROP|DELETE FROM', $sql_query)); && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)|ALTER TABLE +[[:alnum:]_`]* +DROP|DELETE FROM', $sql_query));
if ($do_confirm) { if ($do_confirm) {
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$stripped_sql_query = stripslashes($sql_query); $stripped_sql_query = stripslashes($sql_query);
@@ -208,6 +208,16 @@ else {
// No rows returned -> move back to the calling page // No rows returned -> move back to the calling page
if ($num_rows < 1 || $is_affected) { if ($num_rows < 1 || $is_affected) {
if (isset($strYes)) {
if (isset($table)
&& (eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?TABLE[[:space:]]+`?' . $table . '`?[[:space:]]*$', $sql_query))) {
unset($table);
}
if (isset($db)
&& (eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE[[:space:]]+`?' . $db . '`?[[:space:]]*$', $sql_query))) {
unset($db);
}
}
if (file_exists('./' . $goto)) { if (file_exists('./' . $goto)) {
if ($is_delete) { if ($is_delete) {
$message = $strDeletedRows . '&nbsp;' . $num_rows; $message = $strDeletedRows . '&nbsp;' . $num_rows;

View File

@@ -38,15 +38,19 @@ unset($sql_query);
/** /**
* Selects the db that will be used during this script execution * Selects the db that will be used during this script execution
*/ */
$is_db = @mysql_select_db($db);
// Not a valid db name -> back to the welcome page // Not a valid db name -> back to the welcome page
if (!$is_db) { 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'); header('Location: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . '&reload=true');
exit(); exit();
} }
$is_table = @mysql_query('SHOW TABLES LIKE \'' . sql_addslashes($table, TRUE) . '\'');
// Not a valid table name -> back to the db_details.php3 // Not a valid table name -> back to the db_details.php3
if (!@mysql_numrows($is_table)) { 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'); header('Location: ' . $cfgPmaAbsoluteUri . 'db_details.php3?lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&reload=true');
exit(); exit();
} }