function navigation($missing) {
global $SELF, $dbh;
if ($missing != "auth") {
- ob_flush();
- flush();
$databases = get_databases();
?>
<form action="" method="post">
return $dbh->error;
}
-function get_databases() {
+function get_databases($flush = true) {
// SHOW DATABASES can take a very long time so it is cached
$return = &$_SESSION["databases"][$_GET["server"]];
if (!isset($return)) {
$return = get_vals("SHOW DATABASES");
+ if ($flush) {
+ ob_flush();
+ flush();
+ }
}
return $return;
}
if ($_POST && !$error) {
$where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")";
- $primary = null; // empty array means that all primary fields are selected
- foreach ($indexes as $index) {
- if ($index["type"] == "PRIMARY") {
- $primary = ($select ? array_flip($index["columns"]) : array());
- }
- }
+ $primary = ($indexes["PRIMARY"] ? ($select ? array_flip($indexes["PRIMARY"]["columns"]) : array()) : null); // empty array means that all primary fields are selected
foreach ($select as $key => $val) {
$val = $_GET["columns"][$key];
if (!$val["fun"]) {
if (strlen($name)) {
$order++;
$names[$key] = $name;
- echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>";
+ echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! order by function can collide with column name like min(`id`)
}
next($select);
}
}
function database() {
- $dbs = get_databases();
+ $dbs = get_databases(false);
return (count($dbs) == 1 ? $dbs[0] : (count($dbs) == 2 && information_schema($dbs[0]) ? $dbs[1] : 'test'));
}
}
function selectOrderProcess($columns, $select, $indexes) {
- return ($_GET["order"]
- ? array(idf_escape($_GET["order"][0]) . (isset($_GET["desc"][0]) ? " DESC" : ""))
- : $indexes[$_GET["index_order"]]["columns"]
- );
+ if ($_GET["order"]) {
+ return array(idf_escape($_GET["order"][0]) . (isset($_GET["desc"][0]) ? " DESC" : ""));
+ }
+ if ($_GET["index_order"]) {
+ return $indexes[$_GET["index_order"]]["columns"];
+ }
+ unset($indexes["PRIMARY"]);
+ $index = reset($indexes);
+ return ($index ? $index["columns"] : array());
}
function selectLimitProcess() {