24 lines
780 B
Python
24 lines
780 B
Python
import re
|
|
|
|
with open('_get_instance_details.php', 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
def replace_checkbox(m):
|
|
block = m.group(0)
|
|
return re.sub(
|
|
r'<input type="checkbox" id="<\?= htmlspecialchars\(\$fieldName\) \?>"',
|
|
r'<input type="hidden" name="<?= htmlspecialchars($fieldName) ?>" value="0">\n <input type="checkbox" id="<?= htmlspecialchars($fieldName) ?>" name="<?= htmlspecialchars($fieldName) ?>"',
|
|
block
|
|
)
|
|
|
|
content = re.sub(
|
|
r"<\?php if \(\$field\['type'\] === 'checkbox'\): \?>.*?<\?php else: \?>",
|
|
replace_checkbox,
|
|
content,
|
|
flags=re.DOTALL
|
|
)
|
|
|
|
with open('_get_instance_details.php', 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
print("Hidden inputs added.")
|