diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index c639896e..12b37a6d 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -88,7 +88,7 @@ if (!ini_bool("session.use_cookies") || @ini_set("session.use_cookies", false) ! session_write_close(); // improves concurrency if a user opens several pages at once, may be restarted later } -include "./include/connect.inc.php"; include "./include/editing.inc.php"; +include "./include/connect.inc.php"; $on_actions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; ///< @var string used in foreign_keys() diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index 5bfe947e..298f6579 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -1,7 +1,6 @@ \n"; echo "\n"; - echo "" . (support("database") ? "\n"; + echo "" + . (support("database") ? "\n" + ; - foreach ($databases as $db) { + $databases = ($_GET["dbsize"] ? count_tables($databases) : array_flip($databases)); + + foreach ($databases as $db => $tables) { $root = h(ME) . "db=" . urlencode($db); echo "" . (support("database") ? "
 " : "") . "" . lang('Database') . "" . lang('Collation') . "" . lang('Tables') . "
 " : "") + . "" . lang('Database') + . "" . lang('Collation') + . "" . lang('Tables') + . "" . lang('Size') . " - " . lang('Compute') . "" + . "
" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"])) : ""); echo "" . h($db) . ""; $collation = nbsp(db_collation($db, $collations)); echo "" . (support("database") ? "$collation" : $collation); - echo "?"; + echo "" . ($_GET["dbsize"] ? $tables : "?") . ""; + echo "" . ($_GET["dbsize"] ? db_size($db) : "?"); echo "\n"; } @@ -59,9 +68,6 @@ function connect_error() { } page_footer("db"); - if ($databases) { - echo "\n"; - } } if (isset($_GET["status"])) { diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index b5d7024c..76e4aa2e 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -505,3 +505,19 @@ function ob_gzencode($string) { // ob_start() callback recieves an optional parameter $phase but gzencode() accepts optional parameter $level return gzencode($string); } + +/** Compute size of database +* @param string +* @return string formatted +*/ +function db_size($db) { + global $connection; + if (!$connection->select_db($db)) { + return "?"; + } + $return = 0; + foreach (table_status() as $table_status) { + $return += $table_status["Data_length"] + $table_status["Index_length"]; + } + return number_format($return, 0, '.', lang(',')); +} diff --git a/adminer/include/version.inc.php b/adminer/include/version.inc.php index 2c5973a8..5a236e59 100644 --- a/adminer/include/version.inc.php +++ b/adminer/include/version.inc.php @@ -1,2 +1,2 @@ 'Výchozí hodnoty', 'Drop' => 'Odstranit', 'Are you sure?' => 'Opravdu?', + 'Size' => 'Velikost', + 'Compute' => 'Spočítat', 'Move up' => 'Přesunout nahoru', 'Move down' => 'Přesunout dolů', 'Remove' => 'Odebrat', diff --git a/adminer/lang/xx.inc.php b/adminer/lang/xx.inc.php index 5e989f50..f7bfc8d1 100644 --- a/adminer/lang/xx.inc.php +++ b/adminer/lang/xx.inc.php @@ -165,6 +165,8 @@ $translations = array( 'Default values' => 'xx', 'Drop' => 'xx', 'Are you sure?' => 'xx', + 'Size' => 'xx', + 'Compute' => 'xx', 'Move up' => 'xx', 'Move down' => 'xx', 'Remove' => 'xx', diff --git a/adminer/script.inc.php b/adminer/script.inc.php index 099c47bb..ab850c5f 100644 --- a/adminer/script.inc.php +++ b/adminer/script.inc.php @@ -37,7 +37,8 @@ if ($_GET["script"] == "db") { } else { // connect foreach (count_tables($adminer->databases()) as $db => $val) { - json_row("tables-" . js_escape($db), $val); + json_row("tables-$db", $val); + json_row("size-$db", db_size($db)); } json_row(""); } diff --git a/changes.txt b/changes.txt index 8abfbee1..df665bb7 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,6 @@ -Adminer 4.0.4-dev: +Adminer 4.1.0-dev: +Provide size of all databases in the overview +Compute number of tables in the overview explicitly Display edit form after error in clone or multi-edit Display time of the select command Improve gzip export ratio (bug #387)