'; } 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 : $value === $val); //! '' collide with NULL in $_GET["default"] echo ' '; } if ($field["null"]) { $id = "field-$name-"; echo ' '; } } 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 ' '; } } elseif (strpos($field["type"], "text") !== false) { echo ''; } elseif (preg_match('~binary|blob~', $field["type"])) { echo (ini_get("file_uploads") ? '' : lang('File uploads are disabled.') . ' '); } else { echo ''; } if ($field["null"] && preg_match('~char|text|set|binary|blob~', $field["type"])) { $id = "null-$name"; echo ''; } } function process_input($name, $field) { global $mysql; $name = bracket_escape($name); $value = $_POST["fields"][$name]; if (preg_match('~char|text|set|binary|blob~', $field["type"]) ? $_POST["null"][$name] : !strlen($value)) { return "NULL"; } elseif ($field["type"] == "enum") { return (isset($_GET["default"]) ? "'" . $mysql->escape_string($value) . "'" : intval($value)); } elseif ($field["type"] == "set") { return (isset($_GET["default"]) ? "'" . implode(",", array_map(array($mysql, 'escape_string'), (array) $value)) . "'" : array_sum((array) $value)); } elseif (preg_match('~binary|blob~', $field["type"])) { $file = get_file($name); if (!is_string($file) && !$field["null"]) { return false; //! report errors, also empty $_POST (too big POST data, not only FILES) } return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'"; } else { return "'" . $mysql->escape_string($value) . "'"; } } function edit_type($key, $field, $collations) { global $types, $unsigned, $inout; ?> " size="3" /> escape_string($field["collation"]) . "'" : "") ; } function edit_fields($fields, $collations, $type = "TABLE") { global $inout; ?> $field) { $i++; ?> " />" maxlength="64" /> checked="checked" /> checked="checked" /> " maxlength="255" /> result($mysql->query("SHOW CREATE $type " . idf_escape($name)), 2); preg_match("~\\(($pattern(?:\\s*,$pattern)*)\\)" . ($type == "FUNCTION" ? "\\s*RETURNS\\s+$type_pattern" : "") . "\\s*(.*)~is", $create, $match); $fields = array(); preg_match_all("~$pattern~is", $match[1], $matches, PREG_SET_ORDER); foreach ($matches as $i => $param) { $fields[$i] = array( "field" => str_replace("``", "`", $param[2]) . $param[3], "type" => $param[4], //! type aliases "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[5]), "unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[7] $param[6]"))), "null" => true, "inout" => strtoupper($param[1]), //! detect character set ); } if ($type != "FUNCTION") { return array("fields" => $fields, "definition" => $match[16]); } $returns = array( "type" => $match[16], "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $match[17]), "unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$match[19] $match[18]"))), ); return array("fields" => $fields, "returns" => $returns, "definition" => $match[20]); }