mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 08:28:43 +00:00
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:
68
backend/config/site-config.php
Normal file
68
backend/config/site-config.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* HexaHost.de – zentrale Domain- und Umgebungskonfiguration
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
|
||||||
|
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktuellen HTTP-Host (ohne Port) ermitteln
|
||||||
|
*/
|
||||||
|
function getSiteHost(): string
|
||||||
|
{
|
||||||
|
$host = $_SERVER['HTTP_HOST'] ?? SITE_DOMAIN_PRODUCTION;
|
||||||
|
$host = strtolower($host);
|
||||||
|
|
||||||
|
if (str_contains($host, ':')) {
|
||||||
|
$host = explode(':', $host, 2)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* true, wenn die Seite unter der Dev-Domain läuft
|
||||||
|
*/
|
||||||
|
function isDevelopmentSite(): bool
|
||||||
|
{
|
||||||
|
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basis-URL der aktuellen Anfrage (Schema + Host)
|
||||||
|
*/
|
||||||
|
function getSiteBaseUrl(): string
|
||||||
|
{
|
||||||
|
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||||
|
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
|
||||||
|
|
||||||
|
$scheme = $https ? 'https' : 'http';
|
||||||
|
|
||||||
|
return $scheme . '://' . getSiteHost();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erlaubte CORS-Origins für AJAX (Kontaktformular)
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
function getAllowedOrigins(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'https://' . SITE_DOMAIN_PRODUCTION,
|
||||||
|
'https://www.' . SITE_DOMAIN_PRODUCTION,
|
||||||
|
'https://' . SITE_DOMAIN_DEVELOPMENT,
|
||||||
|
'http://localhost',
|
||||||
|
'http://127.0.0.1',
|
||||||
|
'http://localhost:8000',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kanonische Basis-URL für SEO (Produktion immer hexahost.de)
|
||||||
|
*/
|
||||||
|
function getCanonicalBaseUrl(): string
|
||||||
|
{
|
||||||
|
return 'https://' . SITE_DOMAIN_PRODUCTION;
|
||||||
|
}
|
||||||
@@ -3,6 +3,12 @@
|
|||||||
* Helper functions for HexaHost.de
|
* Helper functions for HexaHost.de
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$configDir = defined('HEXAHOST_CONFIG_DIR')
|
||||||
|
? HEXAHOST_CONFIG_DIR
|
||||||
|
: __DIR__ . '/../config';
|
||||||
|
|
||||||
|
require_once $configDir . '/site-config.php';
|
||||||
|
|
||||||
// Sichere Session-Konfiguration
|
// Sichere Session-Konfiguration
|
||||||
if (session_status() === PHP_SESSION_NONE) {
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
// Session-Cookie-Sicherheit
|
// Session-Cookie-Sicherheit
|
||||||
@@ -52,6 +58,11 @@ function includeHeader($title = '', $description = '', $page = '', $scripts = []
|
|||||||
$current_page = $page;
|
$current_page = $page;
|
||||||
$additional_scripts = $scripts;
|
$additional_scripts = $scripts;
|
||||||
|
|
||||||
|
if (!isset($canonical_url)) {
|
||||||
|
$requestPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
|
||||||
|
$canonical_url = rtrim(getCanonicalBaseUrl(), '/') . $requestPath;
|
||||||
|
}
|
||||||
|
|
||||||
include __DIR__ . '/header.php';
|
include __DIR__ . '/header.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<?php require_once __DIR__ . '/../config/products-config.php'; ?>
|
<?php
|
||||||
|
$configDir = defined('HEXAHOST_CONFIG_DIR') ? HEXAHOST_CONFIG_DIR : __DIR__ . '/../config';
|
||||||
|
require_once $configDir . '/products-config.php';
|
||||||
|
?>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = '404 - Seite nicht gefunden | HexaHost.de';
|
$page_title = '404 - Seite nicht gefunden | HexaHost.de';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = '500 - Serverfehler | HexaHost.de';
|
$page_title = '500 - Serverfehler | HexaHost.de';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Über mich - HexaHost.de | Hosting aus Niederbayern';
|
$page_title = 'Über mich - HexaHost.de | Hosting aus Niederbayern';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Allgemeine Geschäftsbedingungen - HexaHost.de | AGB';
|
$page_title = 'Allgemeine Geschäftsbedingungen - HexaHost.de | AGB';
|
||||||
|
|||||||
41
public/bootstrap.php
Normal file
41
public/bootstrap.php
Normal 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);
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@ if (session_status() === PHP_SESSION_NONE) {
|
|||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Konfiguration laden
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once 'config/mail-config.php';
|
|
||||||
|
$configDir = defined('HEXAHOST_CONFIG_DIR') ? HEXAHOST_CONFIG_DIR : __DIR__ . '/config';
|
||||||
|
require_once $configDir . '/mail-config.php';
|
||||||
|
|
||||||
// PHPMailer Autoload (falls via Composer installiert)
|
// PHPMailer Autoload (falls via Composer installiert)
|
||||||
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||||
@@ -43,13 +45,8 @@ function validateCSRFToken($token) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CORS Headers für AJAX-Requests (nur eigene Domain erlauben)
|
// CORS Headers für AJAX-Requests (nur eigene Domains erlauben)
|
||||||
$allowed_origins = [
|
$allowed_origins = getAllowedOrigins();
|
||||||
'https://hexahost.de',
|
|
||||||
'https://www.hexahost.de',
|
|
||||||
'http://localhost', // Für Entwicklung
|
|
||||||
'http://127.0.0.1' // Für Entwicklung
|
|
||||||
];
|
|
||||||
|
|
||||||
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
||||||
if (in_array($origin, $allowed_origins)) {
|
if (in_array($origin, $allowed_origins)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Kontakt - HexaHost.de | Hosting aus Niederbayern';
|
$page_title = 'Kontakt - HexaHost.de | Hosting aus Niederbayern';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Datenschutzerklärung - HexaHost.de | Datenschutz';
|
$page_title = 'Datenschutzerklärung - HexaHost.de | Datenschutz';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Impressum - HexaHost.de | Rechtliche Angaben';
|
$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>
|
<h1 class="legal-hero-title">Impressum</h1>
|
||||||
<p class="legal-hero-description">
|
<p class="legal-hero-description">
|
||||||
|
Rechtliche Angaben und Pflichtinformationen gemäß § 5 DDG
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'HexaHost.de - Zuverlässiges Hosting aus Niederbayern';
|
$page_title = 'HexaHost.de - Zuverlässiges Hosting aus Niederbayern';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'IT-Dienstleistungen - HexaHost.de | Privat & Gewerblich';
|
$page_title = 'IT-Dienstleistungen - HexaHost.de | Privat & Gewerblich';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Produkt-Daten aus Config laden
|
// Produkt-Daten aus Config laden
|
||||||
$product = getProduct('mail-gateway');
|
$product = getProduct('mail-gateway');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Produkt-Daten aus Config laden
|
// Produkt-Daten aus Config laden
|
||||||
$product = getProduct('vpc');
|
$product = getProduct('vpc');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Produkt-Daten aus Config laden
|
// Produkt-Daten aus Config laden
|
||||||
$product = getProduct('vps');
|
$product = getProduct('vps');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
require_once __DIR__ . '/../backend/config/products-config.php';
|
require_once HEXAHOST_CONFIG_DIR . '/products-config.php';
|
||||||
|
|
||||||
// Produkt-Daten aus Config laden
|
// Produkt-Daten aus Config laden
|
||||||
$product = getProduct('webhosting');
|
$product = getProduct('webhosting');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/../backend/includes/functions.php';
|
require_once __DIR__ . '/bootstrap.php';
|
||||||
|
|
||||||
// Page configuration
|
// Page configuration
|
||||||
$page_title = 'Widerrufsbelehrung - HexaHost.de';
|
$page_title = 'Widerrufsbelehrung - HexaHost.de';
|
||||||
|
|||||||
Reference in New Issue
Block a user