This commit is contained in:
Alexey Berezhok
2026-07-21 00:50:05 +03:00
parent 6e32005129
commit 053d60f354
6 changed files with 69 additions and 26 deletions

View File

@@ -2,10 +2,25 @@
import os
import xml.etree.ElementTree as etree
from xml.dom import minidom
from sys import stdin
import subprocess
import datetime
def dump_all_to_log(root):
log_path = '/usr/local/mgr5/var/nginx-mod-rewrite-plugin.log'
try:
with open(log_path, 'a') as log_file:
timestamp = datetime.datetime.now().isoformat()
xml_str = etree.tostring(root, encoding='unicode')
# Prettyprint the XML
pretty_xml = minidom.parseString(xml_str).toprettyxml(indent=" ")
log_file.write(f"{timestamp} - Dumping XML to log:\n{pretty_xml}\n")
log_file.write(f"{timestamp} - Environment variables:\n")
for key, value in sorted(os.environ.items()):
log_file.write(f"{key}={value}\n")
except Exception:
pass
def CheckModuleExists():
module_path = '/usr/share/nginx/modules/ngx_http_apache_rewrite_module.conf'
@@ -97,13 +112,10 @@ def Handle(root):
for child in list(parent):
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg':
parent.remove(child)
# Find the messages element with name "nginx_mod_rewrite_plugin.settings"
messages_elem = root.find(".//messages[@name='nginx_mod_rewrite_plugin.settings']")
if messages_elem is not None:
# Find the msg element with name "msg_create" and change its text
msg_create_elem = messages_elem.find(".//msg[@name='msg_create']")
if msg_create_elem is not None:
msg_create_elem.text = 'Ничего не делать'
for buttons in root.findall(".//buttons"):
for btn in list(buttons):
if btn.tag == 'button' and btn.get('name') == 'ok':
buttons.remove(btn)
if __name__ == "__main__":
@@ -134,14 +146,10 @@ if __name__ == "__main__":
if child.tag == 'textdata' and child.get('name') == 'nginx_mod_rewrite_plugin_msg':
parent.remove(child)
# Find the messages element with name "nginx_mod_rewrite_plugin.settings"
messages_elem = root.find(".//messages[@name='nginx_mod_rewrite_plugin.settings']")
if messages_elem is not None:
# Find the msg element with name "msg_create" and change its text
msg_create_elem = messages_elem.find(".//msg[@name='msg_create']")
if msg_create_elem is not None:
msg_create_elem.text = 'Ничего не делать'
for buttons in root.findall(".//buttons"):
for btn in list(buttons):
if btn.tag == 'button' and btn.get('name') == 'ok':
buttons.remove(btn)
etree.dump(root)
quit(0)

View File

@@ -5,6 +5,13 @@
<settings>nginx_mod_rewrite_plugin.settings</settings>
<free />
</plugin>
<mainmenu level="admin+">
<modernmenu>
<node name="nginx_mod_rewrite_plugin_menu" customicon="/manimg/icons/mod_rewrite_menu.svg">
<node name="nginx_mod_rewrite_plugin_menu_settings" customicon="/manimg/icons/mod_rewrite_tool.svg"/>
</node>
</modernmenu>
</mainmenu>
<handler name="nginx_mod_rewrite_plugin.py" type="xml">
<func name="nginx_mod_rewrite_plugin.settings" />
</handler>
@@ -14,11 +21,11 @@
<textdata name="nginx_mod_rewrite_plugin_msg" type="banner" status="warning"/>
<textdata name="nginx_mod_rewrite_plugin_msg_info" type="banner" status="info"/>
</field>
<buttons>
<button name="ok" type="ok" />
<button name="cancel" type="cancel" />
</buttons>
</form>
<buttons>
<button name="ok" type="ok" />
<button name="cancel" type="cancel" />
</buttons>
</metadata>
<metadata name="site.edit" type="form">
<form>
@@ -43,13 +50,6 @@
<event name="site.edit" after="yes"/>
<func name="nginx_mod_rewrite_plugin_menu_settings"/>
</handler>
<mainmenu level="admin+">
<modernmenu>
<node name="nginx_mod_rewrite_plugin_menu" customicon="/manimg/icons/mod_rewrite_menu.svg">
<node name="nginx_mod_rewrite_plugin_menu_settings" customicon="/manimg/icons/mod_rewrite_tool.svg"/>
</node>
</modernmenu>
</mainmenu>
<metadata name="nginx_mod_rewrite_plugin_menu_settings" type="form">
<form needconfirm="yes">
<field name="nginx_mod_rewrite_plugin_menu_module_enable">