import os
import re

path = r'c:\wamp64\www\Pascoa\vote.php'
content = open(path, 'r', encoding='utf-8').read()

# Pattern simplified to match the structure regardless of whitespace
pattern = r'<form method="post" action="vote\.php" id="form_.*?">.*?</form>'

replacement = '<div class="rating-group" style="pointer-events: none; opacity: 0.8; margin-top: 1rem;">' \
              '<?php for($i=5; $i>=1; $i--): ?>' \
              '<input type="radio" disabled <?= $userScore === $i ? "checked" : "" ?> />' \
              '<label><?= $i ?></label>' \
              '<?php endfor; ?>' \
              '</div>'

def replacer(match):
    return replacement

new_content = re.sub(pattern, replacer, content, flags=re.DOTALL)
open(path, 'w', encoding='utf-8').write(new_content)
