mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 03:24:01 +02:00
Bulk clone
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@526 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
21
edit.inc.php
21
edit.inc.php
@@ -49,12 +49,11 @@ if ($_POST) {
|
||||
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
|
||||
}
|
||||
}
|
||||
$row = array();
|
||||
if ($select) {
|
||||
$result = $mysql->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1");
|
||||
$row = $result->fetch_assoc();
|
||||
$result->free();
|
||||
} else {
|
||||
$row = array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -66,13 +65,11 @@ if ($fields) {
|
||||
echo "<table border='0' cellspacing='0' cellpadding='2'>\n";
|
||||
foreach ($fields as $name => $field) {
|
||||
echo "<tr><th>" . htmlspecialchars($name) . "</th><td>";
|
||||
if (!isset($row)) {
|
||||
$value = $field["default"];
|
||||
} elseif (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set")) {
|
||||
$value = intval($row[$name]);
|
||||
} else {
|
||||
$value = $row[$name];
|
||||
}
|
||||
$value = (!isset($row) ? $field["default"] :
|
||||
(strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) :
|
||||
($_POST["clone"] && $field["auto_increment"] ? "" :
|
||||
$row[$name]
|
||||
)));
|
||||
input($name, $field, $value);
|
||||
if (isset($_GET["default"]) && $field["type"] == "timestamp") {
|
||||
if (!isset($create) && !$_POST) {
|
||||
@@ -91,10 +88,8 @@ if ($fields) {
|
||||
<input type="hidden" name="token" value="<?php echo $token; ?>" />
|
||||
<?php
|
||||
if (isset($_GET["select"])) {
|
||||
foreach ((array) $_POST["check"] as $val) {
|
||||
echo '<input type="hidden" name="check[]" value="' . htmlspecialchars($val) . '" />';
|
||||
}
|
||||
echo ($_POST["all"] ? "<input type='hidden' name='all' value='1' />\n" : "\n");
|
||||
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
|
||||
echo "<input type='hidden' name='save' value='1' />\n";
|
||||
}
|
||||
if ($fields) {
|
||||
?>
|
||||
|
@@ -341,7 +341,7 @@ function table_comment(&$row) {
|
||||
}
|
||||
}
|
||||
|
||||
function hidden_fields($process, $ignore) {
|
||||
function hidden_fields($process, $ignore = array()) {
|
||||
while (list($key, $val) = each($process)) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k => $v) {
|
||||
|
@@ -99,7 +99,7 @@ if (isset($_GET["download"])) {
|
||||
if (isset($_GET["default"])) {
|
||||
$_GET["edit"] = $_GET["default"];
|
||||
}
|
||||
if (isset($_GET["select"]) && $_POST["edit"]) {
|
||||
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["save"])) {
|
||||
$_GET["edit"] = $_GET["select"];
|
||||
}
|
||||
if (isset($_GET["callf"])) {
|
||||
@@ -108,6 +108,9 @@ if (isset($_GET["download"])) {
|
||||
if (isset($_GET["function"])) {
|
||||
$_GET["procedure"] = $_GET["function"];
|
||||
}
|
||||
if (isset($_GET["clone"])) {
|
||||
$_GET["edit"] = $_GET["clone"];
|
||||
}
|
||||
if (isset($_GET["sql"])) {
|
||||
include "./sql.inc.php";
|
||||
} elseif (isset($_GET["edit"])) {
|
||||
|
@@ -149,7 +149,6 @@ $translations = array(
|
||||
'Routine' => 'Procedura',
|
||||
'Grant' => 'Povolit',
|
||||
'Revoke' => 'Zakázat',
|
||||
'Error during deleting' => 'Chyba při mazání',
|
||||
'Too big POST data. Reduce the data or increase the "post_max_size" configuration directive.' => 'Příliš velká POST data. Zmenšete data nebo zvyšte hodnotu konfigurační direktivy "post_max_size".',
|
||||
'Logged as: %s' => 'Přihlášen jako: %s',
|
||||
'Move up' => 'Přesunout nahoru',
|
||||
@@ -167,8 +166,6 @@ $translations = array(
|
||||
'Tables' => 'Tabulky',
|
||||
'Structure' => 'Struktura',
|
||||
'Data' => 'Data',
|
||||
// 'Export selected' => 'Exportovat označené',
|
||||
// 'Export result' => 'Exportovat výsledek',
|
||||
'Event has been dropped.' => 'Událost byla odstraněna.',
|
||||
'Event has been altered.' => 'Událost byla změněna.',
|
||||
'Event has been created.' => 'Událost byla vytvořena.',
|
||||
@@ -205,4 +202,5 @@ $translations = array(
|
||||
'%d item(s) have been affected.' => array('Byl ovlivněn %d záznam.', 'Byly ovlivněny %d záznamy.', 'Bylo ovlivněno %d záznamů.'),
|
||||
'whole result' => 'celý výsledek',
|
||||
'Tables have been dropped.' => 'Tabulky byla odstraněny.',
|
||||
'Clone' => 'Klonovat',
|
||||
);
|
||||
|
@@ -67,8 +67,6 @@ $limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30");
|
||||
$from = "FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($group && count($group) < count($select) ? " GROUP BY " . implode(", ", $group) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
|
||||
|
||||
if ($_POST && !$error) {
|
||||
$result = true;
|
||||
$affected = 0;
|
||||
if ($_POST["export"]) {
|
||||
dump_headers($_GET["select"]);
|
||||
dump_table($_GET["select"], "");
|
||||
@@ -82,16 +80,20 @@ if ($_POST && !$error) {
|
||||
}
|
||||
exit;
|
||||
}
|
||||
$command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : "UPDATE ") . idf_escape($_GET["select"]);
|
||||
$result = true;
|
||||
$affected = 0;
|
||||
$command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($_GET["select"]);
|
||||
if (!$_POST["delete"]) {
|
||||
$set = array();
|
||||
foreach ($fields as $name => $field) {
|
||||
$val = process_input($name, $field);
|
||||
if ($val !== false) {
|
||||
if ($_POST["clone"]) {
|
||||
$set[] = ($val !== false ? $val : idf_escape($name));
|
||||
} elseif ($val !== false) {
|
||||
$set[] = idf_escape($name) . " = $val";
|
||||
}
|
||||
}
|
||||
$command .= " SET " . implode(", ", $set);
|
||||
$command .= ($_POST["clone"] ? " SELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET " . implode(", ", $set));
|
||||
}
|
||||
if (!$_POST["delete"] && !$set) {
|
||||
// nothing
|
||||
@@ -109,8 +111,9 @@ if ($_POST && !$error) {
|
||||
}
|
||||
}
|
||||
query_redirect(queries(), remove_from_uri("page"), lang('%d item(s) have been affected.', $affected), $result, false, !$result);
|
||||
//! display edit page in case of an error
|
||||
}
|
||||
page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), ($error ? lang('Error during deleting') . ": $error" : ""));
|
||||
page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), $error);
|
||||
|
||||
if (isset($rights["insert"])) {
|
||||
//! pass search values forth and back
|
||||
@@ -297,7 +300,7 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
|
||||
}
|
||||
echo " (" . lang('%d row(s)', $found_rows) . ")</p>\n";
|
||||
|
||||
echo "<fieldset><legend>" . lang('Edit') . "</legend><input type='hidden' name='token' value='$token' /><input type='submit' name='edit' value='" . lang('Edit') . "' /> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return !this.form['all'].checked || confirm('" . lang('Are you sure?') . "');\" /></fieldset>\n";
|
||||
echo "<fieldset><legend>" . lang('Edit') . "</legend><input type='hidden' name='token' value='$token' /><input type='submit' value='" . lang('Edit') . "' /> <input type='submit' name='clone' value='" . lang('Clone') . "' /> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return !this.form['all'].checked || confirm('" . lang('Are you sure?') . "');\" /></fieldset>\n";
|
||||
echo "<fieldset><legend>" . lang('Export') . "</legend>$dump_options <input type='submit' name='export' value='" . lang('Export') . "' /></fieldset>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user