echo "</form>\n"; } } page_footer("db"); } if (isset($_GET["status"])) { $_GET["variables"] = $_GET["status"]; } if (isset($_GET["import"])) { $_GET["sql"] = $_GET["import"]; } 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(); set_session("dbs", null); } connect_error(); // separate function to catch SQLite error exit; } if (support("scheme") && DB != "" && $_GET["ns"] !== "") { if (!isset($_GET["ns"])) { redirect(preg_replace('~ns=[^&]*&~', '', ME) . "ns=" . get_schema()); } if (!set_schema($_GET["ns"])) { header("HTTP/1.1 404 Not Found"); page_header(lang('Schema') . ": " . h($_GET["ns"]), lang('Invalid schema.'), true); page_footer("ns"); exit; } }
/** Prints databases list in menu * @param string * @return null */ function databasesPrint($missing) { global $adminer, $connection; $databases = $this->databases(); ?> <form action=""> <p id="dbs"> <?php hidden_fields_get(); $db_events = " onmousedown='dbMouseDown(event, this);' onchange='dbChange(this);'"; echo "<span title='" . lang('database') . "'>DB</span>: " . ($databases ? "<select name='db'{$db_events}>" . optionlist(array("" => "") + $databases, DB) . "</select>" : '<input name="db" value="' . h(DB) . '" autocapitalize="off">'); echo "<input type='submit' value='" . lang('Use') . "'" . ($databases ? " class='hidden'" : "") . ">\n"; if ($missing != "db" && DB != "" && $connection->select_db(DB)) { if (support("scheme")) { echo "<br>" . lang('Schema') . ": <select name='ns'{$db_events}>" . optionlist(array("" => "") + $adminer->schemas(), $_GET["ns"]) . "</select>"; if ($_GET["ns"] != "") { set_schema($_GET["ns"]); } } } echo isset($_GET["sql"]) ? '<input type="hidden" name="sql" value="">' : (isset($_GET["schema"]) ? '<input type="hidden" name="schema" value="">' : (isset($_GET["dump"]) ? '<input type="hidden" name="dump" value="">' : (isset($_GET["privileges"]) ? '<input type="hidden" name="privileges" value="">' : ""))); echo "</p></form>\n"; }
/** Prints navigation after Adminer title * @param string can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema * @return null */ function navigation($missing) { global $VERSION, $connection, $token, $jush, $drivers; ?> <h1> <?php echo $this->name(); ?> <span class="version"><?php echo $VERSION; ?> </span> <a href="http://www.adminer.org/#download" id="version"><?php echo version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""; ?> </a> </h1> <?php if ($missing == "auth") { $first = true; foreach ((array) $_SESSION["pwds"] as $driver => $servers) { foreach ($servers as $server => $usernames) { foreach ($usernames as $username => $password) { if (isset($password)) { if ($first) { echo "<p onclick='eventStop(event);'>\n"; $first = false; } echo "<a href='" . h(auth_url($driver, $server, $username)) . "'>({$drivers[$driver]}) " . h($username . ($server != "" ? "@{$server}" : "")) . "</a><br>\n"; } } } } } else { $databases = get_databases(); ?> <form action="" method="post"> <p class="logout"> <?php if (DB == "" || !$missing) { echo "<a href='" . h(ME) . "sql='" . bold(isset($_GET["sql"])) . ">" . lang('SQL command') . "</a>\n"; if (support("dump")) { echo "<a href='" . h(ME) . "dump=" . urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]) . "' id='dump'" . bold(isset($_GET["dump"])) . ">" . lang('Dump') . "</a>\n"; } } ?> <input type="submit" name="logout" value="<?php echo lang('Logout'); ?> " onclick="eventStop(event);"> <input type="hidden" name="token" value="<?php echo $token; ?> "> </p> </form> <form action=""> <p> <?php hidden_fields_get(); echo $databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">'; ?> <input type="submit" value="<?php echo lang('Use'); ?> "<?php echo $databases ? " class='hidden'" : ""; ?> onclick="eventStop(event);"> <?php if ($missing != "db" && DB != "" && $connection->select_db(DB)) { if (support("scheme")) { echo "<br>" . html_select("ns", array("" => "(" . lang('schema') . ")") + schemas(), $_GET["ns"], "this.form.submit();"); if ($_GET["ns"] != "") { set_schema($_GET["ns"]); } } if ($_GET["ns"] !== "" && !$missing) { echo '<p><a href="' . h(ME) . 'create="' . bold($_GET["create"] === "") . ">" . lang('Create new table') . "</a>\n"; $tables = tables_list(); if (!$tables) { echo "<p class='message'>" . lang('No tables.') . "\n"; } else { $this->tablesPrint($tables); $links = array(); foreach ($tables as $table => $type) { $links[] = preg_quote($table, '/'); } echo "<script type='text/javascript'>\n"; echo "var jushLinks = { {$jush}: [ '" . js_adminer_escape(ME) . "table=\$&', /\\b(" . implode("|", $links) . ")\\b/g ] };\n"; foreach (array("bac", "bra", "sqlite_quo", "mssql_bra") as $val) { echo "jushLinks.{$val} = jushLinks.{$jush};\n"; } echo "</script>\n"; } } } echo isset($_GET["sql"]) ? '<input type="hidden" name="sql" value="">' : (isset($_GET["schema"]) ? '<input type="hidden" name="schema" value="">' : (isset($_GET["dump"]) ? '<input type="hidden" name="dump" value="">' : "")); echo "</p></form>\n"; } }