Fixed First Start
This commit is contained in:
+10
-3
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user