]> git.joonet.de Git - adminer.git/commitdiff
Separate JavaScript to not wait with Firebug
authorJakub Vrana <jakub@vrana.cz>
Fri, 15 Oct 2010 09:26:42 +0000 (11:26 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 15 Oct 2010 09:26:42 +0000 (11:26 +0200)
adminer/db.inc.php
adminer/include/connect.inc.php
adminer/include/design.inc.php
adminer/index.php
adminer/script.inc.php [new file with mode: 0644]

index a07da0259fa27097accd689e31b1668c70e1e05c..20944c96f106ca7a31c3e45ee7b49b2e7801b591 100644 (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
 }
index ffa2b13770068e7725b83bf92dbda60da335bac9..242f1a89ef5f2f696964946fc52252ceafe7bc1a 100644 (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);
        }
index 68ae314fc8232d478388b7f580724b5500f6274c..621ec5bc6d92dc5b91e23f1ae8a0748398bb6bf3 100644 (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();
 }
index bff57f0103006dc2dd6be1de2370681502c401de..40c849a7f13a29a4d582c01d0d0528d2d1378d71 100644 (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";
 }
diff --git a/adminer/script.inc.php b/adminer/script.inc.php
new file mode 100644 (file)
index 0000000..d60f89c
--- /dev/null
@@ -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