Function results in edit

Bulk edit
Remove <label for>
Simplify optionlist()
Only one button for each action in select

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@508 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2008-10-01 11:39:13 +00:00
parent 4bee1c0f30
commit 78639a98ca
11 changed files with 108 additions and 95 deletions

View file

@ -97,7 +97,7 @@ $collations = collations();
<?php echo lang('Auto Increment'); ?>: <input name="Auto_increment" size="4" value="<?php echo intval($row["Auto_increment"]); ?>" /> <?php echo lang('Auto Increment'); ?>: <input name="Auto_increment" size="4" value="<?php echo intval($row["Auto_increment"]); ?>" />
<?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" /> <?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" />
<script type="text/javascript">// <![CDATA[ <script type="text/javascript">// <![CDATA[
document.write('<label for="column_comments"><input type="checkbox" id="column_comments"<?php if ($column_comments) { ?> checked="checked"<?php } ?> onclick="column_comments_click(this.checked);" /><?php echo lang('Show column comments'); ?></label>'); document.write('<label><input type="checkbox"<?php if ($column_comments) { ?> checked="checked"<?php } ?> onclick="column_comments_click(this.checked);" /><?php echo lang('Show column comments'); ?></label>');
function column_comments_click(checked) { function column_comments_click(checked) {
var trs = document.getElementsByTagName('tr'); var trs = document.getElementsByTagName('tr');
for (var i=0; i < trs.length; i++) { for (var i=0; i < trs.length; i++) {

View file

@ -1,5 +1,5 @@
<?php <?php
$where = where($_GET); $where = (isset($_GET["select"]) ? array() : where($_GET));
$update = ($where && !$_GET["clone"]); $update = ($where && !$_GET["clone"]);
$fields = fields($_GET["edit"]); $fields = fields($_GET["edit"]);
foreach ($fields as $name => $field) { foreach ($fields as $name => $field) {
@ -7,7 +7,7 @@ foreach ($fields as $name => $field) {
unset($fields[$name]); unset($fields[$name]);
} }
} }
if ($_POST && !$error) { if ($_POST && !$error && !isset($_GET["select"])) {
$location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); $location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"]));
if (isset($_POST["delete"])) { if (isset($_POST["delete"])) {
query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been deleted.')); query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been deleted.'));
@ -37,14 +37,11 @@ if ($_POST && !$error) {
} }
} }
} }
page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]); page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || isset($_GET["select"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
unset($row); unset($row);
if ($_POST) { if ($_POST) {
$row = (array) $_POST["fields"]; $row = (array) $_POST["fields"];
foreach ((array) $_POST["null"] as $key => $val) {
$row[$key] = null;
}
} elseif ($where) { } elseif ($where) {
$select = array(); $select = array();
foreach ($fields as $name => $field) { foreach ($fields as $name => $field) {
@ -78,13 +75,12 @@ if ($fields) {
} }
input($name, $field, $value); input($name, $field, $value);
if (isset($_GET["default"]) && $field["type"] == "timestamp") { if (isset($_GET["default"]) && $field["type"] == "timestamp") {
$id = htmlspecialchars("on_update-$name");
if (!isset($create) && !$_POST) { if (!isset($create) && !$_POST) {
//! disable sql_mode NO_FIELD_OPTIONS //! disable sql_mode NO_FIELD_OPTIONS
$create = $mysql->result($mysql->query("SHOW CREATE TABLE " . idf_escape($_GET["edit"])), 1); $create = $mysql->result($mysql->query("SHOW CREATE TABLE " . idf_escape($_GET["edit"])), 1);
} }
$checked = ($_POST ? $_POST["on_update"][bracket_escape($name)] : preg_match("~\n\\s*" . preg_quote(idf_escape($name), '~') . " timestamp.* on update CURRENT_TIMESTAMP~i", $create)); $checked = ($_POST ? $_POST["on_update"][bracket_escape($name)] : preg_match("~\n\\s*" . preg_quote(idf_escape($name), '~') . " timestamp.* on update CURRENT_TIMESTAMP~i", $create));
echo '<label for="' . $id . '"><input type="checkbox" name="on_update[' . htmlspecialchars(bracket_escape($name)) . ']" id="' . $id . '" value="1"' . ($checked ? ' checked="checked"' : '') . ' />' . lang('ON UPDATE CURRENT_TIMESTAMP') . '</label>'; echo '<label><input type="checkbox" name="on_update[' . htmlspecialchars(bracket_escape($name)) . ']" value="1"' . ($checked ? ' checked="checked"' : '') . ' />' . lang('ON UPDATE CURRENT_TIMESTAMP') . '</label>';
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
@ -93,9 +89,17 @@ if ($fields) {
?> ?>
<p> <p>
<input type="hidden" name="token" value="<?php echo $token; ?>" /> <input type="hidden" name="token" value="<?php echo $token; ?>" />
<?php if ($fields) { ?> <?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");
}
if ($fields) {
?>
<input type="submit" value="<?php echo lang('Save'); ?>" /> <input type="submit" value="<?php echo lang('Save'); ?>" />
<?php if (!isset($_GET["default"])) { ?><input type="submit" name="insert" value="<?php echo ($update ? lang('Save and continue edit') : lang('Save and insert next')); ?>" /><?php } ?> <?php if (!isset($_GET["default"]) && !isset($_GET["select"])) { ?><input type="submit" name="insert" value="<?php echo ($update ? lang('Save and continue edit') : lang('Save and insert next')); ?>" /><?php } ?>
<?php } ?> <?php } ?>
<?php if ($update) { ?> <input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?>');" /><?php } ?> <?php if ($update) { ?> <input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?>');" /><?php } ?>
</p> </p>

View file

@ -2,61 +2,73 @@
function input($name, $field, $value) { function input($name, $field, $value) {
global $types; global $types;
$name = htmlspecialchars(bracket_escape($name)); $name = htmlspecialchars(bracket_escape($name));
$onchange = ($field["null"] ? ' onchange="this.form[\'null[' . addcslashes($name, "\r\n'\\") . ']\'].checked = false;"' : '');
if ($field["type"] == "enum") { if ($field["type"] == "enum") {
if (isset($_GET["select"])) {
echo ' <label><input type="radio" name="fields[' . $name . ']" value="-1" checked="checked" /><em>' . lang('original') . '</em></label>';
}
if ($field["null"]) {
echo ' <label><input type="radio" name="fields[' . $name . ']" value=""' . (isset($value) || isset($_GET["select"]) ? '' : ' checked="checked"') . ' /><em>NULL</em></label>';
}
if (!isset($_GET["default"])) { if (!isset($_GET["default"])) {
echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . ' />'; echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . ' />';
} }
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches); preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) { foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val)); $val = stripcslashes(str_replace("''", "'", $val));
$id = "field-$name-" . ($i+1);
$checked = (is_int($value) ? $value == $i+1 : $value === $val); $checked = (is_int($value) ? $value == $i+1 : $value === $val);
echo ' <label for="' . $id . '"><input type="radio" name="fields[' . $name . ']" id="' . $id . '" value="' . (isset($_GET["default"]) ? (strlen($val) ? htmlspecialchars($val) : " ") : $i+1) . '"' . ($checked ? ' checked="checked"' : '') . ' />' . htmlspecialchars($val) . '</label>'; echo ' <label><input type="radio" name="fields[' . $name . ']" value="' . (isset($_GET["default"]) ? (strlen($val) ? htmlspecialchars($val) : " ") : $i+1) . '"' . ($checked ? ' checked="checked"' : '') . ' />' . htmlspecialchars($val) . '</label>';
} }
if ($field["null"]) {
$id = "field-$name-";
echo ' <label for="' . $id . '"><input type="radio" name="fields[' . $name . ']" id="' . $id . '" value=""' . (isset($value) ? '' : ' checked="checked"') . ' />' . lang('NULL') . '</label>';
}
} elseif ($field["type"] == "set") { //! 64 bits
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
$id = "field-$name-" . ($i+1);
$checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
echo ' <input type="checkbox" name="fields[' . $name . '][' . $i . ']" id="' . $id . '" value="' . (isset($_GET["default"]) ? htmlspecialchars($val) : 1 << $i) . '"' . ($checked ? ' checked="checked"' : '') . $onchange . ' /><label for="' . $id . '">' . htmlspecialchars($val) . '</label>';
}
} elseif (strpos($field["type"], "text") !== false) {
echo '<textarea name="fields[' . $name . ']" cols="50" rows="12"' . $onchange . '>' . htmlspecialchars($value) . '</textarea>';
} elseif (preg_match('~binary|blob~', $field["type"])) {
echo (ini_get("file_uploads") ? '<input type="file" name="' . $name . '"' . $onchange . ' />' : lang('File uploads are disabled.') . ' ');
} else { } else {
echo '<input name="fields[' . $name . ']" value="' . htmlspecialchars($value) . '"' . (preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? " maxlength='" . ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) . "'" : ($types[$field["type"]] ? " maxlength='" . $types[$field["type"]] . "'" : '')) . $onchange . ' />'; $first = (isset($_GET["select"]) ? 2 : 1);
} $onchange = ($field["null"] || isset($_GET["select"]) ? ' onchange="var f = this.form[\'function[' . addcslashes($name, "\r\n'\\") . ']\']; f.selectedIndex = Math.max(f.selectedIndex, ' . $first . ');"' : '');
if ($field["null"] && $field["type"] != "enum") { $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : (preg_match('~date|time~', $field["type"]) ? array("", "now") : array("")));
$id = "null-$name"; if ($field["null"]) {
echo '<label for="' . $id . '"><input type="checkbox" name="null[' . $name . ']" value="1" id="' . $id . '"' . (isset($value) ? '' : ' checked="checked"') . ' />' . lang('NULL') . '</label>'; array_unshift($options, "NULL");
}
if (count($options) > 1 || isset($_GET["select"])) {
echo '<select name="function[' . $name . ']">' . (isset($_GET["select"]) ? '<option value="orig">' . lang('original') . '</option>' : '') . optionlist($options, (isset($value) ? (string) $_POST["function"][$name] : null)) . '</select>';
}
if ($field["type"] == "set") { //! 64 bits
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
$checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
echo ' <label><input type="checkbox" name="fields[' . $name . '][' . $i . ']" value="' . (isset($_GET["default"]) ? htmlspecialchars($val) : 1 << $i) . '"' . ($checked ? ' checked="checked"' : '') . $onchange . ' />' . htmlspecialchars($val) . '</label>';
}
} elseif (strpos($field["type"], "text") !== false) {
echo '<textarea name="fields[' . $name . ']" cols="50" rows="12"' . $onchange . '>' . htmlspecialchars($value) . '</textarea>';
} elseif (preg_match('~binary|blob~', $field["type"])) {
echo (ini_get("file_uploads") ? '<input type="file" name="' . $name . '"' . $onchange . ' />' : lang('File uploads are disabled.') . ' ');
} else {
echo '<input name="fields[' . $name . ']" value="' . htmlspecialchars($value) . '"' . (preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? " maxlength='" . ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) . "'" : ($types[$field["type"]] ? " maxlength='" . $types[$field["type"]] . "'" : '')) . $onchange . ' />';
}
} }
} }
function process_input($name, $field) { function process_input($name, $field) {
global $mysql; global $mysql;
$name = bracket_escape($name); $idf = bracket_escape($name);
$value = $_POST["fields"][$name]; $value = $_POST["fields"][$idf];
if ($field["type"] != "enum" && !$field["auto_increment"] ? $_POST["null"][$name] : !strlen($value)) { if ($field["type"] == "enum" ? $value == -1 : $_POST["function"][$idf] == "orig") {
return false;
} elseif ($field["type"] == "enum" || $field["auto_increment"] ? !strlen($value) : $_POST["function"][$idf] == "NULL") {
return "NULL"; return "NULL";
} elseif ($field["type"] == "enum") { } elseif ($field["type"] == "enum") {
return (isset($_GET["default"]) ? "'" . $mysql->escape_string($value) . "'" : intval($value)); return (isset($_GET["default"]) ? "'" . $mysql->escape_string($value) . "'" : intval($value));
} elseif ($field["type"] == "set") { } elseif ($field["type"] == "set") {
return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value)); return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value));
} elseif (preg_match('~binary|blob~', $field["type"])) { } elseif (preg_match('~binary|blob~', $field["type"])) {
$file = get_file($name); $file = get_file($idf);
if (!is_string($file) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) { if (!is_string($file) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) {
return false; //! report errors return false; //! report errors
} }
return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'"; return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";
} elseif ($field["type"] == "timestamp" && $value == "CURRENT_TIMESTAMP") { } elseif ($field["type"] == "timestamp" && $value == "CURRENT_TIMESTAMP") {
return $value; return $value;
} elseif (preg_match('~^(now|uuid)$~', $_POST["function"][$idf])) {
return $_POST["function"][$idf] . "()";
} elseif (preg_match('~^(md5|sha1|password)$~', $_POST["function"][$idf])) {
return $_POST["function"][$idf] . "('" . $mysql->escape_string($value) . "')";
} else { } else {
return "'" . $mysql->escape_string($value) . "'"; return "'" . $mysql->escape_string($value) . "'";
} }

View file

@ -12,15 +12,14 @@ function bracket_escape($idf, $back = false) {
return strtr($idf, ($back ? array_flip($trans) : $trans)); return strtr($idf, ($back ? array_flip($trans) : $trans));
} }
function optionlist($options, $selected = array()) { function optionlist($options, $selected = null) {
$return = ""; $return = "";
foreach ($options as $k => $v) { foreach ($options as $k => $v) {
if (is_array($v)) { if (is_array($v)) {
$return .= '<optgroup label="' . htmlspecialchars($k) . '">'; $return .= '<optgroup label="' . htmlspecialchars($k) . '">';
} }
foreach ((is_array($v) ? $v : array($v)) as $val) { foreach ((is_array($v) ? $v : array($v)) as $val) {
$checked = in_array($val, (array) $selected, true); $return .= '<option' . ($val === $selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($val) . '</option>';
$return .= '<option' . ($checked ? ' selected="selected"' : '') . '>' . htmlspecialchars($val) . '</option>';
} }
if (is_array($v)) { if (is_array($v)) {
$return .= '</optgroup>'; $return .= '</optgroup>';

View file

@ -83,6 +83,9 @@ if (isset($_GET["download"])) {
if (isset($_GET["default"])) { if (isset($_GET["default"])) {
$_GET["edit"] = $_GET["default"]; $_GET["edit"] = $_GET["default"];
} }
if (isset($_GET["select"]) && $_POST["edit"]) {
$_GET["edit"] = $_GET["select"];
}
if (isset($_GET["callf"])) { if (isset($_GET["callf"])) {
$_GET["call"] = $_GET["callf"]; $_GET["call"] = $_GET["callf"];
} }

View file

@ -150,10 +150,6 @@ $translations = array(
'Grant' => 'Povolit', 'Grant' => 'Povolit',
'Revoke' => 'Zakázat', 'Revoke' => 'Zakázat',
'Error during deleting' => 'Chyba při mazání', 'Error during deleting' => 'Chyba při mazání',
'%d item(s) have been deleted.' => array('Byl smazán %d záznam.', 'Byly smazány %d záznamy.', 'Bylo smazáno %d záznamů.'),
'all' => 'vše',
'Delete selected' => 'Smazat označené',
'Truncate result' => 'Promazat výsledek',
'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".', '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', 'Logged as: %s' => 'Přihlášen jako: %s',
'Move up' => 'Přesunout nahoru', 'Move up' => 'Přesunout nahoru',
@ -171,8 +167,8 @@ $translations = array(
'Tables' => 'Tabulky', 'Tables' => 'Tabulky',
'Structure' => 'Struktura', 'Structure' => 'Struktura',
'Data' => 'Data', 'Data' => 'Data',
'Export selected' => 'Exportovat označené', // 'Export selected' => 'Exportovat označené',
'Export result' => 'Exportovat výsledek', // 'Export result' => 'Exportovat výsledek',
'Event has been dropped.' => 'Událost byla odstraněna.', 'Event has been dropped.' => 'Událost byla odstraněna.',
'Event has been altered.' => 'Událost byla změněna.', 'Event has been altered.' => 'Událost byla změněna.',
'Event has been created.' => 'Událost byla vytvořena.', 'Event has been created.' => 'Událost byla vytvořena.',
@ -205,4 +201,7 @@ $translations = array(
'Engine' => 'Úložiště', 'Engine' => 'Úložiště',
'Save and continue edit' => 'Uložit a pokračovat v editaci', 'Save and continue edit' => 'Uložit a pokračovat v editaci',
'clone' => 'klonovat', 'clone' => 'klonovat',
'original' => 'původní',
'%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',
); );

View file

@ -5,5 +5,5 @@ $translations = array(
'Routine has been called, %d row(s) affected.' => array('Routine has been called, %d row affected.', 'Routine has been called, %d rows affected.'), 'Routine has been called, %d row(s) affected.' => array('Routine has been called, %d row affected.', 'Routine has been called, %d rows affected.'),
'%d process(es) has been killed.' => array('%d process has been killed.', '%d processes have been killed.'), '%d process(es) has been killed.' => array('%d process has been killed.', '%d processes have been killed.'),
'%d row(s)' => array('%d row', '%d rows'), '%d row(s)' => array('%d row', '%d rows'),
'%d item(s) have been deleted.' => array('%d item has been deleted.', '%d items have been deleted.'), '%d item(s) have been affected.' => array('%d item have been affected.', '%d items have been affected.'),
); );

View file

@ -58,49 +58,47 @@ $from = "FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode("
if ($_POST && !$error) { if ($_POST && !$error) {
$result = true; $result = true;
$deleted = 0; $affected = 0;
if ($_POST["export"] || $_POST["export_result"]) { if ($_POST["export"]) {
dump_headers($_GET["select"]); dump_headers($_GET["select"]);
dump_table($_GET["select"], ""); dump_table($_GET["select"], "");
} if ($_POST["all"]) {
if (isset($_POST["truncate"])) { dump_data($_GET["select"], "INSERT", ($where ? "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : ""));
$result = queries($where ? "DELETE FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : "TRUNCATE " . idf_escape($_GET["select"]));
$deleted = $mysql->affected_rows;
} elseif ($_POST["export_result"]) {
dump_data($_GET["select"], "INSERT", ($where ? "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : ""));
} elseif (is_array($_POST["delete"])) {
foreach ($_POST["delete"] as $val) {
parse_str($val, $delete);
if ($_POST["export"]) {
dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($delete)) . " LIMIT 1");
} else {
$result = queries("DELETE FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($delete)) . " LIMIT 1");
if (!$result) {
break;
}
$deleted += $mysql->affected_rows;
}
}
} elseif ($_POST["delete_selected"]) {
if ($_POST["export"]) {
dump_data($_GET["select"], "INSERT", $from);
} else { } else {
$result1 = $mysql->query("SELECT * $from"); foreach ((array) $_POST["check"] as $val) {
while ($row1 = $result1->fetch_assoc()) { parse_str($val, $check);
parse_str(implode("&", unique_idf($row1, $indexes)), $delete); dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($check)) . " LIMIT 1");
$result = queries("DELETE FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($delete)) . " LIMIT 1");
if (!$result) {
break;
}
$deleted += $mysql->affected_rows;
} }
$result1->free();
} }
}
if ($_POST["export"] || $_POST["export_result"]) {
exit; exit;
} }
query_redirect(queries(), remove_from_uri("page"), lang('%d item(s) have been deleted.', $deleted), $result, false, !$result); $command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : "UPDATE ") . idf_escape($_GET["select"]);
if (!$_POST["delete"]) {
$set = array();
foreach ($fields as $name => $field) {
$val = process_input($name, $field);
if ($val !== false) {
$set[] = idf_escape($name) . " = $val";
}
}
$command .= " SET " . implode(", ", $set);
}
if (!$_POST["delete"] && !$set) {
// nothing
} elseif ($_POST["all"]) {
$result = queries($command . ($where ? " WHERE " . implode(" AND ", $where) : ""));
$affected = $mysql->affected_rows;
} else {
foreach ((array) $_POST["check"] as $val) {
parse_str($val, $check);
$result = queries($command . " WHERE " . implode(" AND ", where($check)) . " LIMIT 1");
if (!$result) {
break;
}
$affected += $mysql->affected_rows;
}
}
query_redirect(queries(), remove_from_uri("page"), lang('%d item(s) have been affected.', $affected), $result, false, !$result);
} }
page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), ($error ? lang('Error during deleting') . ": $error" : "")); page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), ($error ? lang('Error during deleting') . ": $error" : ""));
@ -156,7 +154,7 @@ function add_row(field) {
if ($index["type"] == "FULLTEXT") { if ($index["type"] == "FULLTEXT") {
echo "(<i>" . implode("</i>, <i>", array_map('htmlspecialchars', $index["columns"])) . "</i>) AGAINST"; echo "(<i>" . implode("</i>, <i>", array_map('htmlspecialchars', $index["columns"])) . "</i>) AGAINST";
echo ' <input name="fulltext[' . $i . ']" value="' . htmlspecialchars($_GET["fulltext"][$i]) . '" />'; echo ' <input name="fulltext[' . $i . ']" value="' . htmlspecialchars($_GET["fulltext"][$i]) . '" />';
echo "<label for='boolean-$i'><input type='checkbox' name='boolean[$i]' value='1' id='boolean-$i'" . (isset($_GET["boolean"][$i]) ? " checked='checked'" : "") . " />" . lang('BOOL') . "</label>"; echo "<label><input type='checkbox' name='boolean[$i]' value='1'" . (isset($_GET["boolean"][$i]) ? " checked='checked'" : "") . " />" . lang('BOOL') . "</label>";
echo "<br />\n"; echo "<br />\n";
} }
} }
@ -229,14 +227,14 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
for ($j=0; $row = $result->fetch_assoc(); $j++) { for ($j=0; $row = $result->fetch_assoc(); $j++) {
if (!$j) { if (!$j) {
echo '<thead><tr>' . (count($select) == count($group) ? '<td><label><input type="checkbox" name="delete_selected" value="1" onclick="var elems = this.form.elements; for (var i=0; elems.length > i; i++) if (elems[i].name == \'delete[]\') elems[i].checked = this.checked;" />' . lang('all') . '</label></td>' : ''); echo '<thead><tr>' . (count($select) == count($group) ? '<td><label><input type="checkbox" name="all" value="1" />' . lang('whole result') . '</label></td>' : '');
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*')) . '&amp;order%5B0%5D=' . htmlspecialchars($key) . ($_GET["order"][0] === $key && !$_GET["desc"][0] ? '&amp;desc%5B0%5D=1' : '') . '">' . htmlspecialchars($key) . "</a></th>"; echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*')) . '&amp;order%5B0%5D=' . htmlspecialchars($key) . ($_GET["order"][0] === $key && !$_GET["desc"][0] ? '&amp;desc%5B0%5D=1' : '') . '">' . htmlspecialchars($key) . "</a></th>";
} }
echo "</tr></thead>\n"; echo "</tr></thead>\n";
} }
$unique_idf = implode('&amp;', unique_idf($row, $indexes)); $unique_idf = implode('&amp;', unique_idf($row, $indexes));
echo '<tr class="nowrap">' . (count($select) == count($group) ? '<td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '&amp;clone=1">' . lang('clone') . '</a></td>' : ''); echo '<tr class="nowrap">' . (count($select) == count($group) ? '<td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false;" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '&amp;clone=1">' . lang('clone') . '</a></td>' : '');
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
if (!isset($val)) { if (!isset($val)) {
$val = "<i>NULL</i>"; $val = "<i>NULL</i>";
@ -289,8 +287,8 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
} }
echo " (" . lang('%d row(s)', $found_rows) . ")</p>\n"; echo " (" . lang('%d row(s)', $found_rows) . ")</p>\n";
echo "<fieldset><legend>" . lang('Delete') . "</legend><input type='hidden' name='token' value='$token' />" . (count($group) == count($select) ? "<input type='submit' value='" . lang('Delete selected') . "' /> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate result') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\" /></fieldset>\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('Export') . "</legend>$dump_options " . (count($group) == count($select) ? "<input type='submit' name='export' value='" . lang('Export selected') . "' /> " : "") . "<input type='submit' name='export_result' value='" . lang('Export result') . "' /></fieldset>\n"; echo "<fieldset><legend>" . lang('Export') . "</legend>$dump_options <input type='submit' name='export' value='" . lang('Export') . "' /></fieldset>\n";
echo "</form>\n"; echo "</form>\n";
} }
$result->free(); $result->free();

View file

@ -58,7 +58,7 @@ if (!$error && $_POST) {
<input type="hidden" name="token" value="<?php echo $token; ?>" /> <input type="hidden" name="token" value="<?php echo $token; ?>" />
<input type="submit" value="<?php echo lang('Execute'); ?>" /> <input type="submit" value="<?php echo lang('Execute'); ?>" />
<script type="text/javascript">// <![CDATA[ <script type="text/javascript">// <![CDATA[
document.write('<label for="highlight"><input type="checkbox" name="highlight" id="highlight" value="jush"<?php echo ($_COOKIE["highlight"] == "jush" ? ' checked="checked"' : ''); ?> /><?php echo addcslashes(lang('Syntax highlighting'), "\r\n'\\"); ?></label>'); document.write('<label><input type="checkbox" name="highlight" value="jush"<?php echo ($_COOKIE["highlight"] == "jush" ? ' checked="checked"' : ''); ?> /><?php echo addcslashes(lang('Syntax highlighting'), "\r\n'\\"); ?></label>');
// ]]></script> // ]]></script>
</p> </p>
</form> </form>

View file

@ -1,14 +1,12 @@
Add whisperer to fields with foreign key Add whisperer to fields with foreign key
Highlight found fields Highlight found fields
MySQL 5 BIT data type MySQL 5 BIT data type
Input function results in edit
Bulk update - leave original, set to value, set to NULL
Transactions in export Transactions in export
Compress export and import Compress export and import
Partitioning (MySQL 5.1) Partitioning (MySQL 5.1)
Create view and routine options Create view and routine options
Import CSV Import CSV
Fix database encoding - http://php.vrana.cz/prevod-kodovani-mysql.php Function to fix database encoding - http://php.vrana.cz/prevod-kodovani-mysql.php
? Execution time in sql.inc.php ? Execution time in sql.inc.php
? Save token also to cookie - for session expiration and login in other window ? Save token also to cookie - for session expiration and login in other window
? Save uploaded files after error to session variable instead of hidden field ? Save uploaded files after error to session variable instead of hidden field

View file

@ -134,7 +134,7 @@ if ($_POST) {
<table border="0" cellspacing="0" cellpadding="2"> <table border="0" cellspacing="0" cellpadding="2">
<tr><th><?php echo lang('Username'); ?></th><td><input name="user" maxlength="16" value="<?php echo htmlspecialchars($row["user"]); ?>" /></td></tr> <tr><th><?php echo lang('Username'); ?></th><td><input name="user" maxlength="16" value="<?php echo htmlspecialchars($row["user"]); ?>" /></td></tr>
<tr><th><?php echo lang('Server'); ?></th><td><input name="host" maxlength="60" value="<?php echo htmlspecialchars($row["host"]); ?>" /></td></tr> <tr><th><?php echo lang('Server'); ?></th><td><input name="host" maxlength="60" value="<?php echo htmlspecialchars($row["host"]); ?>" /></td></tr>
<tr><th><?php echo lang('Password'); ?></th><td><input id="pass" name="pass" value="<?php echo htmlspecialchars($row["pass"]); ?>" /><?php if (!$row["hashed"]) { ?><script type="text/javascript">document.getElementById('pass').type = 'password';</script><?php } ?> <label for="hashed"><input type="checkbox" name="hashed" id="hashed" value="1"<?php if ($row["hashed"]) { ?> checked="checked"<?php } ?> onclick="this.form['pass'].type = (this.checked ? 'text' : 'password');" /><?php echo lang('Hashed'); ?></label></td></tr> <tr><th><?php echo lang('Password'); ?></th><td><input id="pass" name="pass" value="<?php echo htmlspecialchars($row["pass"]); ?>" /><?php if (!$row["hashed"]) { ?><script type="text/javascript">document.getElementById('pass').type = 'password';</script><?php } ?> <label><input type="checkbox" name="hashed" value="1"<?php if ($row["hashed"]) { ?> checked="checked"<?php } ?> onclick="this.form['pass'].type = (this.checked ? 'text' : 'password');" /><?php echo lang('Hashed'); ?></label></td></tr>
</table> </table>
<?php <?php