import re
with open('includes/app.php', 'r', encoding='utf-8') as f:
content = f.read()
# 1. Add is_super_admin()
role_func = """
function is_super_admin(): bool {
if (isset($_GET['role'])) {
$_SESSION['role'] = $_GET['role'];
}
return ($_SESSION['role'] ?? 'super_admin') === 'super_admin';
}
"""
if 'function is_super_admin' not in content:
content = content.replace("function env_value", role_func + "\nfunction env_value", 1)
# 2. Update the header
header_old = ''
header_new = """
\" class=\"header-chip text-decoration-none bg-primary text-white\" style=\"cursor:pointer;\" title=\"اضغط للتبديل\">صلاحية: = e($roleName) ?> ⟳"""
content = content.replace(header_old, header_new)
with open('includes/app.php', 'w', encoding='utf-8') as f:
f.write(content)