Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie

This commit is contained in:
2026-08-27 08:57:05 +00:00
parent 6485f693dc
commit 74612aefbb
55 changed files with 6019 additions and 876 deletions
+35
View File
@@ -1,4 +1,16 @@
<?php
/**
* Asset-server voor productie: serveert statische bestanden uit themes/,
* admin/theme/ en plugins/.
*
* Dit bestand wordt op productie gebruikt wanneer de PHP-dev-router niet
* beschikbaar is. public/.htaccess herschrijft /themes/, /admin/assets/ en
* /plugins/ URLs naar dit bestand. Paden worden via realpath() + prefix-
* check afgedwongen binnen de juiste asset-map om path traversal te voorkomen.
*
* @since 2.6.4
* @package CodePress
*/
/**
* Asset server - serves static files from themes/, admin/theme/, and plugins/
* This file is used on production servers where the PHP router is not available.
@@ -25,6 +37,11 @@ $mimeTypes = [
// Determine which asset directory to serve from
$assetFile = null;
/**
* /themes/<naam>/assets/...: theme-asset matchen en pad oplossen.
*
* @since 2.6.4
*/
// /themes/<name>/assets/...
if (preg_match('#^/themes/([^/]+)/assets/(.+)$#', $path, $m)) {
$themeName = $m[1];
@@ -32,12 +49,22 @@ if (preg_match('#^/themes/([^/]+)/assets/(.+)$#', $path, $m)) {
$assetFile = $basePath . '/themes/' . $themeName . '/assets/' . $assetRel;
$realBase = realpath($basePath . '/themes/' . $themeName . '/assets');
}
/**
* /admin/assets/...: admin-theme-asset matchen (default admin theme).
*
* @since 2.6.4
*/
// /admin/assets/...
elseif (preg_match('#^/admin/assets/(.+)$#', $path, $m)) {
$assetRel = $m[1];
$assetFile = $basePath . '/admin/theme/default/assets/' . $assetRel;
$realBase = realpath($basePath . '/admin/theme/default/assets');
}
/**
* /plugins/<naam>/assets/...: plugin-asset matchen en pad oplossen.
*
* @since 2.6.4
*/
// /plugins/<name>/assets/...
elseif (preg_match('#^/plugins/([^/]+)/assets/(.+)$#', $path, $m)) {
$pluginName = $m[1];
@@ -46,6 +73,14 @@ elseif (preg_match('#^/plugins/([^/]+)/assets/(.+)$#', $path, $m)) {
$realBase = realpath($basePath . '/plugins/' . $pluginName . '/assets');
}
/**
* Matchende asset uitleveren met juiste MIME en cache-headers.
*
* Controleert dat het opgeloste pad binnen de asset-map blijft en een
* regulier bestand is; anders volgt een 404.
*
* @since 2.6.4
*/
if ($assetFile && $realBase) {
$realFile = realpath($assetFile);
if ($realFile && strpos($realFile, $realBase) === 0 && is_file($realFile)) {