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();
}
+12 -4
View File
@@ -5,14 +5,22 @@
switch($env){
/*------ DON'T TOUCH THIS PART ------ */
case "generic":
$doc_root = !empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : dirname(__DIR__);
define('WEB_ROOT', $doc_root);
$app_dir = str_replace('\\', '/', dirname(__DIR__));
$doc_root = !empty($_SERVER['DOCUMENT_ROOT']) ? str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']) : '';
$base_url_path = '';
if (!empty($doc_root) && strpos($app_dir, $doc_root) === 0) {
$base_url_path = substr($app_dir, strlen($doc_root));
}
$base_url_path = rtrim(str_replace('\\', '/', $base_url_path), '/');
$host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
define('DOMAIN', $host);
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
define('FULL_DOMAIN', $protocol . DOMAIN);
define("ROOT_URL", $protocol . DOMAIN );
define("ROOT_DIR", rtrim(WEB_ROOT, '/') . "/");
define("ROOT_URL", $protocol . DOMAIN . $base_url_path);
define("ROOT_DIR", $app_dir . "/");
define('WEB_ROOT', ROOT_DIR);
break;
/* ----------------------------------- */
default:
+2 -2
View File
@@ -8,8 +8,8 @@ $db_needed="yes";
$db_debug="yes";
$db_host="localhost";
$db_name="sld_blocknotes_db";
$db_user="root";
$db_pass="";
$db_user="simone";
$db_pass="Angela";
//-------------------------------------------------------------------------------------
// --- DON'T CHANGE ALL THE CODE BELOW!!! ---