2010-10-15 11:26:42 +02:00
|
|
|
<?php
|
2025-03-05 11:28:53 +01:00
|
|
|
namespace Adminer;
|
|
|
|
|
|
2010-10-15 11:26:42 +02:00
|
|
|
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-26 18:54:19 -07:00
|
|
|
foreach (table_status() as $name => $table_status) {
|
2018-02-20 16:02:25 +01:00
|
|
|
json_row("Comment-$name", h($table_status["Comment"]));
|
2011-07-29 16:42:44 +02:00
|
|
|
if (!is_view($table_status)) {
|
2010-10-15 11:26:42 +02:00
|
|
|
foreach (array("Engine", "Collation") as $key) {
|
2018-02-20 16:02:25 +01:00
|
|
|
json_row("$key-$name", h($table_status[$key]));
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
|
|
|
|
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
|
2011-07-29 16:42:44 +02:00
|
|
|
if ($table_status[$key] != "") {
|
2014-03-19 21:56:42 -07:00
|
|
|
$val = format_number($table_status[$key]);
|
2025-03-06 17:08:32 +01:00
|
|
|
if ($val >= 0) {
|
2025-03-06 17:51:20 +01:00
|
|
|
json_row("$key-$name", ($key == "Rows" && $val && $table_status["Engine"] == (JUSH == "pgsql" ? "table" : "InnoDB")
|
2025-03-06 17:08:32 +01:00
|
|
|
? "~ $val"
|
|
|
|
|
: $val
|
|
|
|
|
));
|
|
|
|
|
}
|
2010-10-15 11:26:42 +02:00
|
|
|
if (isset($sums[$key])) {
|
2012-05-16 07:44:44 -07:00
|
|
|
// ignore innodb_file_per_table because it is not active for tables created before it was enabled
|
2011-07-29 16:42:44 +02:00
|
|
|
$sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0);
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
2011-07-29 16:42:44 +02:00
|
|
|
} elseif (array_key_exists($key, $table_status)) {
|
2025-03-13 13:29:10 +01:00
|
|
|
json_row("$key-$name", "?");
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($sums as $key => $val) {
|
2014-03-19 21:56:42 -07:00
|
|
|
json_row("sum-$key", format_number($val));
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
2010-10-19 01:40:49 +02:00
|
|
|
json_row("");
|
2012-08-19 17:12:19 -07:00
|
|
|
|
|
|
|
|
} elseif ($_GET["script"] == "kill") {
|
2014-11-24 18:17:43 -08:00
|
|
|
$connection->query("KILL " . number($_POST["kill"]));
|
2012-08-19 17:12:19 -07:00
|
|
|
|
2010-10-15 11:26:42 +02:00
|
|
|
} else { // connect
|
2012-02-23 22:54:48 -08:00
|
|
|
foreach (count_tables($adminer->databases()) as $db => $val) {
|
2014-03-01 11:38:38 -08:00
|
|
|
json_row("tables-$db", $val);
|
|
|
|
|
json_row("size-$db", db_size($db));
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
2010-10-19 01:40:49 +02:00
|
|
|
json_row("");
|
2010-10-15 11:26:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit; // don't print footer
|