diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 509f9f97..e0c17d03 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -17,7 +17,7 @@ if (!$error && $_POST) { $call = array(); foreach ($routine["fields"] as $key => $field) { if (in_array($key, $in)) { - $val = process_input($key, $field); + $val = process_input($field); if ($val === false) { $val = "''"; } diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index c91dcbc6..a5ab4ede 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -11,7 +11,7 @@ if ($_POST && !$error && !isset($_GET["select"])) { $location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); // "insert" to continue edit or insert $set = array(); foreach ($fields as $name => $field) { - $val = process_input($name, $field); + $val = process_input($field); if (!isset($_GET["default"])) { if ($val !== false || !$update) { $set[] = "\n" . idf_escape($name) . " = " . ($val !== false ? $val : "''"); @@ -74,6 +74,9 @@ if ($fields) { ? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name]) : ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $field["default"])) ); + if (!$_POST["save"] && is_string($value)) { + $value = $adminer->editVal($value, $field); + } $function = ($_POST["save"] ? (string) $_POST["function"][$name] : ($where && $field["on_update"] == "CURRENT_TIMESTAMP" ? "now" : ($value === false ? null : (isset($value) ? '' : 'NULL')))); input($field, $value, $function); if (isset($_GET["default"]) && $field["type"] == "timestamp") { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 2bdbcfe4..63067301 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -110,7 +110,7 @@ class Adminer { } /** Value printed in select table - * @param string escaped value to print + * @param string HTML-escaped value to print * @param string link to foreign key * @param array single field returned from fields() * @return string @@ -123,6 +123,15 @@ class Adminer { return ($link ? "$return" : $return); } + /** Value conversion used in select and edit + * @param string + * @param array single field returned from fields() + * @return + */ + function editVal($val, $field) { + return $val; + } + /** Print columns box in select * @param array result of selectColumnsProcess() * @param array selectable columns @@ -263,7 +272,7 @@ class Adminer { $return[] = "MATCH (" . idf_escape($val["col"]) . ") AGAINST (" . $dbh->quote($val["val"]) . " IN BOOLEAN MODE)"; } else { $in = process_length($val["val"]); - $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " (" . (strlen($in) ? $in : "NULL") . ")" : " " . $dbh->quote($val["val"]))); + $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " (" . (strlen($in) ? $in : "NULL") . ")" : " " . $this->processInput($fields[$val["col"]], $val["val"]))); if (strlen($val["col"])) { $return[] = idf_escape($val["col"]) . $cond; } else { @@ -379,15 +388,14 @@ class Adminer { } /** Process sent input - * @param string field name * @param array single field from fields() + * @param string + * @param string * @return string expression to use in a query */ - function processInput($name, $field) { + function processInput($field, $value, $function = "") { global $dbh; - $idf = bracket_escape($name); - $function = $_POST["function"][$idf]; - $value = $_POST["fields"][$idf]; + $name = $field["field"]; $return = $dbh->quote($value); if (ereg('^(now|uuid)$', $function)) { $return = "$function()"; diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 674f4ce5..7f100231 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -318,7 +318,7 @@ function input($field, $value, $function) { } elseif (strpos($field["type"], "text") !== false) { echo ''; } elseif (ereg('binary|blob', $field["type"])) { - echo (ini_get("file_uploads") ? '' : lang('File uploads are disabled.') . ' '); + echo (ini_get("file_uploads") ? '' : lang('File uploads are disabled.')); } else { // int(3) is only a display hint $maxlength = (!ereg('int', $field["type"]) && preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0)); @@ -327,9 +327,9 @@ function input($field, $value, $function) { } } -function process_input($name, $field) { +function process_input($field) { global $dbh, $adminer; - $idf = bracket_escape($name); + $idf = bracket_escape($field["field"]); $function = $_POST["function"][$idf]; $value = $_POST["fields"][$idf]; if ($field["type"] == "enum" ? $value == -1 : $function == "orig") { @@ -347,7 +347,7 @@ function process_input($name, $field) { } return "_binary" . $dbh->quote($file); } else { - return $adminer->processInput($name, $field); + return $adminer->processInput($field, $value, $function); } } diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index cdce3fc3..1779aac6 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Byl překročen maximální povolený počet polí. Zvyšte prosím %s a %s.', '(anywhere)' => '(kdekoliv)', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$6.$4.$1', 'History' => 'Historie', 'Variables' => 'Proměnné', 'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exists.' => 'Zdrojové a cílové sloupce musí mít stejný datový typ, nad cílovými sloupci musí být definován index a odkazovaná data musí existovat.', diff --git a/adminer/lang/de.inc.php b/adminer/lang/de.inc.php index dd5b6860..cb736256 100644 --- a/adminer/lang/de.inc.php +++ b/adminer/lang/de.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Bei Fehler anhaltan', 'Select table' => 'Tabelle auswählen', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$6.$4.$1', 'History' => 'History', 'Variables' => 'Variablen', 'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exists.' => 'Spalten des Ursprungs und des Zieles müssen vom gleichen Datentyp sein, es muss unter den Zielspalten ein Index existieren und die referenzierten Daten müssen existieren.', diff --git a/adminer/lang/es.inc.php b/adminer/lang/es.inc.php index c70b7d53..0430d11d 100644 --- a/adminer/lang/es.inc.php +++ b/adminer/lang/es.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Parar en caso de error', 'Select table' => 'Seleccionar tabla', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$5/$3/$1', 'History' => 'History', 'Variables' => 'Variables', 'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exists.' => 'Las columnas de origen y destino deben ser del mismo tipo, debe existir un índice entre las columnas del destino y el registro referenciado debe existir.', diff --git a/adminer/lang/et.inc.php b/adminer/lang/et.inc.php index ee4614c0..ece41625 100644 --- a/adminer/lang/et.inc.php +++ b/adminer/lang/et.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Peatuda vea esinemisel', 'Select table' => 'Vali tabel', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$6.$4.$1', 'History' => 'Ajalugu', 'Variables' => 'Muutujad', 'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exists.' => 'Lähte- ja sihtveerud peavad eksisteerima ja omama sama andmetüüpi, sihtveergudel peab olema määratud indeks ning viidatud andmed peavad eksisteerima.', diff --git a/adminer/lang/fr.inc.php b/adminer/lang/fr.inc.php index bbb99ffc..f81738d0 100644 --- a/adminer/lang/fr.inc.php +++ b/adminer/lang/fr.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Arrêt sur erreur', 'Select table' => 'Selectionner la table', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$5/$3/$1', 'History' => 'Historique', 'Variables' => 'Variables', 'Source and target columns must have the same data type and there must be an index on the target columns.' => 'Les colonnes selectionnées et les colonnes de destination doivent être du même type et il doit y avoir un index sur les colonnes de destination.', diff --git a/adminer/lang/it.inc.php b/adminer/lang/it.inc.php index 78eb93e3..66145008 100644 --- a/adminer/lang/it.inc.php +++ b/adminer/lang/it.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Stop su errore', 'Select table' => 'Scegli tabella', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$5/$3/$1', 'History' => 'Storico', 'Variables' => 'Variabili', 'Source and target columns must have the same data type and there must be an index on the target columns.' => 'Le colonne sorgente e destinazione devono essere dello stesso tipo e ci deve essere un indice sulla colonna di destinazione.', diff --git a/adminer/lang/nl.inc.php b/adminer/lang/nl.inc.php index 1c200ab6..31d759bc 100644 --- a/adminer/lang/nl.inc.php +++ b/adminer/lang/nl.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => 'Stoppen bij fout', 'Select table' => 'Selecteer tabel', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$5-$3-$1', 'History' => 'Geschiedenis', 'Variables' => 'Variabelen', 'Source and target columns must have the same data type and there must be an index on the target columns.' => 'Bron- en doelkolommen moeten van hetzelfde data type zijn en er moet een index bestaan op de gekozen kolommen.', diff --git a/adminer/lang/ru.inc.php b/adminer/lang/ru.inc.php index d9fa52b0..e515e9a7 100644 --- a/adminer/lang/ru.inc.php +++ b/adminer/lang/ru.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Достигнуто максимальное значение количества доступных полей. Увеличьте %s и %s.', '(anywhere)' => '(в любом месте)', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$5.$3.$1', 'History' => 'История', 'Variables' => 'Переменные', 'Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exists.' => 'Колонки должны иметь одинаковые типы данных, в результирующей колонке должен быть индекс, данные для импорта должны существовать.', diff --git a/adminer/lang/sk.inc.php b/adminer/lang/sk.inc.php index 470c31d1..7d14d54f 100644 --- a/adminer/lang/sk.inc.php +++ b/adminer/lang/sk.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Bol prekročený maximálny počet povolených polí. Zvýšte prosím %s a %s.', '(anywhere)' => '(kdekoľvek)', '%.3f s' => '%.3f s', + '$1-$3-$5' => '$6.$4.$1', 'History' => 'História', 'Variables' => 'Premenné', 'Source and target columns must have the same data type and there must be an index on the target columns.' => 'Zdrojové a cieľové stĺpce musia mať rovnaký dátový typ a nad cieľovými stĺpcami musí byť definovaný index.', diff --git a/adminer/lang/zh.inc.php b/adminer/lang/zh.inc.php index 913930de..d4f24410 100644 --- a/adminer/lang/zh.inc.php +++ b/adminer/lang/zh.inc.php @@ -211,6 +211,7 @@ $translations = array( 'Stop on error' => '出错时停止', 'Select table' => '选择表', '%.3f s' => '%.3f 秒', + '$1-$3-$5' => '$1.$3.$5', 'History' => '历史', 'Variables' => '变量', 'Source and target columns must have the same data type and there must be an index on the target columns.' => '源列和目标列必须具有相同的数据类型并且在目标列的必须是一个索引', diff --git a/adminer/select.inc.php b/adminer/select.inc.php index b0c05e25..7aa5eea7 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -67,7 +67,7 @@ if ($_POST && !$error) { if (!$_POST["delete"]) { $set = array(); foreach ($columns as $name => $val) { //! should check also for edit or insert privileges - $val = process_input($name, $fields[$name]); + $val = process_input($fields[$name]); if ($_POST["clone"]) { $set[] = ($val !== false ? $val : idf_escape($name)); } elseif ($val !== false) { @@ -201,6 +201,7 @@ if (!$columns) { $email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages } $link = ""; + $val = $adminer->editVal($val, $fields[$key]); if (!isset($val)) { $val = "NULL"; } else { diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 0af26e18..20df161c 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -118,6 +118,13 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 return ($link ? "$return" : $return); } + function editVal($val, $field) { + if (ereg('date|timestamp', $field["type"])) { + return preg_replace('~^([0-9]{2}([0-9]+))-(0?([0-9]+))-(0?([0-9]+))~', lang('$1-$3-$5'), $val); + } + return $val; + } + function selectColumnsPrint($select, $columns) { //! allow grouping functions by indexes } @@ -177,11 +184,11 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 } function selectSearchProcess($indexes, $fields) { - global $dbh; $return = array(); foreach ((array) $_GET["where"] as $val) { if (strlen("$val[col]$val[val]")) { - $cond = " = " . $dbh->quote($val["val"]); + $value = $this->processInput($fields[$val["col"]], $val["val"]); + $cond = ($value == "NULL" ? " IS $value" : " = $value"); if (strlen($val["col"])) { $return[] = idf_escape($val["col"]) . $cond; } else { @@ -285,16 +292,9 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 return $return; } - /** Process sent input - * @param string field name - * @param array single field from fields() - * @return string expression to use in a query - */ - function processInput($name, $field) { + function processInput($field, $value, $function = "") { global $dbh; - $idf = bracket_escape($name); - $value = $_POST["fields"][$idf]; - $return = $dbh->quote($value); + $return = $dbh->quote(ereg('date|timestamp', $field["type"]) ? preg_replace_callback('(' . preg_replace('~(\\\\\\$([0-9]))~', '(?P[0-9]+)', preg_quote(lang('$1-$3-$5'))) . ')', 'conversion_date', $value) : $value); if (!ereg('varchar|text', $field["type"]) && !strlen($value)) { $return = "NULL"; } elseif (ereg('date|time', $field["type"]) && $value == "CURRENT_TIMESTAMP") { diff --git a/editor/include/editing.inc.php b/editor/include/editing.inc.php index b3d9bbc7..3c905a4d 100644 --- a/editor/include/editing.inc.php +++ b/editor/include/editing.inc.php @@ -1 +1,4 @@