mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 05:59:25 +08:00
功能OK
面板操作日志已清空!
This commit is contained in:
+21
-6
@@ -72,10 +72,7 @@ class files_api:
|
||||
|
||||
def getDirSizeApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
if public.getOs() == 'darwin':
|
||||
tmp = public.execShell('du -sh ' + path)
|
||||
else:
|
||||
tmp = public.execShell('du -sbh ' + path)
|
||||
tmp = self.getDirSize(path)
|
||||
return public.returnJson(True, tmp[0].split()[0])
|
||||
|
||||
def getDirApi(self):
|
||||
@@ -99,7 +96,8 @@ class files_api:
|
||||
os.makedirs(_path)
|
||||
open(file, 'w+').close()
|
||||
self.setFileAccept(file)
|
||||
# public.WriteLog('TYPE_FILE', 'FILE_CREATE_SUCCESS', (get.path,))
|
||||
msg = public.getInfo('创建文件[{1}]成功!', (file,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '文件创建成功!')
|
||||
except Exception as e:
|
||||
# print str(e)
|
||||
@@ -114,7 +112,8 @@ class files_api:
|
||||
return public.returnJson(False, '指定目录已存在!')
|
||||
os.makedirs(path)
|
||||
self.setFileAccept(path)
|
||||
# public.writeLog('TYPE_FILE', 'DIR_CREATE_SUCCESS', (get.path,))
|
||||
msg = public.getInfo('创建目录[{1}]成功!', (path,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '目录创建成功!')
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '目录创建失败!')
|
||||
@@ -317,6 +316,15 @@ done
|
||||
except:
|
||||
return public.returnJson(False, '删除文件失败!')
|
||||
|
||||
def closeLogsApi(self):
|
||||
logPath = public.getLogsDir()
|
||||
os.system('rm -f ' + logPath + '/*')
|
||||
os.system('kill -USR1 `cat ' + public.getServerDir() +
|
||||
'openresty/nginx/logs/nginx.pid`')
|
||||
public.writeLog('文件管理', '网站日志已被清空!')
|
||||
tmp = self.getDirSize(logPath)
|
||||
return public.returnJson(True, tmp[0].split()[0])
|
||||
|
||||
##### ----- end ----- ###
|
||||
|
||||
# 检查敏感目录
|
||||
@@ -353,6 +361,13 @@ done
|
||||
|
||||
return not path in nDirs
|
||||
|
||||
def getDirSize(self, path):
|
||||
if public.getOs() == 'darwin':
|
||||
tmp = public.execShell('du -sh ' + path)
|
||||
else:
|
||||
tmp = public.execShell('du -sbh ' + path)
|
||||
return tmp
|
||||
|
||||
def checkFileName(self, filename):
|
||||
# 检测文件名
|
||||
nots = ['\\', '&', '*', '|', ';']
|
||||
|
||||
@@ -218,6 +218,11 @@ class firewall_api:
|
||||
public.execShell('sysctl -p')
|
||||
return public.returnJson(True, '设置成功!')
|
||||
|
||||
def delPanelLogsApi(self):
|
||||
public.M('logs').where('id>?', (0,)).delete()
|
||||
public.writeLog('面板设置', '面板操作日志已清空!')
|
||||
return public.returnJson(True, '面板操作日志已清空!')
|
||||
|
||||
##### ----- start ----- ###
|
||||
|
||||
def getList(self, page, limit):
|
||||
|
||||
@@ -27,9 +27,9 @@ $(function(){
|
||||
});
|
||||
|
||||
function closeLogs(){
|
||||
$.post('/files?action=CloseLogs','',function(rdata){
|
||||
$.post('/files/close_logs','',function(rdata){
|
||||
$("#logSize").html(rdata.msg);
|
||||
layer.msg(lan.firewall.empty,{icon:1});
|
||||
layer.msg('已清理!',{icon:1});
|
||||
},'json');
|
||||
}
|
||||
|
||||
@@ -145,6 +145,44 @@ function ping(status){
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更改禁ping状态
|
||||
* @param {Int} state 0.禁ping 1.可ping
|
||||
*/
|
||||
function firewall(status){
|
||||
var msg = status == 1 ? '禁PING后不影响服务器正常使用,但无法ping通服务器,您真的要禁PING吗?' : '解除禁PING状态可能会被黑客发现您的服务器,您真的要解禁吗?';
|
||||
layer.confirm(msg,{title:'是否禁ping',closeBtn:2,cancel:function(){
|
||||
if(status == 1){
|
||||
$("#noping").prop("checked",true);
|
||||
} else {
|
||||
$("#noping").prop("checked",false);
|
||||
}
|
||||
}},function(){
|
||||
layer.msg('正在处理,请稍候...',{icon:16,time:20000});
|
||||
$.post('/firewall/set_ping','status='+status, function(data) {
|
||||
layer.closeAll();
|
||||
if (data['status'] == true) {
|
||||
if(status == 1){
|
||||
layer.msg(data['msg'], {icon: 1});
|
||||
} else {
|
||||
layer.msg('已解除禁PING', {icon: 1});
|
||||
}
|
||||
setTimeout(function(){window.location.reload();},3000);
|
||||
} else {
|
||||
layer.msg('连接服务器失败', {icon: 2});
|
||||
}
|
||||
},'json');
|
||||
},function(){
|
||||
if(status == 1){
|
||||
$("#noping").prop("checked",true);
|
||||
} else {
|
||||
$("#noping").prop("checked",false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置远程服务状态
|
||||
* @param {Int} state 0.启用 1.关闭
|
||||
@@ -299,10 +337,10 @@ function getLogs(page,search) {
|
||||
function delLogs(){
|
||||
layer.confirm('即将清空面板日志,继续吗?',{title:'清空日志',closeBtn:2},function(){
|
||||
var loadT = layer.msg('正在清理,请稍候...',{icon:16});
|
||||
$.post('/ajax?action=delClose','',function(rdata){
|
||||
$.post('/firewall/del_panel_logs','',function(rdata){
|
||||
layer.close(loadT);
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||
getLogs(1);
|
||||
});
|
||||
},'json');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user