'text/css', 'js' => 'application/javascript', 'svg' => 'image/svg+xml', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'ico' => 'image/x-icon', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'json' => 'application/json', 'map' => 'application/json', ]; // Determine which asset directory to serve from $assetFile = null; /** * /themes//assets/...: theme-asset matchen en pad oplossen. * * @since 2.6.4 */ // /themes//assets/... if (preg_match('#^/themes/([^/]+)/assets/(.+)$#', $path, $m)) { $themeName = $m[1]; $assetRel = $m[2]; $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//assets/...: plugin-asset matchen en pad oplossen. * * @since 2.6.4 */ // /plugins//assets/... elseif (preg_match('#^/plugins/([^/]+)/assets/(.+)$#', $path, $m)) { $pluginName = $m[1]; $assetRel = $m[2]; $assetFile = $basePath . '/plugins/' . $pluginName . '/assets/' . $assetRel; $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)) { $ext = strtolower(pathinfo($realFile, PATHINFO_EXTENSION)); if (isset($mimeTypes[$ext])) { header('Content-Type: ' . $mimeTypes[$ext]); } header('Cache-Control: public, max-age=86400'); readfile($realFile); exit; } } http_response_code(404); header('Content-Type: text/plain'); echo '404 Not Found';