import sys with open('index.php', 'r') as f: lines = f.readlines() # Section starts after line 1294 (index 1294) # Section ends before chat-input-container (Line 1749 -> index 1748) start_index = 1294 end_index = 0 for i, line in enumerate(lines): if '
' in line: end_index = i break if not end_index: print("Error: Could not find end marker") sys.exit(1) print(f"Replacing lines {start_index+1} to {end_index}") new_content = """
">
"> É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'])); ?> +
""" with open('index.php', 'w') as f: f.writelines(lines[:start_index]) f.write(new_content) f.write("\n") f.writelines(lines[end_index:])