1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Separate JavaScript to not wait with Firebug

This commit is contained in:
Jakub Vrana
2010-10-15 11:26:42 +02:00
parent 49565e0563
commit e98c995155
5 changed files with 41 additions and 41 deletions

View File

@@ -38,8 +38,6 @@ if (support("scheme")) {
}
if ($_GET["ns"] !== "") {
echo '<a href="' . h(ME) . 'schema=">' . lang('Database schema') . "</a>\n";
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
echo "<h3>" . lang('Tables and views') . "</h3>\n";
$tables_list = tables_list();
if (!$tables_list) {
@@ -70,7 +68,7 @@ if ($_GET["ns"] !== "") {
echo "<tr><td>&nbsp;<th>" . lang('%d in total', count($tables_list));
echo "<td>" . nbsp($connection->result("SELECT @@storage_engine"));
echo "<td>" . nbsp(db_collation(DB, collations()));
foreach ($sums as $key => $val) {
foreach (array("Data_length", "Index_length", "Data_free") as $key) {
echo "<td align='right' id='sum-$key'>&nbsp;";
}
echo "</table>\n";
@@ -157,33 +155,6 @@ if ($_GET["ns"] !== "") {
}
page_footer();
$table_status = table_status();
if ($table_status) {
echo "<script type='text/javascript'>\n";
foreach ($table_status as $row) {
$id = addcslashes($row["Name"], "\\'/");
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
if (!is_view($row)) {
foreach (array("Engine", "Collation") as $key) {
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
}
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
if ($row[$key] != "") {
$val = number_format($row[$key], 0, '.', lang(','));
echo "setHtml('$key-$id', '" . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "');\n";
if (isset($sums[$key])) {
$sums[$key] += ($row["Engine"] != "InnoDB" || $key != "Data_free" ? $row[$key] : 0);
}
} elseif (array_key_exists($key, $row)) {
echo "setHtml('$key-$id');\n";
}
}
}
}
foreach ($sums as $key => $val) {
echo "setHtml('sum-$key', '" . number_format($val, 0, '.', lang(',')) . "');\n";
}
echo "</script>\n";
}
echo "<script type='text/javascript' src='" . h(ME) . "script=db'></script>\n";
exit; // page_footer() already called
}

View File

@@ -44,17 +44,13 @@ function connect_error() {
}
}
page_footer("db");
echo "<script type='text/javascript'>\n";
foreach (count_tables($databases) as $db => $val) {
echo "setHtml('tables-" . addcslashes($db, "\\'/") . "', '$val');\n";
}
echo "</script>\n";
echo "<script type='text/javascript' src='" . h(ME) . "script=connect'></script>\n";
}
if (isset($_GET["status"])) {
$_GET["variables"] = $_GET["status"];
}
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"]))) {
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")) {
if (DB != "") {
set_session("dbs", null);
}

View File

@@ -86,8 +86,4 @@ function page_footer($missing = "") {
<?php $adminer->navigation($missing); ?>
</div>
<?php
// don't wait for code after footer
session_write_close();
ob_flush();
flush();
}

View File

@@ -66,6 +66,8 @@ if (isset($_GET["download"])) {
include "./select.inc.php";
} elseif (isset($_GET["variables"])) {
include "./variables.inc.php";
} elseif (isset($_GET["script"])) {
include "./script.inc.php";
} else {
include "./db.inc.php";
}

35
adminer/script.inc.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
header("Content-Type: text/javascript; charset=utf-8");
if ($_GET["script"] == "db") {
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
foreach (table_status() as $row) {
$id = addcslashes($row["Name"], "\\'/");
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
if (!is_view($row)) {
foreach (array("Engine", "Collation") as $key) {
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
}
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
if ($row[$key] != "") {
$val = number_format($row[$key], 0, '.', lang(','));
echo "setHtml('$key-$id', '" . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "');\n";
if (isset($sums[$key])) {
$sums[$key] += ($row["Engine"] != "InnoDB" || $key != "Data_free" ? $row[$key] : 0);
}
} elseif (array_key_exists($key, $row)) {
echo "setHtml('$key-$id');\n";
}
}
}
}
foreach ($sums as $key => $val) {
echo "setHtml('sum-$key', '" . number_format($val, 0, '.', lang(',')) . "');\n";
}
} else { // connect
foreach (count_tables(get_databases()) as $db => $val) {
echo "setHtml('tables-" . addcslashes($db, "\\'/") . "', '$val');\n";
}
}
exit; // don't print footer