function connect_error() { global $adminer, $connection, $token, $error, $drivers; if (DB != "") { header("HTTP/1.1 404 Not Found"); page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true); } else { if ($_POST["db"] && !$error) { queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"])); } //Encabezado y botones de la parte superior en la seleccion de bases de datos page_header(lang('Select database'), $error, false); echo "<p>\n"; foreach (array('database' => lang('Create new database'), 'privileges' => lang('Privileges'), 'processlist' => lang('Process list'), 'variables' => lang('Variables'), 'status' => lang('Status')) as $key => $val) { if (support($key)) { echo "<a class='btn btn-xs btn-primary' href='" . h(ME) . "{$key}='>{$val}</a>\n"; } } //Presenta informacion de la conexion echo "<p><i class='fa fa-exchange fa-fw'></i> " . lang('%s version: %s through PHP extension %s', $drivers[DRIVER], "<b>" . h($connection->server_info) . "</b>", "<b>{$connection->extension}</b>") . "\n"; echo "<p><i class='fa fa-user fa-fw'></i> " . lang('Logged as: %s', "<b>" . h(logged_user()) . "</b>") . "\n"; //Presenta la lista de bases de datos existentes y los encabezados $databases = $adminer->databases(); if ($databases) { $scheme = support("scheme"); $collations = collations(); echo "<form action='' method='post'>\n"; echo "<table cellspacing='0' class='checkable table table-condensed table-responsive table-hover' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n"; echo "<thead><tr>" . (support("database") ? "<th> " : "") . "<th>" . lang('Database') . " - <a class='btn btn-default btn-xs' href='" . h(ME) . "refresh=1'><i class='fa fa-refresh fa-fw'></i> " . lang('Refresh') . "</a>" . "<th>" . lang('Collation') . "<th>" . lang('Tables') . "<th>" . lang('Size') . " - <a class='btn btn-default btn-xs' href='" . h(ME) . "dbsize=1' onclick=\"return !ajaxSetHtml('" . js_escape(ME) . "script=connect');\">" . lang('Compute') . "</a>" . "</thead>\n"; //Presenta la lista de bases de datos $databases = $_GET["dbsize"] ? count_tables($databases) : array_flip($databases); foreach ($databases as $db => $tables) { $root = h(ME) . "db=" . urlencode($db); echo "<tr" . odd() . ">" . (support("database") ? "\n\t\t\t\t\t<td align=center>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"])) : ""); echo "<th><a href='{$root}'>" . h($db) . "</a>"; $collation = nbsp(db_collation($db, $collations)); echo "<td>" . (support("database") ? "<a href='{$root}" . ($scheme ? "&ns=" : "") . "&database=' title='" . lang('Alter database') . "'>{$collation}</a>" : $collation); echo "<td align='right'><a href='{$root}&schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>" . ($_GET["dbsize"] ? $tables : "?") . "</a>"; echo "<td align='right' id='size-" . h($db) . "'>" . ($_GET["dbsize"] ? db_size($db) : "?"); echo "\n"; } echo "</table>\n"; //Agrega boton de eliminar echo support("database") ? "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>\n" . "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^db/));\">\n" . "<input class='btn btn-xs btn-danger' type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n" . "</div></fieldset>\n" : ""; echo "<script type='text/javascript'>tableCheck();</script>\n"; echo "<input type='hidden' name='token' value='{$token}'>\n"; echo "</form>\n"; } } page_footer("db"); }
function connect_error() { global $connection, $token, $error, $drivers; $databases = array(); if (DB != "") { page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true); } else { if ($_POST["db"] && !$error) { queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"])); } page_header(lang('Select database'), $error, false); echo "<p><a href='" . h(ME) . "database='>" . lang('Create new database') . "</a>\n"; foreach (array('privileges' => lang('Privileges'), 'processlist' => lang('Process list'), 'variables' => lang('Variables'), 'status' => lang('Status')) as $key => $val) { if (support($key)) { echo "<a href='" . h(ME) . "{$key}='>{$val}</a>\n"; } } echo "<p>" . lang('%s version: %s through PHP extension %s', $drivers[DRIVER], "<b>{$connection->server_info}</b>", "<b>{$connection->extension}</b>") . "\n"; echo "<p>" . lang('Logged as: %s', "<b>" . h(logged_user()) . "</b>") . "\n"; if ($_GET["refresh"]) { set_session("dbs", null); } $databases = get_databases(); if ($databases) { $scheme = support("scheme"); $collations = collations(); echo "<form action='' method='post'>\n"; echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);'>\n"; echo "<thead><tr><td> <th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n"; foreach ($databases as $db) { $root = h(ME) . "db=" . urlencode($db); echo "<tr" . odd() . "><td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"])); echo "<th><a href='{$root}'>" . h($db) . "</a>"; echo "<td><a href='{$root}" . ($scheme ? "&ns=" : "") . "&database=' title='" . lang('Alter database') . "'>" . nbsp(db_collation($db, $collations)) . "</a>"; echo "<td align='right'><a href='{$root}&schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>?</a>"; echo "\n"; } echo "</table>\n"; echo "<script type='text/javascript'>tableCheck();</script>\n"; echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n"; // 1 - eventStop echo "<input type='hidden' name='token' value='{$token}'>\n"; echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n"; echo "</form>\n"; } } page_footer("db"); if ($databases) { echo "<script type='text/javascript'>ajaxSetHtml('" . js_adminer_escape(ME) . "script=connect');</script>\n"; } }
foreach ($orig_fields as $field) { $field["has_default"] = isset($field["default"]); $row["fields"][] = $field; } if (support("partitioning")) { $from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($TABLE); $result = $connection->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION {$from} ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1"); list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row(); $partitions = get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION {$from} AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION"); $partitions[""] = ""; $row["partition_names"] = array_keys($partitions); $row["partition_values"] = array_values($partitions); } } } $collations = collations(); $engines = engines(); // case of engine may differ foreach ($engines as $engine) { if (!strcasecmp($engine, $row["Engine"])) { $row["Engine"] = $engine; break; } } ?> <form action="" method="post" id="form"> <p> <?php if (support("columns") || $TABLE == "") { echo lang('Table name');
echo '<th>' . (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name)); if ($view) { echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . (preg_match('~materialized~i', $type) ? lang('Materialized View') : lang('View')) . '</a>'; echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>'; } else { foreach (array("Engine" => array(), "Collation" => array(), "Data_length" => array("create", lang('Alter table')), "Index_length" => array("indexes", lang('Alter indexes')), "Data_free" => array("edit", lang('New item')), "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), "Rows" => array("select", lang('Select data'))) as $key => $link) { $id = " id='{$key}-" . h($name) . "'"; echo $link ? "<td align='right'>" . (support("table") || $key == "Rows" || support("indexes") && $key != "Data_length" ? "<a href='" . h(ME . "{$link['0']}=") . urlencode($name) . "'{$id} title='{$link['1']}'>?</a>" : "<span{$id}>?</span>") : "<td id='{$key}-" . h($name) . "'> "; } $tables++; } echo support("comment") ? "<td id='Comment-" . h($name) . "'> " : ""; } echo "<tr><td> <th>" . lang('%d in total', count($tables_list)); echo "<td>" . nbsp($jush == "sql" ? $connection->result("SELECT @@storage_engine") : ""); echo "<td>" . nbsp(db_collation(DB, collations())); foreach (array("Data_length", "Index_length", "Data_free") as $key) { echo "<td align='right' id='sum-{$key}'> "; } echo "</table>\n"; if (!information_schema(DB)) { $vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("'VACUUM'") . "> "; $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'" . on_help($jush == "sql" ? "'OPTIMIZE TABLE'" : "'VACUUM OPTIMIZE'") . "> "; echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>" . ($jush == "sqlite" ? $vacuum : ($jush == "pgsql" ? $vacuum . $optimize : ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'" . on_help("'ANALYZE TABLE'") . "> " . $optimize . "<input type='submit' name='check' value='" . lang('Check') . "'" . on_help("'CHECK TABLE'") . "> " . "<input type='submit' name='repair' value='" . lang('Repair') . "'" . on_help("'REPAIR TABLE'") . "> " : ""))) . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . "> " . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . on_help("'DROP TABLE'") . ">\n"; $databases = support("scheme") ? $adminer->schemas() : $adminer->databases(); if (count($databases) != 1 && $jush != "sqlite") { $db = isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB); echo "<p>" . lang('Move to other database') . ": "; echo $databases ? html_select("target", $databases, $db) : '<input name="target" value="' . h($db) . '" autocapitalize="off">'; echo " <input type='submit' name='move' value='" . lang('Move') . "'>"; echo support("copy") ? " <input type='submit' name='copy' value='" . lang('Copy') . "'>" : "";