import re with open('approved_school.php', 'r', encoding='utf-8') as f: content = f.read() # Hide "archive cycle" form in approved_school.php archive_form = r"""(
\s*.*?<\/form>)""" content = re.sub(archive_form, r'\1', content, flags=re.DOTALL) # Hide col-lg-4 containing cycles switcher and start new cycle form col_lg_4_cycles = r"""(
\s*)""" content = re.sub(col_lg_4_cycles, r'\n\1\n', content, flags=re.DOTALL) # Adjust col-lg-8 to be conditionally 12 content = re.sub(r'
', r'
', content) # Check POST handler for cycles in approved_school.php post_handler = r"if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cycle_action'])) {" post_handler_new = r"""if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cycle_action'])) { if (!is_super_admin()) { set_flash('error', 'عذراً، الإدارة الكاملة للدورات متاحة للمشرف العام فقط.'); header('Location: approved_school.php?id=' . $application['id']); exit; }""" content = content.replace(post_handler, post_handler_new) with open('approved_school.php', 'w', encoding='utf-8') as f: f.write(content)