import sys import re with open('index.php', 'r') as f: content = f.read() # First, let's restore the thread loop (the first one) thread_loop_pattern = r'<\?php foreach\(\$messages as \$m\):.*?\<\?php endforeach; \?\>' # We need a non-greedy regex that handles nested PHP tags # Actually, it's easier to find the markers. # Let's find the first foreach($messages as $m) # and the first endforeach after it. # I'll just use a simpler approach: # Find everything between
# and
# and replace it with a clean version of both loops. start_marker = '
' end_marker = '
' start_pos = content.find(start_marker) end_pos = content.find(end_marker) if start_pos == -1 or end_pos == -1: print("Error: Could not find markers") sys.exit(1) # Now we need to keep the structure between those markers but clean it. # The structure is: # if($active_thread): # ... # foreach($messages as $m): (thread loop) # ... # endforeach # ... # elseif($channel_type === 'event'): # ... # else: (normal chat) # ... # foreach($messages as $m): (normal loop) # ... # endforeach # endif clean_inner = """

Discussion :

prepare("SELECT ft.* FROM forum_tags ft JOIN thread_tags tt ON ft.id = tt.tag_id WHERE tt.thread_id = ?"); $stmt_t->execute([$active_thread['id']]); $thread_tags = $stmt_t->fetchAll(); if ($thread_tags): foreach ($thread_tags as $t): ?>
">
"> SOLUTION
📊 SONDAGE
$opt): $count = 0; $user_voted = false; if (isset($m['votes_data'])) { foreach($m['votes_data'] as $v) { if ($v['option_index'] == $idx) { $count = (int)$v['vote_count']; $user_ids = explode(',', $v['user_ids'] ?? ''); if (in_array($current_user_id, $user_ids)) { $user_voted = true; } break; } } } $percent = $total_votes > 0 ? round(($count / $total_votes) * 100) : 0; $is_expired = !empty($meta['end_date']) && strtotime($meta['end_date']) < time(); ?>
% ()
prepare("SELECT emoji, COUNT(*) as count, GROUP_CONCAT(user_id) as users FROM message_reactions WHERE message_id = ? GROUP BY emoji"); $stmt_react->execute([$m['id']]); $reactions = $stmt_react->fetchAll(); foreach ($reactions as $r): $reacted = in_array($current_user_id, explode(',', $r['users'])); ?> +

Événements

Découvrez et gérez les événements à venir.

Aucun événement prévu pour le moment.

Cliquez sur "Ajouter un événement" pour commencer.

">
à
Fin: à
Voir plus
Participants ()
prepare("SELECT u.avatar_url, u.display_name FROM event_participations ep JOIN users u ON ep.user_id = u.id WHERE ep.event_id = ? LIMIT 5"); $stmt_p->execute([$event['id']]); $participants = $stmt_p->fetchAll(); $p_idx = 0; foreach ($participants as $p): ?>
; margin-left: 0 ? '-8px' : '0'; ?>; position: relative; z-index: ;">
5): ?>
+

📜

.
prepare("SELECT 1 FROM rule_acceptances WHERE user_id = ? AND channel_id = ?"); $stmtAcc->execute([$current_user_id, $active_channel_id]); $has_accepted = $stmtAcc->fetch(); ?>
Vous avez accepté les règles.

Veuillez accepter les règles pour obtenir l'accès complet.

🛡️

Cliquez sur un bouton pour vous attribuer ou vous retirer un rôle.

prepare("SELECT 1 FROM user_roles WHERE user_id = ? AND role_id = ?"); $stmtHasRole->execute([$current_user_id, $ar['role_id']]); $has_role = $stmtHasRole->fetch(); ?>

🏛️

Pas encore de discussions. Commencez-en une !
💬
Lancé par "> messages
Dernière activité :

Par • Dans #
Retour au forum

Bienvenue dans # !

C'est le début du salon #.

">
"> Épinglé
📊 SONDAGE
$opt): $count = 0; $user_voted = false; if (isset($m['votes_data'])) { foreach($m['votes_data'] as $v) { if ($v['option_index'] == $idx) { $count = (int)$v['vote_count']; $user_ids = explode(',', $v['user_ids'] ?? ''); if (in_array($current_user_id, $user_ids)) { $user_voted = true; } break; } } } $percent = $total_votes > 0 ? round(($count / $total_votes) * 100) : 0; $is_expired = !empty($meta['end_date']) && strtotime($meta['end_date']) < time(); ?>
% ()
prepare("SELECT emoji, COUNT(*) as count, GROUP_CONCAT(user_id) as users FROM message_reactions WHERE message_id = ? GROUP BY emoji"); $stmt_react->execute([$m['id']]); $reactions = $stmt_react->fetchAll(); foreach ($reactions as $r): $reacted = in_array($current_user_id, explode(',', $r['users'])); ?> +
""" new_content = clean_inner.strip() content = content[:start_pos + len(start_marker)] + "\n" + new_content + "\n" + content[end_pos:] with open('index.php', 'w') as f: f.write(content)