]> git.joonet.de Git - adminer.git/commitdiff
Revert drop removal (r887, r1195)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 1 Mar 2010 22:59:08 +0000 (22:59 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 1 Mar 2010 22:59:08 +0000 (22:59 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1336 7c3ca157-0c34-0410-bff1-cbf682f78f5c

12 files changed:
adminer/create.inc.php
adminer/database.inc.php
adminer/lang/cs.inc.php
adminer/lang/de.inc.php
adminer/lang/es.inc.php
adminer/lang/et.inc.php
adminer/lang/fr.inc.php
adminer/lang/it.inc.php
adminer/lang/nl.inc.php
adminer/lang/ru.inc.php
adminer/lang/sk.inc.php
adminer/lang/zh.inc.php

index 1f72f2f5c8443b70cad9e99ec972ccc6b01aa0b6..51ce06c7dc534e48814ccb26a1c2278a5fd44de8 100644 (file)
@@ -16,83 +16,87 @@ if ($TABLE != "") {
 }
 
 if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
-       $auto_increment_index = " PRIMARY KEY";
-       // don't overwrite primary key by auto_increment
-       if ($TABLE != "" && $_POST["auto_increment_col"]) {
-               foreach (indexes($TABLE) as $index) {
-                       if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
-                               $auto_increment_index = "";
-                               break;
-                       }
-                       if ($index["type"] == "PRIMARY") {
-                               $auto_increment_index = " UNIQUE";
-                       }
-               }
-       }
-       $fields = "";
-       ksort($_POST["fields"]);
-       $orig_field = reset($orig_fields);
-       $after = "FIRST";
-       foreach ($_POST["fields"] as $key => $field) {
-               $type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
-               if ($field["field"] != "") {
-                       if ($type_field) {
-                               $default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
-                               if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
-                                       $field["on_update"] = "CURRENT_TIMESTAMP";
-                                       $field["default"] = $default;
-                               }
-                               if (!$field["has_default"]) {
-                                       $field["default"] = null;
-                               }
-                               $process_field = process_field($field, $type_field);
-                               $auto_increment = ($key == $_POST["auto_increment_col"]);
-                               if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
-                                       $fields .= "\n" . ($TABLE != "" ? ($field["orig"] != "" ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
-                                               . " $process_field"
-                                               . ($auto_increment ? " AUTO_INCREMENT$auto_increment_index" : "")
-                                               . ($TABLE != "" ? " $after" : "") . ","
-                                       ;
+       if ($_POST["drop"]) {
+               query_redirect("DROP TABLE " . idf_escape($_GET["create"]), substr(ME, 0, -1), lang('Table has been dropped.'));
+       } else {
+               $auto_increment_index = " PRIMARY KEY";
+               // don't overwrite primary key by auto_increment
+               if ($TABLE != "" && $_POST["auto_increment_col"]) {
+                       foreach (indexes($TABLE) as $index) {
+                               if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
+                                       $auto_increment_index = "";
+                                       break;
                                }
-                               if (!isset($types[$field["type"]])) {
-                                       $fields .= ($TABLE != "" ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
+                               if ($index["type"] == "PRIMARY") {
+                                       $auto_increment_index = " UNIQUE";
                                }
                        }
-                       $after = "AFTER " . idf_escape($field["field"]);
-                       //! drop and create foreign keys with renamed columns
-               } elseif ($field["orig"] != "") {
-                       $fields .= "\nDROP " . idf_escape($field["orig"]) . ",";
                }
-               if ($field["orig"] != "") {
-                       $orig_field = next($orig_fields);
+               $fields = "";
+               ksort($_POST["fields"]);
+               $orig_field = reset($orig_fields);
+               $after = "FIRST";
+               foreach ($_POST["fields"] as $key => $field) {
+                       $type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
+                       if ($field["field"] != "") {
+                               if ($type_field) {
+                                       $default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
+                                       if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
+                                               $field["on_update"] = "CURRENT_TIMESTAMP";
+                                               $field["default"] = $default;
+                                       }
+                                       if (!$field["has_default"]) {
+                                               $field["default"] = null;
+                                       }
+                                       $process_field = process_field($field, $type_field);
+                                       $auto_increment = ($key == $_POST["auto_increment_col"]);
+                                       if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
+                                               $fields .= "\n" . ($TABLE != "" ? ($field["orig"] != "" ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
+                                                       . " $process_field"
+                                                       . ($auto_increment ? " AUTO_INCREMENT$auto_increment_index" : "")
+                                                       . ($TABLE != "" ? " $after" : "") . ","
+                                               ;
+                                       }
+                                       if (!isset($types[$field["type"]])) {
+                                               $fields .= ($TABLE != "" ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
+                                       }
+                               }
+                               $after = "AFTER " . idf_escape($field["field"]);
+                               //! drop and create foreign keys with renamed columns
+                       } elseif ($field["orig"] != "") {
+                               $fields .= "\nDROP " . idf_escape($field["orig"]) . ",";
+                       }
+                       if ($field["orig"] != "") {
+                               $orig_field = next($orig_fields);
+                       }
                }
-       }
-       $status = "COMMENT=" . $connection->quote($_POST["Comment"])
-               . ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
-               . ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
-               . ($_POST["Auto_increment"] != "" ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["Auto_increment"]) : "")
-       ;
-       if (in_array($_POST["partition_by"], $partition_by)) {
-               $partitions = array();
-               if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
-                       foreach (array_filter($_POST["partition_names"]) as $key => $val) {
-                               $value = $_POST["partition_values"][$key];
-                               $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
+               $status = "COMMENT=" . $connection->quote($_POST["Comment"])
+                       . ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
+                       . ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
+                       . ($_POST["Auto_increment"] != "" ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["Auto_increment"]) : "")
+               ;
+               if (in_array($_POST["partition_by"], $partition_by)) {
+                       $partitions = array();
+                       if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
+                               foreach (array_filter($_POST["partition_names"]) as $key => $val) {
+                                       $value = $_POST["partition_values"][$key];
+                                       $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
+                               }
                        }
+                       $status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
+                               ? " (" . implode(",", $partitions) . "\n)"
+                               : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
+                       );
+               } elseif ($connection->server_info >= 5.1 && $TABLE != "") {
+                       $status .= "\nREMOVE PARTITIONING";
+               }
+               $location = ME . "table=" . urlencode($_POST["name"]);
+               if ($TABLE != "") {
+                       query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
+               } else {
+                       cookie("adminer_engine", $_POST["Engine"]);
+                       query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . substr($fields, 0, -1) . "\n) $status", $location, lang('Table has been created.'));
                }
-               $status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
-                       ? " (" . implode(",", $partitions) . "\n)"
-                       : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
-               );
-       } elseif ($connection->server_info >= 5.1 && $TABLE != "") {
-               $status .= "\nREMOVE PARTITIONING";
-       }
-       $location = ME . "table=" . urlencode($_POST["name"]);
-       if ($TABLE != "") {
-               query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
-       } else {
-               cookie("adminer_engine", $_POST["Engine"]);
-               query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . substr($fields, 0, -1) . "\n) $status", $location, lang('Table has been created.'));
        }
 }
 
@@ -174,6 +178,7 @@ document.write('<label><input type="checkbox"<?php if ($column_comments) { ?> ch
 <p>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <input type="submit" value="<?php echo lang('Save'); ?>">
+<?php if (strlen($_GET["create"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
 <?php
 if ($connection->server_info >= 5.1) {
        $partition_table = ereg('RANGE|LIST', $row["partition_by"]);
index 28c61c0bab9221a3d17732721c44eba1fe14ebbd..80e4b65e808e38aae99fde78074f76f8fcd04703 100644 (file)
@@ -1,8 +1,11 @@
 <?php
 if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
-       if (DB !== $_POST["name"]) {
+       restart_session();
+       if ($_POST["drop"]) {
+               unset($_SESSION["databases"][$_GET["server"]]);
+               query_redirect("DROP DATABASE " . idf_escape(DB), remove_from_uri("db|database"), lang('Database has been dropped.'));
+       } elseif (DB !== $_POST["name"]) {
                // create or rename database
-               restart_session();
                unset($_SESSION["databases"][$_GET["server"]]); // clear cache
                $dbs = explode("\n", str_replace("\r", "", $_POST["name"]));
                $failed = false;
@@ -70,7 +73,9 @@ if ($_POST) {
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
-if (!$_POST["add_x"] && $_GET["db"] == "") {
+if (strlen(DB)) {
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
+} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
        echo "<input type='image' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
 }
 ?>
index 8f4f5ec28dc383279ba3187ef43a183314ef078e..8ca5dfe68b8a59930d7440c36a48fadbf11c6adb 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Vybrat databázi',
        'Invalid database.' => 'Nesprávná databáze.',
        'Create new database' => 'Vytvořit novou databázi',
+       'Table has been dropped.' => 'Tabulka byla odstraněna.',
        'Table has been altered.' => 'Tabulka byla změněna.',
        'Table has been created.' => 'Tabulka byla vytvořena.',
        'Alter table' => 'Pozměnit tabulku',
index 83b78786211f630f4fe5383982ac40449ea837ac..cca37cb78de2ba04add4b023debdb8362b0d8d46 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Datenbank auswählen',
        'Invalid database.' => 'Datenbank ungültig.',
        'Create new database' => 'Neue Datenbank',
+       'Table has been dropped.' => 'Tabelle entfernt.',
        'Table has been altered.' => 'Tabelle geändert.',
        'Table has been created.' => 'Tabelle erstellt.',
        'Alter table' => 'Tabelle ändern',
index 27cfcf91b4c9f43af9d320a29e290fa5b65e9e31..c539c432ffe67d975eee57d8c519974dc0fc4302 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Seleccionar Base de datos',
        'Invalid database.' => 'Base de datos inválida.',
        'Create new database' => 'Nueva Base de datos',
+       'Table has been dropped.' => 'Tabla eliminada.',
        'Table has been altered.' => 'Tabla modificada.',
        'Table has been created.' => 'Tabla creada.',
        'Alter table' => 'Modificar Estructura',
index f3b7f313e28df41d0753ee5a158236331ecbd572..6f582c8f58f26f315f9146f6fb23825acf4622b0 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Vali andmebaas',
        'Invalid database.' => 'Tundmatu andmebaas.',
        'Create new database' => 'Loo uus andmebaas',
+       'Table has been dropped.' => 'Tabel on edukalt kustutatud.',
        'Table has been altered.' => 'Tabeli andmed on edukalt muudetud.',
        'Table has been created.' => 'Tabel on edukalt loodud.',
        'Alter table' => 'Muuda tabeli struktuuri',
index ce614875632a8bca7af0eb91dba34ca42eb1ea54..e6dd1030df6c6dbac013984dbd30d3ecde9ec183 100644 (file)
@@ -2,14 +2,15 @@
 $translations = array(
        'Login' => 'Authentification',
        'Logout successful.' => 'Aurevoir!',
-       'Invalid credentials.' => 'Authentification échouée',
+       'Invalid credentials.' => 'Authentification échouée.',
        'Server' => 'Serveur',
        'Username' => 'Utilisateur',
        'Password' => 'Mot de passe',
        'Select database' => 'Selectionner la base de donnée',
-       'Invalid database.' => 'Base de donnée invalide',
+       'Invalid database.' => 'Base de donnée invalide.',
        'Create new database' => 'Créer une base de donnée',
-       'Table has been altered.' => 'Table modifiée',
+       'Table has been dropped.' => 'Table effacée.',
+       'Table has been altered.' => 'Table modifiée.',
        'Table has been created.' => 'Table créée.',
        'Alter table' => 'Modifier la table',
        'Create table' => 'Créer une table',
@@ -57,7 +58,7 @@ $translations = array(
        'Sort' => 'Ordonner',
        'descending' => 'décroissant',
        'Limit' => 'Limit',
-       'No rows.' => 'Aucun résultat',
+       'No rows.' => 'Aucun résultat.',
        'Action' => 'Action',
        'edit' => 'modifier',
        'Page' => 'Page',
@@ -170,9 +171,9 @@ $translations = array(
        'At given time' => 'À un moment précis',
        'Save and continue edit' => 'Sauvegarder et continuer l\'édition',
        'original' => 'original',
-       'Tables have been truncated.' => 'Les tables ont été tronquées',
-       'Tables have been moved.' => 'Les tables ont été déplacées',
-       'Tables have been dropped.' => 'Les tables ont été effacées',
+       'Tables have been truncated.' => 'Les tables ont été tronquées.',
+       'Tables have been moved.' => 'Les tables ont été déplacées.',
+       'Tables have been dropped.' => 'Les tables ont été effacées.',
        'Tables and views' => 'Tables et vues',
        'Engine' => 'Moteur',
        'Collation' => 'Collation',
@@ -191,12 +192,12 @@ $translations = array(
        '%d item(s) have been affected.' => array('%d élément ont été modifié.', '%d éléments ont été modifié.'),
        'whole result' => 'résultat entier',
        'Clone' => 'Cloner',
-       'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Le nombre de champs maximum est dépassé. Veuillez augmenter %s et %s',
+       'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Le nombre de champs maximum est dépassé. Veuillez augmenter %s et %s.',
        'Partition by' => 'Partitionné par',
        'Partitions' => 'Partitions',
        'Partition name' => 'Nom de la partition',
        'Values' => 'Valeurs',
-       '%d row(s) have been imported.' => array('%d ligne a été importé','%d lignes ont été importé'),
+       '%d row(s) have been imported.' => array('%d ligne a été importé.','%d lignes ont été importé.'),
        'Show structure' => 'Structure de la table',
        '(anywhere)' => '(n\'importe où)',
        'CSV Import' => 'Importation CVS',
index 0a5319ca670fdf7210f6b7449d54d86132e03938..7772750405723800c0925ce56954b26850385191 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Seleziona database',
        'Invalid database.' => 'Database non valido.',
        'Create new database' => 'Crea nuovo database',
+       'Table has been dropped.' => 'Tabella eliminata.',
        'Table has been altered.' => 'Tabella modificata.',
        'Table has been created.' => 'Tabella creata.',
        'Alter table' => 'Modifica tabella',
index d25fe47fc3917b872f67f73ab4c078e001ad05b7..6f3b6a8131a5f194e25595dbec5d5856641b1e86 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Database selecteren',
        'Invalid database.' => 'Ongeldige database.',
        'Create new database' => 'Nieuwe database',
+       'Table has been dropped.' => 'Tabel verwijderd.',
        'Table has been altered.' => 'Tabel aangepast.',
        'Table has been created.' => 'Tabel aangemaakt.',
        'Alter table' => 'Tabel aanpassen',
index a799a8361b2d2f7078ef920f0bda2f5b3482aa66..52c40404738d3c9eff7dbc88434c0c890be7d762 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Выбрать базу данных',
        'Invalid database.' => 'Плохая база данных.',
        'Create new database' => 'Создать новую базу данных',
+       'Table has been dropped.' => 'Таблица была удалена.',
        'Table has been altered.' => 'Таблица была изменена.',
        'Table has been created.' => 'Таблица была создана.',
        'Alter table' => 'Изменить таблицу',
index 1eda1e8affb98b7a9a5cf31da1a1cf1c88712e56..cd492153d7cbe03ca296d77e754f4d3199387257 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => 'Vybrať databázu',
        'Invalid database.' => 'Nesprávna databáza.',
        'Create new database' => 'Vytvoriť novú databázu',
+       'Table has been dropped.' => 'Tabuľka bola odstránená.',
        'Table has been altered.' => 'Tabuľka bola zmenená.',
        'Table has been created.' => 'Tabuľka bola vytvorená.',
        'Alter table' => 'Zmeniť tabuľku',
index ca7c7cbd7d86a283ef77ca1eaeb6dd8efee22481..e86396bc88bd0ecd1adacf5a2254d62bfc83a772 100644 (file)
@@ -9,6 +9,7 @@ $translations = array(
        'Select database' => '选择数据库',
        'Invalid database.' => '无效数据库。',
        'Create new database' => '创建新数据库',
+       'Table has been dropped.' => '已丢弃表。',
        'Table has been altered.' => '已更改表。',
        'Table has been created.' => '已创建表。',
        'Alter table' => '更改表',