From eece3b3462ba35573d77e47d13d12faac5fc9787 Mon Sep 17 00:00:00 2001 From: Steve Alberty Date: Tue, 17 Jul 2001 09:59:25 +0000 Subject: [PATCH] block table rename if newname empty --- ChangeLog | 3 +++ tbl_copy.php3 | 31 ++++++++++++++++--------------- tbl_rename.php3 | 27 ++++++++++++++++++--------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7fc3e9b75..282745c00 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2001-07-17 Steve Alberty + * tbl_addfield.php3: add trouble detection if insert field failed + * tbl_rename.php3,tbl_copy.php3: block table rename if newname empty 2001-07-16 Marc Delisle * tbl_change.php3, bug 441689, "Insert as new row" was not copying blobs. diff --git a/tbl_copy.php3 b/tbl_copy.php3 index 5fce9b75c..a03f47e0e 100755 --- a/tbl_copy.php3 +++ b/tbl_copy.php3 @@ -16,29 +16,30 @@ function my_handler($sql_insert) $sql_query = $sql_insert; } -$sql_structure = get_table_def($db, $table, "\n"); -// speedup copy table - staybyte - 22. Juni 2001 -if(MYSQL_MAJOR_VERSION >= "3.23"){ - $sql_structure = ereg_replace("CREATE TABLE `$table`", "CREATE TABLE `$new_name`", $sql_structure); - $result = mysql_query($sql_structure) or mysql_die(); - if($what == "data"){ - $query="INSERT INTO $new_name SELECT * FROM $table"; - $result = mysql_query($query) or mysql_die(); +if (isset($new_name)) $new_name=trim($new_name); // Cleanup to suppress '' tables +if (isset($new_name) && $new_name!=""){ + $sql_structure = get_table_def($db, $table, "\n"); + // speedup copy table - staybyte - 22. Juni 2001 + if(MYSQL_MAJOR_VERSION >= "3.23"){ + $sql_structure = ereg_replace("CREATE TABLE `$table`", "CREATE TABLE `$new_name`", $sql_structure); + $result = mysql_query($sql_structure) or mysql_die(); + if($what == "data"){ + $query="INSERT INTO $new_name SELECT * FROM $table"; + $result = mysql_query($query) or mysql_die(); + } + } + else{ + $sql_structure = ereg_replace("CREATE TABLE $table", "CREATE TABLE $new_name", $sql_structure); + $result = mysql_query($sql_structure) or mysql_die(); } } -else{ - $sql_structure = ereg_replace("CREATE TABLE $table", "CREATE TABLE $new_name", $sql_structure); - $result = mysql_query($sql_structure) or mysql_die(); -} +else mysql_die($strTableEmpty); if (isset($sql_query)) $sql_query .= "\n$sql_structure"; else $sql_query = "$sql_structure"; -//$sql_query .= "\n$sql_structure"; - - if(MYSQL_MAJOR_VERSION < "3.23" && $what == "data") get_table_content($db, $table, "my_handler"); eval("\$message = \"$strCopyTableOK\";"); diff --git a/tbl_rename.php3 b/tbl_rename.php3 index d4db8ef4b..e363a196f 100755 --- a/tbl_rename.php3 +++ b/tbl_rename.php3 @@ -3,16 +3,25 @@ require("./grab_globals.inc.php3"); - -$old_name = $table; -$table = $new_name; -require("./header.inc.php3"); +if (isset($new_name)) $new_name=trim($new_name); // Cleanup to suppress '' tables +if (isset($new_name) && $new_name!=""){ + + $old_name = $table; + $table = $new_name; + + include("./header.inc.php3"); + + mysql_select_db($db); + $result = mysql_query("ALTER TABLE $old_name RENAME $new_name") or mysql_die(); + $table = $old_name; + eval("\$message = \"$strRenameTableOK\";"); + $table = $new_name; +} +else{ + include("./header.inc.php3"); + mysql_die($strTableEmpty); +} -mysql_select_db($db); -$result = mysql_query("ALTER TABLE $old_name RENAME $new_name") or mysql_die(); -$table = $old_name; -eval("\$message = \"$strRenameTableOK\";"); -$table = $new_name; require("./tbl_properties.php3"); ?>