diff --git a/pandora_console/include/lib/Core/Config.php b/pandora_console/include/lib/Core/Config.php index 4891cabcce..620c63f84a 100644 --- a/pandora_console/include/lib/Core/Config.php +++ b/pandora_console/include/lib/Core/Config.php @@ -72,18 +72,19 @@ final class Config $config['history_db_port'], false ); + + if ($config['history_db_connection'] !== false) { + $data = \db_get_all_rows_sql( + 'SELECT * FROM `tconfig`', + false, + false, + $config['history_db_connection'] + ); + } + ob_get_clean(); } - ob_start(); - $data = \db_get_all_rows_sql( - 'SELECT * FROM `tconfig`', - false, - false, - $config['history_db_connection'] - ); - ob_get_clean(); - if (is_array($data) !== true) { return []; } @@ -119,6 +120,8 @@ final class Config if (isset(self::$settings[$token]) === true) { return self::$settings[$token]; } + + return $default; } else { global $config; diff --git a/pandora_console/include/lib/Core/DBMaintainer.php b/pandora_console/include/lib/Core/DBMaintainer.php index 685ca1b126..8b3fc75bab 100644 --- a/pandora_console/include/lib/Core/DBMaintainer.php +++ b/pandora_console/include/lib/Core/DBMaintainer.php @@ -230,12 +230,14 @@ final class DBMaintainer $results = []; - do { - $row = $rs->fetch_array(MYSQLI_ASSOC); - if ((bool) $row !== false) { - $results[] = $row; - } - } while ((bool) $row !== false); + if ($rs !== false) { + do { + $row = $rs->fetch_array(MYSQLI_ASSOC); + if ((bool) $row !== false) { + $results[] = $row; + } + } while ((bool) $row !== false); + } return $results; } @@ -412,6 +414,10 @@ final class DBMaintainer return true; } + if ($this->dbh === null) { + return false; + } + $rc = $this->dbh->query( sprintf( 'CREATE DATABASE %s', @@ -503,7 +509,7 @@ final class DBMaintainer return false; } - if ($this->install() !== true) { + if ($this->install($check_only) !== true) { return false; } @@ -564,7 +570,7 @@ final class DBMaintainer } } - if ($this->applyDump($filename) !== true) { + if ($this->applyDump($filename, true) !== true) { $err = 'Unable to apply MR update #'; $err .= $last_mr_curr.': '; $this->lastError = $err.$this->lastError; @@ -630,6 +636,23 @@ final class DBMaintainer } + /** + * Checks if target is ready to connect. + * + * @return boolean + */ + public function isReady() + { + if ($this->ready === true) { + return true; + } + + $this->connect(); + + return $this->ready; + } + + /** * Checks if current target is connected, installed and updated. * @@ -657,29 +680,37 @@ final class DBMaintainer /** * This function keeps same functionality as install.php:parse_mysqli_dump. * - * @param string $path Path where SQL dump file is stored. + * @param string $path Path where SQL dump file is stored. + * @param boolean $transactional Use transactions from file (true) (MRs). * * @return boolean Success or not. */ - private function applyDump(string $path) + private function applyDump(string $path, bool $transactional=false) { if (file_exists($path) === true) { - $file_content = file($path); - $query = ''; - foreach ($file_content as $sql_line) { - if (trim($sql_line) !== '' - && strpos($sql_line, '-- ') === false - ) { - $query .= $sql_line; - if ((bool) preg_match("/;[\040]*\$/", $sql_line) === true) { - $result = $this->dbh->query($query); - if ((bool) $result === false) { - $this->lastError = $this->dbh->errno.': '; - $this->lastError .= $this->dbh->error; - return false; - } + if ($transactional === true) { + global $config; + // MR are loaded in transactions. + include_once $config['homedir'].'/include/db/mysql.php'; + return db_run_sql_file($path); + } else { + $file_content = file($path); + $query = ''; + foreach ($file_content as $sql_line) { + if (trim($sql_line) !== '' + && strpos($sql_line, '-- ') === false + ) { + $query .= $sql_line; + if ((bool) preg_match("/;[\040]*\$/", $sql_line) === true) { + $result = $this->dbh->query($query); + if ((bool) $result === false) { + $this->lastError = $this->dbh->errno.': '; + $this->lastError .= $this->dbh->error; + return false; + } - $query = ''; + $query = ''; + } } } } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 12f5825a8f..aff419a62a 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -603,6 +603,11 @@ select:-internal-list-box { .flex-nowrap { flex-wrap: nowrap; } + +.flex-evenly { + justify-content: space-evenly; +} + .flex-row-baseline { display: flex; flex-direction: row; diff --git a/pandora_console/include/styles/setup.css b/pandora_console/include/styles/setup.css index 5c7b304772..c7f9ededaf 100644 --- a/pandora_console/include/styles/setup.css +++ b/pandora_console/include/styles/setup.css @@ -18,3 +18,7 @@ input[type="text"], input[type="number"] { width: 220px; } + +.fit > tbody > tr > td img { + width: 15px; +}