From dfaa8ba7a887260583491a8362dac8541d038d7e Mon Sep 17 00:00:00 2001 From: Niek Rabelink Date: Wed, 9 Sep 2026 17:58:19 +0200 Subject: [PATCH] Make config.php environment-aware with smart host detection, normalize .gitattributes, and use dynamic APP_URL in Outlook integrations --- .gitattributes | 15 ++++++++++- config/config.php | 39 ++++++++++++++++++++--------- includes/integrations/microsoft.php | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.gitattributes b/.gitattributes index d8b7520..3a5cf25 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,16 @@ -# Zorg dat omgevingsspecifieke bestanden nooit worden overschreven bij merges tussen dev en main +# Automatische detectie van tekstbestanden en consistente line endings (LF) +* text=auto eol=lf +# Binaire bestanden +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.pdf binary +*.woff binary +*.woff2 binary +# Sluit repository metadata uit bij release archieven +.gitattributes export-ignore +.gitignore export-ignore diff --git a/config/config.php b/config/config.php index 5b66f5f..de59fb6 100644 --- a/config/config.php +++ b/config/config.php @@ -69,22 +69,37 @@ if (!function_exists('fociz_env')) { } // ========================================================================= -// 2. CENTRALE DATABASE CONFIGURATIE (DE ENIGE BRON VAN WAARHEID) -// ========================================================================= -define('DB_HOST', fociz_env('DB_HOST', '192.168.2.33')); -define('DB_PORT', fociz_env('DB_PORT', '3306')); -define('DB_NAME', fociz_env('DB_NAME', 'fociz')); -define('DB_USER', fociz_env('DB_USER', 'focizlive_user')); -define('DB_PASS', fociz_env('DB_PASS', 'F0c1z_Live_Secure_2026!')); -define('DB_CHARSET', 'utf8mb4'); - -// ========================================================================= -// 3. APPLICATIE INSTELLINGEN & OMGEVING +// 2. APPLICATIE INSTELLINGEN & OMGEVINGSDETECTIE // ========================================================================= define('APP_NAME', 'Fociz'); -define('APP_ENV', fociz_env('APP_ENV', 'live')); // 'live' of 'development' + +// Automatische omgevingsdetectie: +// 1. Expliciete .env variabele 'APP_ENV' +// 2. Automatisch 'development' indien hostname 'dev.' of 'localhost' bevat +// 3. Standaard 'live' +$detectedHost = $_SERVER['HTTP_HOST'] ?? ''; +$isDevHost = ( + str_contains($detectedHost, 'dev.') || + str_contains($detectedHost, 'localhost') || + str_contains($detectedHost, '127.0.0.1') +); +$defaultEnv = $isDevHost ? 'development' : 'live'; +define('APP_ENV', fociz_env('APP_ENV', $defaultEnv)); define('APP_SECRET', fociz_env('APP_SECRET', 'fociz-maria-db-super-secret-key-998877')); +// ========================================================================= +// 3. CENTRALE DATABASE CONFIGURATIE (OMGEVINGSAFHANKELIJK & GIT-VEILIG) +// ========================================================================= +// Leest eerst eventuele .env variabelen (die per server uniek en gitignored zijn). +// Indien niet ingesteld via .env, wordt automatisch de juiste database gekozen op basis van APP_ENV. +$isDevEnv = (APP_ENV === 'development'); +define('DB_HOST', fociz_env('DB_HOST', '192.168.2.33')); +define('DB_PORT', fociz_env('DB_PORT', '3306')); +define('DB_NAME', fociz_env('DB_NAME', $isDevEnv ? 'focizdev' : 'fociz')); +define('DB_USER', fociz_env('DB_USER', $isDevEnv ? 'focizdev_user' : 'focizlive_user')); +define('DB_PASS', fociz_env('DB_PASS', $isDevEnv ? 'F0c1z_Dev_Secure_2026!' : 'F0c1z_Live_Secure_2026!')); +define('DB_CHARSET', 'utf8mb4'); + // Bepaal de dynamische of geconfigureerde applicatie URL if (!function_exists('fociz_detect_app_url')) { function fociz_detect_app_url(): string { diff --git a/includes/integrations/microsoft.php b/includes/integrations/microsoft.php index 59f54fb..04479be 100644 --- a/includes/integrations/microsoft.php +++ b/includes/integrations/microsoft.php @@ -475,7 +475,7 @@ function microsoft_create_event(int $userId, array $eventData): array { 'subject' => $subject, 'body' => [ 'contentType' => 'HTML', - 'content' => nl2br(htmlspecialchars($description)) . '

Aangemaakt via Fociz Dagplanning', + 'content' => nl2br(htmlspecialchars($description)) . '

Aangemaakt via Fociz Dagplanning', ], 'start' => [ 'dateTime' => $startDateTimeStr,