';
}
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"] && $field["type"] != "enum") {
$id = "null-$name";
echo '';
}
}
function process_input($name, $field) {
global $mysql;
$name = bracket_escape($name);
$value = $_POST["fields"][$name];
if ($field["type"] != "enum" && !$field["auto_increment"] ? $_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) && ($file != UPLOAD_ERR_NO_FILE || !$field["null"])) {
return false; //! report errors
}
return "_binary'" . (is_string($file) ? $mysql->escape_string($file) : "") . "'";
} elseif ($field["type"] == "timestamp" && $value == "CURRENT_TIMESTAMP") {
return $value;
} 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++;
$display = ($_POST["add"][$i-1] || (isset($field["field"]) && !$_POST["drop_col"][$i]));
?>
>
|
" maxlength="64" />" /> |
checked="checked" /> |
checked="checked" /> |
" maxlength="255" /> |
|
"tinyint", "bool" => "tinyint", "boolean" => "tinyint", "integer" => "int", "double precision" => "float", "real" => "float", "dec" => "decimal", "numeric" => "decimal", "fixed" => "decimal", "national char" => "char", "national varchar" => "varchar");
$type_pattern = "([a-z]+)(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
$pattern = "\\s*(" . ($type == "FUNCTION" ? "" : implode("|", $inout)) . ")?\\s*(?:`((?:[^`]+|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern";
$create = $mysql->result($mysql->query("SHOW CREATE $type " . idf_escape($name)), 2);
preg_match("~\\(((?:$pattern\\s*,?)*)\\)" . ($type == "FUNCTION" ? "\\s*RETURNS\\s+$type_pattern" : "") . "\\s*(.*)~is", $create, $match);
$fields = array();
preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER);
foreach ($matches as $i => $param) {
$data_type = strtolower($param[4]);
$fields[$i] = array(
"field" => str_replace("``", "`", $param[2]) . $param[3],
"type" => (isset($aliases[$data_type]) ? $aliases[$data_type] : $data_type),
"length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[5]),
"unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[7] $param[6]"))),
"inout" => strtoupper($param[1]),
"collation" => strtolower($param[8]),
);
}
if ($type != "FUNCTION") {
return array("fields" => $fields, "definition" => $match[10]);
}
$returns = array("type" => $match[10], "length" => $match[11], "unsigned" => $match[13], "collation" => $match[14]);
return array("fields" => $fields, "returns" => $returns, "definition" => $match[15]);
}