/** * Domain Helper - Domein-specifieke functies * Maakt duidelijke scheiding tussen portal.itlive.nl en itlive.nl */ // Domein detectie – account.itlive.nl = eigen accountomgeving (geen portal) function getCurrentDomain() { $host = $_SERVER['HTTP_HOST'] ?? ''; if (stripos($host, 'account.itlive.nl') !== false) { return 'account'; } if (stripos($host, 'portal.itlive.nl') !== false) { return 'portal'; } if (stripos($host, 'itlive.nl') !== false) { return 'public'; } return 'unknown'; } // Base URL generatie – publieke hosts gebruiken eigen host; portal blijft intern. function getBaseUrl() { $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST'] ?? ''; $domain = getCurrentDomain(); if ($domain === 'account') { return $scheme . '://' . $host; } return $scheme . '://itlive.nl'; } // Portal URL generatie – NOOIT cross-domain naar portal.itlive.nl exposeren. function getPortalUrl($path = '') { $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST'] ?? ''; return $scheme . '://' . $host . (strpos($path, '/') === 0 ? '' : '/') . $path; } // Public URL generatie function getPublicUrl($path = '') { return 'https://itlive.nl' . $path; } // Domein-specifieke navigation function getDomainNavigation() { $domain = getCurrentDomain(); if ($domain === 'portal') { return [ ['label' => 'Dashboard', 'url' => '/dashboard/'], ['label' => 'Projecten', 'url' => '/projects/'], ['label' => 'Tools', 'url' => '/tools/'], ['label' => 'Support', 'url' => '/support/'], ['label' => 'Instellingen', 'url' => '/settings/'] ]; } else { return [ ['label' => 'Home', 'url' => '/'], ['label' => 'Diensten', 'url' => '/diensten'], ['label' => 'AI Tools', 'url' => '/ai-tools'], ['label' => 'Tools', 'url' => '/tools'], ['label' => 'Over Ons', 'url' => '/over-ons'], ['label' => 'Contact', 'url' => '/contact'] ]; } } // Domein-specifieke header info – account = eigen titel, geen "Portal" function getDomainHeader() { $domain = getCurrentDomain(); if ($domain === 'account') { return [ 'title' => 'Account - IT Live', 'description' => 'Uw account en klantportaal', 'robots' => 'noindex, nofollow', 'favicon' => '/favicon.ico' ]; } if ($domain === 'portal') { return [ 'title' => 'IT Live Portal - Klantportaal', 'description' => 'Beheer uw digitale diensten en projecten', 'robots' => 'noindex, nofollow', 'favicon' => '/favicon-portal.ico' ]; } return [ 'title' => 'IT Live - Digitale Oplossingen voor MKB', 'description' => 'Professionele websites, AI tools en digitale diensten voor ondernemers', 'robots' => 'index, follow', 'favicon' => '/favicon.ico' ]; } // Check of path toegestaan is op huidig domein function isPathAllowed($path) { $domain = getCurrentDomain(); if ($domain === 'portal') { $allowed = [ '/admin/', '/admin_portal/', '/customer/', '/customer_portal/', '/klant/', '/klant-portal/', '/agent/', '/agent_portal/', '/manager/', '/manager_portal/', '/dashboard/', '/login/', '/register/' ]; foreach ($allowed as $allowed_path) { if (strpos($path, $allowed_path) === 0) return true; } return false; } if ($domain === 'account') { return strpos($path, '/customer_portal/') === 0 || $path === '/' || $path === ''; } $allowed = [ '/', '/index.php', '/index.html', '/diensten', '/diensten.php', '/over-ons', '/over-ons.php', '/contact', '/contact.php', '/ai-tools', '/ai-tools.php', '/tools', '/tools.php', '/idee', '/idee/', '/bedrijvencheck', '/bedrijvencheck/', '/lead-generator', '/lead-generator/', '/ai-site-builder', '/ai-site-builder/', '/website-builder', '/website-builder/', '/business-plan', '/business-plan/', '/404', '/404.php' ]; foreach ($allowed as $allowed_path) { if (strpos($path, $allowed_path) === 0) return true; } return false; } // Automatische redirect indien nodig – account.itlive.nl NOOIT naar portal function handleDomainRedirect() { $current_path = $_SERVER['REQUEST_URI'] ?? ''; $path = parse_url($current_path, PHP_URL_PATH) ?: $current_path; $domain = getCurrentDomain(); if (!isPathAllowed($path)) { if ($domain === 'portal') { header('Location: https://itlive.nl' . $current_path, true, 301); exit; } if ($domain === 'account') { // Account: alleen customer_portal; onbekend path → startpagina klantportaal, NOOIT portal header('Location: ' . getBaseUrl() . '/customer_portal/', true, 302); exit; } // Public domein met onbekend path → 404 (geen cross-domain redirect naar portal). http_response_code(404); exit; } } // Domein-specifieke footer links function getDomainFooterLinks() { $domain = getCurrentDomain(); if ($domain === 'portal') { return [ ['label' => 'Dashboard', 'url' => '/dashboard/'], ['label' => 'Help', 'url' => '/help/'], ['label' => 'Support', 'url' => '/support/'], ['label' => 'Documentatie', 'url' => '/docs/'] ]; } else { return [ ['label' => 'Home', 'url' => '/'], ['label' => 'Diensten', 'url' => '/diensten'], ['label' => 'AI Tools', 'url' => '/ai-tools'], ['label' => 'Over Ons', 'url' => '/over-ons'], ['label' => 'Contact', 'url' => '/contact'], ['label' => 'Privacy', 'url' => '/privacy'], ['label' => 'Voorwaarden', 'url' => '/voorwaarden'] ]; } } // Domein-specifieke CSS classes function getDomainBodyClass() { $domain = getCurrentDomain(); return 'domain-' . $domain; } // Domein-specifieke analytics tracking function getDomainAnalytics() { $domain = getCurrentDomain(); if ($domain === 'portal') { return [ 'ga_tracking_id' => 'UA-XXXXXXX-X-1', 'gtm_container_id' => 'GTM-XXXXXXX1' ]; } else { return [ 'ga_tracking_id' => 'UA-XXXXXXX-X', 'gtm_container_id' => 'GTM-XXXXXXX' ]; } } // Domein-specifieke branding function getDomainBranding() { $domain = getCurrentDomain(); if ($domain === 'account') { return [ 'logo' => '/assets/logo.svg', 'logo_alt' => 'IT Live Account', 'brand_color' => '#0d9488', 'theme' => 'account' ]; } if ($domain === 'portal') { return [ 'logo' => '/assets/logo-portal.svg', 'logo_alt' => 'IT Live Portal', 'brand_color' => '#ffc107', 'theme' => 'portal' ]; } return [ 'logo' => '/assets/logo.svg', 'logo_alt' => 'IT Live', 'brand_color' => '#007bff', 'theme' => 'public' ]; } // Helper functie om correcte link te genereren – op account: nooit portal-URL function generateLink($path, $text = null, $class = '') { $domain = getCurrentDomain(); $is_portal_path = strpos($path, '/admin/') === 0 || strpos($path, '/admin_portal/') === 0 || strpos($path, '/customer/') === 0 || strpos($path, '/customer_portal/') === 0 || strpos($path, '/klant/') === 0 || strpos($path, '/dashboard/') === 0; if ($domain === 'account') { $url = getBaseUrl() . (strpos($path, '/') === 0 ? '' : '/') . ltrim($path, '/'); } elseif ($is_portal_path) { $url = getPortalUrl($path); } else { $url = getPublicUrl($path); } $link_text = $text ?: $path; return '' . htmlspecialchars($link_text) . ''; } // Automatische redirect handler (aanroepen bovenaan pagina) if (!function_exists('handleDomainRedirect')) { handleDomainRedirect(); }