Merge pull request #712 from midoks/dev

简单优化
This commit is contained in:
Mr Chen
2025-03-01 22:18:31 +08:00
committed by GitHub
4 changed files with 13 additions and 16 deletions
+3 -6
View File
@@ -324,8 +324,7 @@ class App:
siteInfo['open'] = not siteInfo['open']
m_logs = {True: '开启', False: '关闭'}
self.writeLog('%s站点[%s]防篡改保护' %
(m_logs[siteInfo['open']], siteInfo['siteName']))
self.writeLog('%s站点[%s]防篡改保护' % (m_logs[siteInfo['open']], siteInfo['siteName']))
self.siteReload(siteInfo)
self.saveSiteConfig(siteInfo)
self.restart()
@@ -458,8 +457,7 @@ class App:
if not protectExt in siteInfo['protectExt']:
continue
siteInfo['protectExt'].remove(protectExt)
self.writeLog('站点[%s]从受保护列表中删除[.%s]' %
(siteInfo['siteName'], protectExt))
self.writeLog('站点[%s]从受保护列表中删除[.%s]' % (siteInfo['siteName'], protectExt))
self.siteReload(siteInfo)
self.saveSiteConfig(siteInfo)
return mw.returnJson(True, '删除成功!')
@@ -593,8 +591,7 @@ class App:
for i in range(len(sites)):
if sites[i]['siteName'] in siteNames:
sites[i]['open'] = siteState
self.writeLog('%s站点[%s]防篡改保护' %
(m_logs[siteState], sites[i]['siteName']))
self.writeLog('%s站点[%s]防篡改保护' % (m_logs[siteState], sites[i]['siteName']))
self.writeSites(sites)
return mw.returnJson(True, '批量设置成功')
+2 -2
View File
@@ -1,9 +1,9 @@
{
"title": "网站防篡改程序[PY]",
"title": "网站防篡改程序PY",
"tip": "lib",
"name": "tamper_proof_py",
"type": "soft",
"ps": "事件型防篡改程序,可有效保护网站重要文件不被木马篡改",
"ps": "事件型防篡改程序,可有效保护网站重要文件不被木马篡改[Python]",
"versions": "1.0",
"shell": "install.sh",
"checks": "server/tamper_proof_py",
@@ -123,10 +123,10 @@ class MyEventHandler(pyinotify.ProcessEvent):
return ret[0:20]
return ret
def get_site_logs(self, Stiename):
def get_site_logs(self, site_name):
try:
pythonV = sys.version_info[0]
path = '/www/wwwlogs/' + Stiename + '.log'
path = '/www/wwwlogs/' + site_name + '.log'
num = 500
if not os.path.exists(path):
return []
@@ -422,7 +422,7 @@ class MyEventHandler(pyinotify.ProcessEvent):
os.system('chattr -R -a {} &> /dev/null'.format(path))
self.set_user_ini(path)
def close(self, reload=False):
def close(self, close_reload=False):
# 解除锁定
sites = self.get_sites()
print("")
@@ -433,11 +433,10 @@ class MyEventHandler(pyinotify.ProcessEvent):
tip = self._PLUGIN_PATH + '/tips/' + siteInfo['siteName'] + '.pl'
if not siteInfo['open'] and not os.path.exists(tip):
continue
if reload and siteInfo['open']:
if close_reload and siteInfo['open']:
continue
if sys.version_info[0] == 2:
print(
"【{}】|-Unlock website[{}]".format(mw.formatDate(), siteInfo['siteName'])),
print("【{}】|-Unlock website[{}]".format(mw.formatDate(), siteInfo['siteName'])),
else:
os.system("echo -e '{}|-Unlock website[{}]\c'".format(mw.formatDate(), siteInfo['siteName']))
#print("【{}】|-解锁网站[{}]".format(mw.format_date(),siteInfo['siteName']),end=" ")
@@ -514,8 +513,7 @@ def run():
if not os.path.exists(tip):
event.list_DIR(siteInfo['path'], siteInfo)
try:
watchManager.add_watch(
siteInfo['path'], mode, auto_add=True, rec=True)
watchManager.add_watch(siteInfo['path'], mode, auto_add=True, rec=True)
except:
print(mw.getTracebackInfo())
tout = round(time.time() - s, 2)
+2
View File
@@ -15,6 +15,8 @@ Install_App()
mkdir -p $serverPath/webhook
echo "${VERSION}" > $serverPath/webhook/version.pl
echo '安装完成'
which mw && mw restart
}
Uninstall_App()