Refactor configuration loading: Updated multiple public PHP files to require a new bootstrap file for configuration management. Adjusted paths for product configuration to enhance maintainability and consistency across the application.

This commit is contained in:
smueller
2026-05-22 13:58:30 +02:00
parent ec8686761c
commit 96a5977283
19 changed files with 151 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = '404 - Seite nicht gefunden | HexaHost.de';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = '500 - Serverfehler | HexaHost.de';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'Über mich - HexaHost.de | Hosting aus Niederbayern';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'Allgemeine Geschäftsbedingungen - HexaHost.de | AGB';

41
public/bootstrap.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
/**
* HexaHost Bootstrap für Monorepo- und Produktions-Layout
*
* Monorepo: public/../backend/{includes,config}
* Produktion: public/{includes,config} (nach Backend-Kopie)
*/
if (!defined('HEXAHOST_BOOTSTRAPPED')) {
$pathCandidates = [
[
'includes' => __DIR__ . '/includes',
'config' => __DIR__ . '/config',
],
[
'includes' => __DIR__ . '/../backend/includes',
'config' => __DIR__ . '/../backend/config',
],
];
$resolved = false;
foreach ($pathCandidates as $paths) {
if (is_file($paths['includes'] . '/functions.php')) {
define('HEXAHOST_INCLUDES_DIR', $paths['includes']);
define('HEXAHOST_CONFIG_DIR', $paths['config']);
require_once $paths['includes'] . '/functions.php';
$resolved = true;
break;
}
}
if (!$resolved) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo 'HexaHost: Anwendung konnte nicht gestartet werden (includes nicht gefunden).';
exit;
}
define('HEXAHOST_BOOTSTRAPPED', true);
}

View File

@@ -9,8 +9,10 @@ if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Konfiguration laden
require_once 'config/mail-config.php';
require_once __DIR__ . '/bootstrap.php';
$configDir = defined('HEXAHOST_CONFIG_DIR') ? HEXAHOST_CONFIG_DIR : __DIR__ . '/config';
require_once $configDir . '/mail-config.php';
// PHPMailer Autoload (falls via Composer installiert)
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
@@ -43,13 +45,8 @@ function validateCSRFToken($token) {
return false;
}
// CORS Headers für AJAX-Requests (nur eigene Domain erlauben)
$allowed_origins = [
'https://hexahost.de',
'https://www.hexahost.de',
'http://localhost', // Für Entwicklung
'http://127.0.0.1' // Für Entwicklung
];
// CORS Headers für AJAX-Requests (nur eigene Domains erlauben)
$allowed_origins = getAllowedOrigins();
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
if (in_array($origin, $allowed_origins)) {

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Page configuration
$page_title = 'Kontakt - HexaHost.de | Hosting aus Niederbayern';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'Datenschutzerklärung - HexaHost.de | Datenschutz';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'Impressum - HexaHost.de | Rechtliche Angaben';
@@ -23,7 +23,7 @@ includeHeader($page_title, $page_description, $current_page);
?>
<h1 class="legal-hero-title">Impressum</h1>
<p class="legal-hero-description">
Rechtliche Angaben und Pflichtinformationen gemäß § 5 DDG
</p>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Page configuration
$page_title = 'HexaHost.de - Zuverlässiges Hosting aus Niederbayern';

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'IT-Dienstleistungen - HexaHost.de | Privat & Gewerblich';

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Produkt-Daten aus Config laden
$product = getProduct('mail-gateway');

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Produkt-Daten aus Config laden
$product = getProduct('vpc');

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Produkt-Daten aus Config laden
$product = getProduct('vps');

View File

@@ -1,6 +1,6 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/../backend/config/products-config.php';
require_once __DIR__ . '/bootstrap.php';
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
// Produkt-Daten aus Config laden
$product = getProduct('webhosting');

View File

@@ -1,5 +1,5 @@
<?php
require_once __DIR__ . '/../backend/includes/functions.php';
require_once __DIR__ . '/bootstrap.php';
// Page configuration
$page_title = 'Widerrufsbelehrung - HexaHost.de';