pas de redirection abonnement. */ /* ========================= Helpers ========================= */ function is_header_logged_in(): bool { $role = (string) ($_SESSION['role'] ?? ($_SESSION['user_type'] ?? '')); if (! empty($_SESSION['reference_id']) && $role !== '') { return true; } if (! empty($_SESSION['user_id'])) { return true; } if (! empty($_SESSION['client_id'])) { return true; } if (! empty($_SESSION['praticien_id'])) { return true; } return false; } /** * Inclut /public/includes/header.php sans DOCTYPE/HTML/HEAD/BODY et sans recharger bootstrap/css. */ function include_header_clean(string $absPath): void { global $translations, $lang; require_once APP_HTDOCS . '/public/includes/securite.php'; ob_start(); include $absPath; // /public/includes/header.php $buf = ob_get_clean() ?: ''; // 0) DOCTYPE + … $buf = preg_replace('~]*>~i', '', $buf); $buf = preg_replace('~]*>~i', '', $buf); // 1) retirer … et ouverts/fermés $buf = preg_replace('~]*>.*?~is', '', $buf); $buf = preg_replace('~]*>~i', '', $buf); // 2) retirer les CSS “globaux” pour éviter d’écraser la home $buf = preg_replace('~]+href="[^"]*(bootstrap[^"]*\.css|mobil_style\.css|site_style\.css|fonts\.googleapis)[^"]*"[^>]*>~i', '', $buf); // 3) retirer le ~i', '', $buf); echo $buf; // garde
+ tes scripts inline utiles } function prepare_secure_header_context(): void { $pdo = $GLOBALS['pdo'] ?? null; if (! ($pdo instanceof PDO)) { return; } $role = strtolower((string) ($_SESSION['role'] ?? '')); $refId = (int) ($_SESSION['reference_id'] ?? 0); // Initiales client/praticien if ($refId > 0 && ($role === 'client' || $role === 'praticien')) { try { $table = ($role === 'client') ? 'client' : 'praticien'; $st = $pdo->prepare("SELECT nom, prenom FROM {$table} WHERE id = ? LIMIT 1"); $st->execute([$refId]); $u = $st->fetch(PDO::FETCH_ASSOC) ?: []; $nom = trim((string) ($u['nom'] ?? '')); $prenom = trim((string) ($u['prenom'] ?? '')); $ini = mb_strtoupper( mb_substr($prenom, 0, 1, 'UTF-8') . mb_substr($nom, 0, 1, 'UTF-8'), 'UTF-8' ); $GLOBALS['initiales'] = $ini !== '' ? $ini : 'U'; } catch (Throwable $e) { $GLOBALS['initiales'] = 'U'; } } } // Si connecté -> préparer le contexte header sécurisé (sans redirection) $logged = is_header_logged_in(); if ($logged) { prepare_secure_header_context(); }