Exemple #1
0
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>&nbsp;" : "") . "<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 ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>{$collation}</a>" : $collation);
                echo "<td align='right'><a href='{$root}&amp;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");
}
Exemple #2
0
            }
            foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
                if ($table_status[$key] != "") {
                    $val = format_number($table_status[$key]);
                    json_row("{$key}-{$id}", $key == "Rows" && $val && $table_status["Engine"] == ($sql == "pgsql" ? "table" : "InnoDB") ? "~ {$val}" : $val);
                    if (isset($sums[$key])) {
                        // ignore innodb_file_per_table because it is not active for tables created before it was enabled
                        $sums[$key] += $table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0;
                    }
                } elseif (array_key_exists($key, $table_status)) {
                    json_row("{$key}-{$id}");
                }
            }
        }
    }
    foreach ($sums as $key => $val) {
        json_row("sum-{$key}", format_number($val));
    }
    json_row("");
} elseif ($_GET["script"] == "kill") {
    $connection->query("KILL " . +$_POST["kill"]);
} else {
    // connect
    foreach (count_tables($adminer->databases()) as $db => $val) {
        json_row("tables-{$db}", $val);
        json_row("size-{$db}", db_size($db));
    }
    json_row("");
}
exit;
// don't print footer
        json_row("Comment-{$id}", nbsp($table_status["Comment"]));
        if (!is_view($table_status)) {
            foreach (array("Engine", "Collation") as $key) {
                json_row("{$key}-{$id}", nbsp($table_status[$key]));
            }
            foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
                if ($table_status[$key] != "") {
                    $val = number_format($table_status[$key], 0, '.', lang(','));
                    json_row("{$key}-{$id}", $key == "Rows" && $table_status["Engine"] == "InnoDB" && $val ? "~ {$val}" : $val);
                    if (isset($sums[$key])) {
                        $sums[$key] += $table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0;
                    }
                } elseif (array_key_exists($key, $table_status)) {
                    json_row("{$key}-{$id}");
                }
            }
        }
    }
    foreach ($sums as $key => $val) {
        json_row("sum-{$key}", number_format($val, 0, '.', lang(',')));
    }
    json_row("");
} else {
    // connect
    foreach (count_tables(get_databases()) as $db => $val) {
        json_row("tables-" . js_adminer_escape($db), $val);
    }
    json_row("");
}
exit;
// don't print footer