2007-07-02 05:51:26 +00:00
|
|
|
<?php
|
2009-05-29 20:30:16 +00:00
|
|
|
function connect_error() {
|
2012-02-24 06:54:48 +00:00
|
|
|
global $adminer, $connection, $token, $error, $drivers;
|
2010-04-21 12:01:32 +00:00
|
|
|
$databases = array();
|
2010-01-09 23:33:41 +00:00
|
|
|
if (DB != "") {
|
2013-06-24 12:23:14 +00:00
|
|
|
header("HTTP/1.1 404 Not Found");
|
2010-04-21 12:01:32 +00:00
|
|
|
page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true);
|
2007-07-02 20:21:30 +00:00
|
|
|
} else {
|
2009-10-18 09:29:01 +00:00
|
|
|
if ($_POST["db"] && !$error) {
|
2010-04-23 09:05:30 +00:00
|
|
|
queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"]));
|
2009-10-18 09:29:01 +00:00
|
|
|
}
|
|
|
|
|
2010-04-21 12:01:32 +00:00
|
|
|
page_header(lang('Select database'), $error, false);
|
2013-07-06 17:31:21 +00:00
|
|
|
echo "<p class='links'>\n";
|
2009-06-21 23:35:27 +00:00
|
|
|
foreach (array(
|
2013-07-06 17:31:21 +00:00
|
|
|
'database' => lang('Create new database'),
|
2009-06-21 23:35:27 +00:00
|
|
|
'privileges' => lang('Privileges'),
|
|
|
|
'processlist' => lang('Process list'),
|
|
|
|
'variables' => lang('Variables'),
|
2010-01-08 10:07:08 +00:00
|
|
|
'status' => lang('Status'),
|
2009-06-21 23:35:27 +00:00
|
|
|
) as $key => $val) {
|
2010-04-21 12:01:32 +00:00
|
|
|
if (support($key)) {
|
|
|
|
echo "<a href='" . h(ME) . "$key='>$val</a>\n";
|
|
|
|
}
|
2009-06-21 23:35:27 +00:00
|
|
|
}
|
2010-04-21 12:01:32 +00:00
|
|
|
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";
|
2012-02-24 06:54:48 +00:00
|
|
|
$databases = $adminer->databases();
|
2009-10-18 09:29:01 +00:00
|
|
|
if ($databases) {
|
2010-10-17 23:53:31 +00:00
|
|
|
$scheme = support("scheme");
|
2009-10-18 09:29:01 +00:00
|
|
|
$collations = collations();
|
|
|
|
echo "<form action='' method='post'>\n";
|
2012-10-04 07:42:56 +00:00
|
|
|
echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
|
2013-07-06 17:31:21 +00:00
|
|
|
echo "<thead><tr>" . (support("database") ? "<td> " : "") . "<th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n";
|
2013-05-02 01:28:04 +00:00
|
|
|
|
2009-10-18 09:29:01 +00:00
|
|
|
foreach ($databases as $db) {
|
|
|
|
$root = h(ME) . "db=" . urlencode($db);
|
2013-07-06 17:31:21 +00:00
|
|
|
echo "<tr" . odd() . ">" . (support("database") ? "<td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"])) : "");
|
2009-10-18 09:29:01 +00:00
|
|
|
echo "<th><a href='$root'>" . h($db) . "</a>";
|
2013-07-06 17:31:21 +00:00
|
|
|
$collation = nbsp(db_collation($db, $collations));
|
|
|
|
echo "<td>" . (support("database") ? "<a href='$root" . ($scheme ? "&ns=" : "") . "&database=' title='" . lang('Alter database') . "'>$collation</a>" : $collation);
|
2011-08-10 16:33:50 +00:00
|
|
|
echo "<td align='right'><a href='$root&schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>?</a>";
|
2009-10-18 09:29:01 +00:00
|
|
|
echo "\n";
|
|
|
|
}
|
2013-05-02 01:28:04 +00:00
|
|
|
|
2009-10-18 09:29:01 +00:00
|
|
|
echo "</table>\n";
|
2013-07-11 23:57:16 +00:00
|
|
|
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" // used by trCheck()
|
2013-07-12 00:02:14 +00:00
|
|
|
. "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n"
|
2013-07-11 23:57:16 +00:00
|
|
|
. "</div></fieldset>\n"
|
|
|
|
: ""
|
|
|
|
);
|
2011-08-11 11:48:27 +00:00
|
|
|
echo "<script type='text/javascript'>tableCheck();</script>\n";
|
2011-03-08 12:43:05 +00:00
|
|
|
echo "<input type='hidden' name='token' value='$token'>\n";
|
2009-10-18 09:29:01 +00:00
|
|
|
echo "</form>\n";
|
|
|
|
}
|
2013-07-11 23:57:16 +00:00
|
|
|
echo "<p><a href='" . h(ME) . "refresh=1'>" . lang('Refresh') . "</a>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
2013-05-02 01:28:04 +00:00
|
|
|
|
2007-07-06 08:47:20 +00:00
|
|
|
page_footer("db");
|
2010-10-17 23:48:27 +00:00
|
|
|
if ($databases) {
|
2010-11-26 09:59:16 +00:00
|
|
|
echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=connect');</script>\n";
|
2010-10-17 23:48:27 +00:00
|
|
|
}
|
2009-05-29 20:30:16 +00:00
|
|
|
}
|
|
|
|
|
2010-01-08 10:07:08 +00:00
|
|
|
if (isset($_GET["status"])) {
|
|
|
|
$_GET["variables"] = $_GET["status"];
|
|
|
|
}
|
2013-08-02 18:45:55 +00:00
|
|
|
if (isset($_GET["import"])) {
|
|
|
|
$_GET["sql"] = $_GET["import"];
|
|
|
|
}
|
|
|
|
|
2012-08-20 00:12:19 +00:00
|
|
|
if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]) || $_GET["script"] == "connect" || $_GET["script"] == "kill")) {
|
|
|
|
if (DB != "" || $_GET["refresh"]) {
|
|
|
|
restart_session();
|
2010-10-15 08:58:08 +00:00
|
|
|
set_session("dbs", null);
|
2009-05-29 20:30:16 +00:00
|
|
|
}
|
2009-06-21 23:20:32 +00:00
|
|
|
connect_error(); // separate function to catch SQLite error
|
2007-07-02 05:51:26 +00:00
|
|
|
exit;
|
|
|
|
}
|
2010-05-05 16:30:55 +00:00
|
|
|
|
2010-10-18 00:15:58 +00:00
|
|
|
if (support("scheme") && DB != "" && $_GET["ns"] !== "") {
|
|
|
|
if (!isset($_GET["ns"])) {
|
|
|
|
redirect(preg_replace('~ns=[^&]*&~', '', ME) . "ns=" . get_schema());
|
|
|
|
}
|
|
|
|
if (!set_schema($_GET["ns"])) {
|
2013-06-24 12:23:14 +00:00
|
|
|
header("HTTP/1.1 404 Not Found");
|
2010-10-18 00:15:58 +00:00
|
|
|
page_header(lang('Schema') . ": " . h($_GET["ns"]), lang('Invalid schema.'), true);
|
|
|
|
page_footer("ns");
|
|
|
|
exit;
|
|
|
|
}
|
2010-05-05 16:30:55 +00:00
|
|
|
}
|