Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuratie-loader voor CodePress CMS.
|
||||
*
|
||||
* Laadt config.json (of maakt deze aan op basis van config.json.example of
|
||||
* een ingebouwde standaardconfiguratie), voegt ontbrekende secties
|
||||
* (security, analytics, logging) samen met defaults, converteert relatieve
|
||||
* content_dir-paden naar absoluut, laadt de actieve theme-configuratie en
|
||||
* returnt de uiteindelijke configuratie-array. Bij falen volgt een
|
||||
* minimale fallback-configuratie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @package CodePress
|
||||
*/
|
||||
|
||||
// Simple configuration loader
|
||||
$configJsonPath = __DIR__ . '/../../config.json';
|
||||
$configExamplePath = __DIR__ . '/../../config.json.example';
|
||||
|
||||
/**
|
||||
* config.json automatisch aanmaken als deze nog niet bestaat.
|
||||
*
|
||||
* Kopieert config.json.example indien aanwezig; anders wordt een ingebouwde
|
||||
* standaardconfiguratie weggeschreven.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
// Auto-create config.json if it does not exist
|
||||
if (!file_exists($configJsonPath)) {
|
||||
if (file_exists($configExamplePath)) {
|
||||
@@ -83,6 +104,15 @@ if (!file_exists($configJsonPath)) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* config.json inladen en ontbrekende secties aanvullen met defaults.
|
||||
*
|
||||
* Voegt default-waarden samen voor security, analytics en logging,
|
||||
* garandeert de excluded_ips-standaardlijst en converteert relatieve
|
||||
* content_dir-paden naar absoluut.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
if (file_exists($configJsonPath)) {
|
||||
$jsonContent = file_get_contents($configJsonPath);
|
||||
$config = json_decode($jsonContent, true);
|
||||
@@ -150,6 +180,11 @@ if (file_exists($configJsonPath)) {
|
||||
$config['content_dir'] = $projectRoot . $config['content_dir'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Actieve theme-configuratie laden vanuit theme.json.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
// Load active theme
|
||||
$activeTheme = $config['active_theme'] ?? 'default';
|
||||
$themeDir = __DIR__ . '/../../themes/' . $activeTheme;
|
||||
@@ -166,6 +201,11 @@ if (file_exists($configJsonPath)) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimale fallback-configuratie wanneer config.json niet geladen kon worden.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
// Fallback to minimal config
|
||||
return [
|
||||
'site_title' => 'CodePress',
|
||||
|
||||
Reference in New Issue
Block a user