Fixed First Start

This commit is contained in:
2026-08-20 09:02:05 +01:00
parent a2f36b6fac
commit 1ea31362c4
5 changed files with 54 additions and 20 deletions
+10 -3
View File
@@ -4,7 +4,9 @@ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// Check if first_start.php installer file exists and database setup is needed
$first_start_path = ROOT_DIR . "first_start.php";
if (file_exists($first_start_path) && basename($_SERVER['SCRIPT_FILENAME'] ?? '') !== 'first_start.php') {
$first_start_completed = file_exists(ROOT_DIR . "first_start.php.completed") || file_exists(ROOT_DIR . "config/installed.lock");
if (file_exists($first_start_path) && !$first_start_completed && basename($_SERVER['SCRIPT_FILENAME'] ?? '') !== 'first_start.php') {
// Check connection first
try {
$test_conn = @new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
@@ -93,11 +95,16 @@ try {
}
} catch (mysqli_sql_exception $e) {
if (file_exists($first_start_path) && basename($_SERVER['SCRIPT_FILENAME'] ?? '') !== 'first_start.php') {
if (file_exists($first_start_path) && !$first_start_completed && basename($_SERVER['SCRIPT_FILENAME'] ?? '') !== 'first_start.php') {
header("Location: first_start.php");
exit;
}
include(PAGES_FOLD . "db-error.php");
$pages_fold = defined('PAGES_FOLD') ? PAGES_FOLD : ROOT_DIR . "pages/";
if (file_exists($pages_fold . "db-error.php")) {
include($pages_fold . "db-error.php");
} else {
echo "Database connection error: " . htmlspecialchars($e->getMessage());
}
debugStatusMes("Database setup error: " . $e->getMessage(), "High");
die();
}