query("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once if (isset($_POST["truncate"])) { if ($_POST["tables"]) { foreach ($_POST["tables"] as $table) { if (!queries("TRUNCATE " . idf_escape($table))) { $result = false; break; } } $message = lang('Tables have been truncated.'); } } elseif (isset($_POST["move"])) { $rename = array(); foreach ($tables_views as $table) { $rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table); } $result = queries("RENAME TABLE " . implode(", ", $rename)); $message = lang('Tables have been moved.'); } elseif ((!isset($_POST["drop"]) || !$_POST["views"] || queries("DROP VIEW " . implode(", ", array_map('idf_escape', $_POST["views"])))) && (!$_POST["tables"] || ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"]))))) ) { if (isset($_POST["drop"])) { $message = lang('Tables have been dropped.'); } else { while ($row = $result->fetch_assoc()) { $message .= htmlspecialchars("$row[Table]: $row[Msg_text]") . "
"; } } } query_redirect(queries(), substr($SELF, 0, -1), $message, $result, false, !$result); } page_header(lang('Database') . ": " . htmlspecialchars($_GET["db"]), $error, false); echo '

' . lang('Alter database') . "

\n"; echo '

' . lang('Database schema') . "

\n"; echo "

" . lang('Tables and views') . "

\n"; $result = $dbh->query("SHOW TABLE STATUS"); if (!$result->num_rows) { echo "

" . lang('No tables.') . "

\n"; } else { echo "
\n"; echo "\n"; echo '\n"; while ($row = $result->fetch_assoc()) { $name = $row["Name"]; table_comment($row); echo ''; if (isset($row["Rows"])) { echo '"; foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) { $val = number_format($row[$key], 0, '.', lang(',')); echo ''; } echo ""; } else { echo ''; } echo "\n"; } echo "
' . lang('Table') . '' . lang('Engine') . '' . lang('Collation') . '' . lang('Data Length') . '' . lang('Index Length') . '' . lang('Data Free') . '' . lang('Auto Increment') . '' . lang('Rows') . '' . lang('Comment') . "
' . htmlspecialchars($name) . "$row[Engine]$row[Collation]' . (strlen($row[$key]) ? '' . str_replace(" ", " ", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '' : ' ') . '" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "' . htmlspecialchars($name) . '' . lang('View') . '
\n"; echo "

\n"; $dbs = get_databases(); if (count($dbs) != 1) { $db = (isset($_POST["target"]) ? $_POST["target"] : $_GET["db"]); echo "

" . lang('Move to other database') . ($dbs ? ": " : ': ') . "

\n"; } echo "
\n"; } $result->free(); if ($dbh->server_info >= 5) { echo '

' . lang('Create view') . "

\n"; echo "

" . lang('Routines') . "

\n"; $result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = '" . $dbh->escape_string($_GET["db"]) . "'"); if ($result->num_rows) { echo "\n"; while ($row = $result->fetch_assoc()) { echo ""; echo ""; echo ''; echo '"; echo "\n"; } echo "
" . htmlspecialchars($row["ROUTINE_TYPE"]) . "' . htmlspecialchars($row["ROUTINE_NAME"]) . '' . lang('Alter') . "
\n"; } $result->free(); echo '

' . lang('Create procedure') . ' ' . lang('Create function') . "

\n"; } if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) { echo "

" . lang('Events') . "

\n"; if ($result->num_rows) { echo "\n"; echo "\n"; while ($row = $result->fetch_assoc()) { echo ""; echo '"; echo ""; echo ""; echo "\n"; } echo "
" . lang('Name') . "" . lang('Schedule') . "" . lang('Start') . "" . lang('End') . "
' . htmlspecialchars($row["Name"]) . "" . ($row["Execute at"] ? lang('At given time') . "" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "$row[Starts]") . "$row[Ends]
\n"; } $result->free(); echo '

' . lang('Create event') . "

\n"; }