Init Git Prod Mars 2026

This commit is contained in:
Oleg Barykin committed 2026-03-05 10:25:39 +01:00
commit d81efe93b1
362 files changed
+86627

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
<?php
//init_auth.php
declare(strict_types=1);
require_once __DIR__ . '/../../../includes/bootstrap_global.php';
require_once __DIR__ . '/securite.php';
function init_auth_page(?array $roles = null): void
{
require_login_or_redirect($roles);
// Push config (si utilisé dans header site)
$pushCfgPath = __DIR__ . '/../../push/config.php'; // /public/push/config.php
$GLOBALS['pushCfg'] = is_file($pushCfgPath) ? require $pushCfgPath : [];
// Abonnement (si tu l’utilises dans le header site praticien)
$abonnementPath = __DIR__ . '/verifier_abonnement.php';
if (is_file($abonnementPath)) {
require $abonnementPath;
$GLOBALS['alerte_abonnement'] = $alerte_abonnement ?? null;
} else {
$GLOBALS['alerte_abonnement'] = null;
}
// Avatars
$GLOBALS['initiales'] = 'U';
$GLOBALS['avatar_svg'] = null;
$role = strtolower((string)($_SESSION['role'] ?? ''));
// Admin / Secrétaire => SVG
if ($role === 'admin') {
$GLOBALS['avatar_svg'] = '/public/uploads/img/avatar_admin.svg';
return;
}
if ($role === 'secretaire') {
$GLOBALS['avatar_svg'] = '/public/uploads/img/avatar_secretaire.svg';
return;
}
// Client / Praticien => initiales depuis tables
$refId = (int)($_SESSION['reference_id'] ?? 0);
$pdo = $GLOBALS['pdo'] ?? null;
if (!($pdo instanceof PDO) || $refId <= 0) return;
if ($role === 'client') {
$stmt = $pdo->prepare("SELECT nom, prenom FROM client WHERE id = ?");
} elseif ($role === 'praticien') {
$stmt = $pdo->prepare("SELECT nom, prenom FROM praticien WHERE id = ?");
} else {
return;
}
$stmt->execute([$refId]);
$u = $stmt->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';
}