adminerevo/adminer/script.inc.php

46 lines
1.5 KiB
PHP
Raw Normal View History

<?php
header("Content-Type: text/javascript; charset=utf-8");
if ($_GET["script"] == "db") {
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
2013-04-27 01:54:19 +00:00
foreach (table_status() as $name => $table_status) {
json_row("Comment-$name", h($table_status["Comment"]));
2011-07-29 14:42:44 +00:00
if (!is_view($table_status)) {
foreach (array("Engine", "Collation") as $key) {
json_row("$key-$name", h($table_status[$key]));
}
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
2011-07-29 14:42:44 +00:00
if ($table_status[$key] != "") {
2014-03-20 04:56:42 +00:00
$val = format_number($table_status[$key]);
2023-07-10 20:08:15 +00:00
json_row("$key-$name", ($key == "Rows" && $val && $table_status["Engine"] == ($jush == "pgsql" ? "table" : "InnoDB")
? "~ $val"
: $val
));
if (isset($sums[$key])) {
2012-05-16 14:44:44 +00:00
// ignore innodb_file_per_table because it is not active for tables created before it was enabled
2011-07-29 14:42:44 +00:00
$sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0);
}
2011-07-29 14:42:44 +00:00
} elseif (array_key_exists($key, $table_status)) {
json_row("$key-$name");
}
}
}
}
foreach ($sums as $key => $val) {
2014-03-20 04:56:42 +00:00
json_row("sum-$key", format_number($val));
}
json_row("");
2012-08-20 00:12:19 +00:00
} elseif ($_GET["script"] == "kill") {
$connection->query("KILL " . number($_POST["kill"]));
2012-08-20 00:12:19 +00:00
} else { // connect
2012-02-24 06:54:48 +00:00
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