$field) { if (strlen($field["name"]) && in_array($field["type"], $types)) { $length = ($field["length"] ? "(" . intval($field["length"]) . ")" : ""); //! decimal, enum and set lengths $fields[] = idf_escape($field["name"]) . " " . $field["type"] . $length . ($field["not_null"] ? " NOT NULL" : "") . ($field["auto_increment"] ? " AUTO_INCREMENT" : ""); } } $status = ($_POST["Engine"] ? " ENGINE='" . mysql_real_escape_string($_POST["Engine"]) . "'" : "") . ($_POST["Collation"] ? " COLLATE '" . mysql_real_escape_string($_POST["Collation"]) . "'" : ""); if (strlen($_GET["create"])) { $query = "ALTER TABLE " . idf_escape($_GET["create"]) . " RENAME TO " . idf_escape($_POST["name"]) . ", $status"; $message = lang('Table has been altered.'); } else { $query = "CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(", ", $fields) . ")$status"; $message = lang('Table has been created.'); } } if (mysql_query($query)) { redirect(($_POST["drop"] ? substr($SELF, 0, -1) : $SELF . "table=" . urlencode($_POST["name"])), $message); } $error = mysql_error(); } page_header(strlen($_GET["create"]) ? lang('Alter table') . ': ' . htmlspecialchars($_GET["create"]) : lang('Create table')); echo "
" . lang('Unable to operate table') . ": " . htmlspecialchars($error) . "
\n"; $row = $_POST; } elseif (strlen($_GET["create"])) { $row = mysql_fetch_assoc(mysql_query("SHOW TABLE STATUS LIKE '" . mysql_real_escape_string($_GET["create"]) . "'")); $row["name"] = $_GET["create"]; $row["fields"] = array(); $result1 = mysql_query("SHOW COLUMNS FROM " . idf_escape($_GET["create"])); while ($row1 = mysql_fetch_assoc($result1)) { if (preg_match('~^([^)]*)\\((.*)\\)$~', $row1["Type"], $match)) { $row1["Type"] = $match[1]; $row1["Length"] = $match[2]; } $row["fields"][] = $row1; } mysql_free_result($result1); } else { $row = array("fields" => array()); } //! collate columns, references, indexes, unsigned, default ?>