2010-10-15 09:26:42 +00:00
|
|
|
<?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) {
|
2015-01-12 17:46:53 +00:00
|
|
|
json_row("Comment-$name", nbsp($table_status["Comment"]));
|
2011-07-29 14:42:44 +00:00
|
|
|
if (!is_view($table_status)) {
|
2010-10-15 09:26:42 +00:00
|
|
|
foreach (array("Engine", "Collation") as $key) {
|
2015-01-12 17:46:53 +00:00
|
|
|
json_row("$key-$name", nbsp($table_status[$key]));
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
|
|
|
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]);
|
2015-01-12 17:46:53 +00:00
|
|
|
json_row("$key-$name", ($key == "Rows" && $val && $table_status["Engine"] == ($sql == "pgsql" ? "table" : "InnoDB")
|
2012-07-29 17:45:38 +00:00
|
|
|
? "~ $val"
|
|
|
|
: $val
|
|
|
|
));
|
2010-10-15 09:26:42 +00:00
|
|
|
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);
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
2011-07-29 14:42:44 +00:00
|
|
|
} elseif (array_key_exists($key, $table_status)) {
|
2015-01-12 17:46:53 +00:00
|
|
|
json_row("$key-$name");
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($sums as $key => $val) {
|
2014-03-20 04:56:42 +00:00
|
|
|
json_row("sum-$key", format_number($val));
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
2010-10-18 23:40:49 +00:00
|
|
|
json_row("");
|
2012-08-20 00:12:19 +00:00
|
|
|
|
|
|
|
} elseif ($_GET["script"] == "kill") {
|
2014-11-25 02:17:43 +00:00
|
|
|
$connection->query("KILL " . number($_POST["kill"]));
|
2012-08-20 00:12:19 +00:00
|
|
|
|
2018-01-24 13:15:55 +00:00
|
|
|
} elseif ($_GET["script"] == "version") {
|
|
|
|
$fp = file_open_lock(get_temp_dir() . "/adminer.version");
|
|
|
|
if ($fp) {
|
2018-01-24 14:10:44 +00:00
|
|
|
file_write_unlock($fp, serialize(array("signature" => $_POST["signature"], "version" => $_POST["version"])));
|
2018-01-24 13:15:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 09:26:42 +00:00
|
|
|
} else { // connect
|
2012-02-24 06:54:48 +00:00
|
|
|
foreach (count_tables($adminer->databases()) as $db => $val) {
|
2014-03-01 19:38:38 +00:00
|
|
|
json_row("tables-$db", $val);
|
|
|
|
json_row("size-$db", db_size($db));
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
2010-10-18 23:40:49 +00:00
|
|
|
json_row("");
|
2010-10-15 09:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit; // don't print footer
|