Exemplo n.º 1
0
    /** 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";
    }
Exemplo n.º 2
0
$set = null;
if (isset($rights["insert"])) {
    $set = "";
    foreach ((array) $_GET["where"] as $val) {
        if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "=" || !$val["op"] && !ereg('[_%]', $val["val"]))) {
            $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
        }
    }
}
$adminer->selectLinks($table_status, $set);
if (!$columns) {
    echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "." : ": " . error()) . "\n";
} else {
    echo "<form action='' id='form'>\n";
    echo "<div style='display: none;'>";
    hidden_fields_get();
    echo DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' . (isset($_GET["ns"]) ? '<input type="hidden" name="ns" value="' . h($_GET["ns"]) . '">' : "") : "";
    // not used in Editor
    echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
    echo "</div>\n";
    $adminer->selectColumnsPrint($select, $columns);
    $adminer->selectSearchPrint($where, $columns, $indexes);
    $adminer->selectOrderPrint($order, $columns, $indexes);
    $adminer->selectLimitPrint($limit);
    $adminer->selectLengthPrint($text_length);
    $adminer->selectActionPrint($indexes);
    echo "</form>\n";
    $page = $_GET["page"];
    if ($page == "last") {
        $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : ""));
        $page = floor(max(0, $found_rows - 1) / $limit);
Exemplo n.º 3
0
    /** 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";
        }
    }