// Total count including replies if (!function_exists('count_comments_total')) { function count_comments_total($list): int { if (!is_array($list) || !$list) return 0; if (!isset($list[0]['children'])) return (int)count($list); $sum = 0; foreach ($list as $n) { $sum++; if (!empty($n['children']) && is_array($n['children'])) { $sum += count_comments_total($n['children']); } } return $sum; } } // Descendants counter if (!function_exists('count_descendants')) { function count_descendants(array $node): int { $sum = 0; if (!empty($node['children']) && is_array($node['children'])) { foreach ($node['children'] as $ch) { $sum++; $sum += count_descendants($ch); } } return $sum; } } // Safe body HTML if (!function_exists('comment_body_html_safe')) { function comment_body_html_safe(array $c): string { // Supposons que render_comment_html est défini ailleurs (functions.php global) return isset($c['body_html']) ? (string)$c['body_html'] : (function_exists('render_comment_html') ? render_comment_html((string)($c['body'] ?? '')) : htmlspecialchars($c['body'] ?? '')); } } // Render Comment Node (Recursive) if (!function_exists('render_comment_node')) { function render_comment_node( array $c, bool $can_comment, string $commentsActionUrl, string $csrf, callable $loginNext, int $depth = 0, int $maxDepth = 3 ) { global $baseurl, $mod_rewrite, $lang; // Récupération des globales nécessaires $___base = rtrim((string)($baseurl ?? ''), '/') . '/'; $___mr = ((string)($mod_rewrite ?? '1') === '1'); $id = (int)($c['id'] ?? 0); $username = (string)($c['username'] ?? 'Invité'); $ts = isset($c['created_at']) ? strtotime((string)$c['created_at']) : 0; $ago = $ts ? ('il y a ' . (function_exists('conTime') ? conTime($ts) : date('Y-m-d', $ts))) : ''; $body_html = comment_body_html_safe($c); $can_delete = !empty($c['can_delete']); $children = is_array($c['children'] ?? null) ? $c['children'] : []; $initial = strtoupper(mb_substr($username !== '' ? $username : 'G', 0, 1, 'UTF-8')); $hasKids = !empty($children); $clamped = ($depth >= $maxDepth) && $hasKids; $threadId = 'thread-' . $id; $descCnt = $clamped ? count_descendants($c) : 0; $depthStyle = '--d:' . (int)$depth . ';'; // Inclure le template d'un commentaire unique // Pour éviter de casser la récursion avec des includes, on garde le HTML ici ou on fait un template très simple. // Pour simplifier ta vie maintenant, on garde le HTML généré ici, c'est le plus robuste pour la récursion. ?>
  • ' . htmlspecialchars($cu, ENT_QUOTES, 'UTF-8') . ''; } else { echo htmlspecialchars($cu ?: 'Invité', ENT_QUOTES, 'UTF-8'); } ?> #