diff --git a/db.inc.php b/db.inc.php new file mode 100644 index 00000000..50f378fe --- /dev/null +++ b/db.inc.php @@ -0,0 +1,105 @@ +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()) { + 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($row["Name"]) . "$row[Engine]$row[Collation]' . (strlen($row[$key]) ? '' . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val) . '' : ' ') . '" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "' . htmlspecialchars($row["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"; +} diff --git a/index.php b/index.php index 02b52737..d2e6a4ad 100644 --- a/index.php +++ b/index.php @@ -127,110 +127,7 @@ if (isset($_GET["download"])) { } elseif (isset($_GET["select"])) { include "./select.inc.php"; } else { - if ($_POST["tables"] && !$error) { - $result = true; - $message = ""; - if (isset($_POST["truncate"])) { - 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 ($_POST["tables"] 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 ($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()) { - table_comment($row); - 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') . "
'; - if (isset($row["Rows"])) { - echo '' . htmlspecialchars($row["Name"]) . "$row[Engine]$row[Collation]' . (strlen($row[$key]) ? '' . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val) . '' : ' ') . '" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "' . htmlspecialchars($row["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"; - } + include "./db.inc.php"; } } page_footer();