diff --git a/edit.inc.php b/edit.inc.php index df229ef3..621c0da2 100644 --- a/edit.inc.php +++ b/edit.inc.php @@ -14,33 +14,10 @@ if ($_POST && !$error) { } else { $set = array(); foreach ($fields as $name => $field) { - $key = bracket_escape($name); - $val = $_POST["fields"][$key]; - if (preg_match('~char|text|set|binary|blob~', $field["type"]) ? $_POST["null"][$key] : !strlen($val)) { - $val = "NULL"; - } elseif ($field["type"] == "enum") { - $val = (isset($_GET["default"]) && preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches) ? "'" . $matches[1][$val-1] . "'" : intval($val)); - } elseif ($field["type"] == "set") { - if (!isset($_GET["default"])) { - $val = array_sum((array) $val); - } else { - preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches); - $value = array(); - foreach ((array) $val as $key => $v) { - $value[] = $matches[1][$key]; - } - $val = "'" . implode(",", $value) . "'"; - } - } elseif (preg_match('~binary|blob~', $field["type"])) { - $file = get_file($key); - if (!is_string($file) && !$field["null"]) { - continue; //! report errors, also empty $_POST - not only because of file upload - } - $val = "_binary'" . (is_string($file) ? mysql_real_escape_string($file) : "") . "'"; - } else { - $val = "'" . mysql_real_escape_string($val) . "'"; + $val = process_input($name, $field); + if ($val !== false) { + $set[] = idf_escape($name) . (isset($_GET["default"]) ? ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val") : " = $val"); } - $set[] = idf_escape($name) . (isset($_GET["default"]) ? ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val") : " = $val"); } if (isset($_GET["default"])) { $query = "ALTER TABLE " . idf_escape($_GET["edit"]) . " ALTER " . implode(", ALTER ", $set); @@ -78,54 +55,27 @@ if ($_POST) { unset($data); } ?> +