Files
aaPanel/BTPanel/templates/default/firewall.html
T
2022-12-16 10:40:55 +08:00

743 lines
34 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "layout.html" %}
{% block content %}
<style>
.weblog {
font-size: 14px;
display: inline-block;
line-height: 30px;
}
.weblog em {
font-style: normal;
color: #666;
margin: 0 15px;
font-size:12px;
}
.weblog span {
margin-right: 10px;
}
.weblog a {
color: #20a53a;
}
.firewall-port-box{
margin-bottom:15px;
}
.ssl_login_config_view span{
vertical-align: 5px;
margin-right: 10px;
}
.ssl_login_config_view .btswitch-ios+.btswitch-btn{
display: inline-block;
margin: 5px 0 0 0;
}
.overflow_hide_style{
overflow: hidden;
text-overflow:ellipsis;
white-space:nowrap;
display: inline-block;
cursor: default;
}
.detail.security_detail {
padding: 20px;
}
.detail_block {
padding: 10px 0;
border-bottom: 1px #ececec dashed;
}
.detail_title {
font-weight: 600;
margin-bottom: 5px;
color: #333;
}
pre.layui-code {
position: relative;
margin: 10px 0;
padding: 15px;
line-height: 20px;
border: 1px solid #ddd;
border-left-width: 6px;
background-color: #F2F2F2;
color: red;
font-family: Courier New;
font-size: 12px;
}
.security_detail pre {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}
.detail_tips {
margin-top: 15px;
}
.setchmod {
padding-top: 0;
}
</style>
<div class="main-content">
<div class="container-fluid" style="padding-bottom: 50px;">
<div class="pos-box bgw mtb15">
<div class="position f14 c9 pull-left">
<a class="plr10 c4" href="/">{{data['lan']['H1']}}</a>/<span class="plr10 c4">{{data['lan']['H2']}}</span>
</div>
</div>
<div class="safe container-fluid bgw mtb15 pd15">
<div class="mr20 pull-left">
<form>
<div class="ss-text pull-left">
<em>{{data['lan']['BTN1']}}</em>
<div class='ssh-item' id="in_safe">
<input class='btswitch btswitch-ios' id='sshswitch' type='checkbox' checked><label class='btswitch-btn sshswitch' for='sshswitch' ></label>
</div>
</div>
</form>
</div>
<div class="mr20 pull-left">
<div class="ss-text pull-left mr5">
<em>{{data['lan']['BTN2']}}</em>
<input type="text" class="bt-input-text" id="mstscPort" value="" />
</div>
<div class="ss-text pull-left">
<button id="mstscSubmit" onclick='bt.firewall.set_mstsc($("#mstscPort").prop("value"))' class="btn btn-default btn-sm" type="button">{{data['lan']['BTN3']}}</button>
<button onclick='firewall.open_sshsafe_config_view()' class="btn btn-default btn-sm" type="button">SSH Safety</button>
</div>
</div>
<div class="mr50 pull-left" style="border-right: 1px solid #ccc; padding-right: 40px;">
<div class="ss-text pull-left">
<em>{{data['lan']['BTN4']}}</em>
<div class='ssh-item' id="isPing">
<input class='btswitch btswitch-ios' id='noping' type='checkbox' checked><label class='btswitch-btn noping' for='noping' ></label>
</div>
</div>
</div>
<div class="weblog">
<span class="f12 c5">{{data['lan']['S1']}}</span><a href="javascript:openPath('{{session['logsPath']}}');">{{session['logsPath']}}</a><em id="logSize">0KB</em>
<button class="btn btn-default btn-sm" onclick="firewall.clear_logs_files();">{{data['lan']['BTN5']}}</button>
</div>
</div>
<div class="white-black-ip bgw mtb15">
<div class="black-ip">
<div class="def-log">
<div class="title c6 plr15">
<h3 class="f16">{{data['lan']['H3']}}</h3>
</div>
<div class="divtable pd15">
<div class="firewall-port-box">
<select id="firewalldType" class="bt-input-text c5 mr5" name="type">
<option value="port">{{data['lan']['F1']}}</option>
<option value="address">{{data['lan']['F2']}}</option>
</select><input type="text" class="bt-input-text mr5" style="width: 117px;" id="AcceptPort" placeholder="{{data['lan']['F3']}}"><input type="text" class="bt-input-text mr5" id="Ps" placeholder="{{data['lan']['F4']}}"><button id="toAccept" onclick="firewall.add_accept_port()" class="btn btn-default btn-sm va0" type="button">{{data['lan']['F5']}}</button>
<button class="btn btn-default btn-sm sys_firewall" type="button">SYS Firewall</button>
<span id="f-ps" class="c9" style="margin-left: 10px;">{{data['lan']['F6']}}</span>
</div>
<div class="tablescroll">
<table id="firewallBody" class="table table-hover" style="min-width: 640px;border: 0 none;">
</table>
</div>
<div class="dataTables_paginate paging_bootstrap page firewallBody" style="margin-bottom:0">
</div>
</div>
</div>
</div>
</div>
<div class="white-black-ip bgw mtb15">
<div class="black-ip">
<div class="def-log">
<div class="tootls_group" style="height: 40px;">
<div class="pull-right">
<div class="bt_search" style="margin-top: 10px;margin-right: 15px;">
<input type="text" style="width:260px" class="search_input" placeholder="Please enter a keyword search log"><span onclick="firewall.on_search()" class="glyphicon glyphicon-search" aria-hidden="true"></span>
</div>
</div>
<div class="title c6 plr15">
<h3 class="f16">{{data['lan']['H4']}}</h3>
<a class="btn btn-default btn-sm va0" onclick="bt.firewall.clear_logs(function(){firewall.get_log_list()});">{{data['lan']['BTN5']}}</a>
<span class="btn btn-default btn-sm" style="margin-top: 10px;" onclick="firewall.get_panel_error_logs()">{{data['lan']['PANEL_LOG']}}</span>
</div>
</div>
<div class="divtable pd15">
<div class="tablescroll">
<table id="logsBody" class="table table-hover" style="min-width: 640px;border: 0 none;">
</table>
</div>
<div class="dataTables_paginate paging_bootstrap page logsBody" style="margin-bottom:0">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script type="text/javascript">
var firewall = {
ssl_scanning_list: [], //扫描列表
on_search: function () {
firewall.get_log_list(1, $('.search_input').val());
},
get_init: function () {
firewall.flush_init();
firewall.get_list();
firewall.get_log_list();
firewall.get_logs_size();
$('.sshswitch').click(function(){
var status = $("#sshswitch").prop("checked")==true?1:0;
bt.firewall.set_mstsc_status(status,function(rdata){
if(rdata===-1){
if(status){
$("#sshswitch").prop("checked","checked")
}else{
$("#sshswitch").removeAttr('checked');
}
}else{
bt.msg(rdata);
firewall.flush_init();
}
})
})
$('.noping').click(function(){
var status = $("#noping").prop("checked")==true?1:0;
bt.firewall.ping(status,function(rdata){
if(rdata===-1){
if(status){
$("#noping").prop("checked","checked")
}else{
$("#noping").removeAttr('checked');
}
}else{
bt.msg(rdata);
firewall.flush_init();
}
})
});
$('.sys_firewall').on('click', function () {
$.post('/plugin?action=getConfigHtml', {name: 'firewall'}, function (rdata) {
if(rdata.status == false) {
layer.confirm('The SYS Firewall plugin is not installed, <br>please leave to &quot;<a href="/soft" class="btlink">APP Store > Tools</a>&quot;<br> install SYS Firewall plugin first.',
{title: 'No SYS Firewall', icon: 7, closeBtn: 2,}, function () {
window.location.href = '/soft';
});
} else {
bt.soft.set_lib_config('firewall','SYS Firewall');
}
});
});
$("#firewalldType").change(function(){
var type = $(this).val();
var w = '120px';
var p = lan.firewall.port;
var t = lan.firewall.accept;
var m = lan.firewall.port_ps;
if(type == 'address'){
w = '150px';
p = lan.firewall.ip;
t = lan.firewall.drop;
m = lan.firewall.ip_ps;
}
$("#AcceptPort").css("width",w);
$("#AcceptPort").attr('placeholder',p);
$("#toAccept").html(t);
$("#f-ps").html(m);
});
},
flush_init:function(){
bt.firewall.get_ssh_info(function(rdata){
if(!rdata.status){
$("#mstscSubmit").attr('disabled','disabled')
$("#mstscPort").attr('disabled','disabled')
$('#sshswitch').removeAttr('checked');
}
else{
$("#mstscSubmit").removeAttr('disabled')
$("#mstscPort").removeAttr('disabled')
$('#sshswitch').attr('checked','checked');
}
if(rdata.ping){
$('#noping').removeAttr('checked');
}else{
$('#noping').attr('checked','checked');
}
$("#mstscPort").val(rdata.port);
})
},
///////////SSH安全管理功能开始
open_sshsafe_config_view:function(){
var _this = this;
layer.open({
type: 1,
title: "SSH Safety",
area: '700px',
closeBtn: 2,
shadeClose: false,
content:'<div class="bt-form">\
<div class="bt-w-main">\
<div class="bt-w-menu" style="width: 130px;"><p class="bgw">Risk reminder</p><p>Login Method</p><p>Login alarm</p><p>Login logs</p></div>\
<div class="bt-w-con pd15 divtable" style="margin-left: 130px;">\
<div class="bt-box">\
<div class="divtable">\
<table class="table table-hover">\
<thead><tr><th width="100">Risk name</th><th>Recommendations for hardening</th><th style="text-align: right;">Operation</th></tr></thead>\
</table>\
</div>\
<div class="divtable ssh_list_switch" style="height: 479px;overflow: auto;">\
<table class="table table-hover"><thead></thead><tbody id="ssh_scanning"></tbody></table>\
</div>\
</div>\
<div class="bt-box" style="display: none;">\
<div class="bt-form">\
<div class="line">\
<span class="tname">Password login</span>\
<div class="info-r c4">\
<input class="btswitch btswitch-ios" id="ssh_paw" type="checkbox"><label class="btswitch-btn" for="ssh_paw" title="SSH Password login" style="display: inline-block;"></label>\
<div style="margin-left:40px;display: inline-block;"><span class="tname">Key login</span>\
<input class="btswitch btswitch-ios" id="ssh_key" type="checkbox">\
<label class="btswitch-btn" for="ssh_key" title="SSH Key login"style="margin: 5px 0 0 117px;"></label>\
</div>\
</div>\
</div>\
<div class="line">\
<span class="tname">SSH Key</span>\
<div class="info-r c4">\
<textarea id="ssh_text_key" class="bt-input-text mr20" style="height:180px;width:330px"></textarea>\
</div>\
</div>\
<div style="margin-left:123px" class="btn-sshkey-group">\
<button type="button" class="btn btn-success btn-sm btn-copy-sshkey">Copy</button>\
<button type="button" class="btn btn-success btn-sm btn-download-sshkey">Download</button>\
</div>\
</div>\
</div>\
<div class="bt-box" style="display: none;">\
<button class="btn btn-success btn-sm add_white_ip" type="button">Add IP white list</button>\
<div class="pull-right ssl_login_config_view"><span>Monitor root login</span><input class="btswitch btswitch-ios" id="ssh_root_login" type="checkbox"><label class="btswitch-btn" for="ssh_root_login" title="Monitor root login"></label></div>\
<div class="divtable mtb15" style="max-height: 441px;overflow: auto;">\
<table id="ssh_ip_white_table" class="table table-hover" style="min-width: 500px;"></table>\
</div>\
<ul class="help-info-text c7">\
<li>This list is an IP whitelist, and no alarm will be issued when these IPs log in</li>\
</ul>\
</div>\
<div class="bt-box" style="display: none;">\
<table id="ssh_logs_table" class="table table-hover" style="min-width: 500px;"></table>\
<div class="page">\
<div id="ssh_logs"></div>\
</div>\
</div>\
</div>\
</div></div>',
success(layers,index){
firewall.ssh_list_view();
//导航事件
$(".bt-w-menu p").click(function(){
var index = $(this).index();
$(this).addClass("bgw").siblings().removeClass("bgw");
$('.bt-w-con .bt-box').eq(index).show().siblings().hide();
switch(index){
case 0:
firewall.ssh_list_view();
break;
case 1:
firewall.get_ssh_config();
break;
case 2:
firewall.get_white_ip();
break;
case 3:
firewall.get_logs_view({p:1});
break;
}
});
// 复制按钮
$('.btn-copy-sshkey').click(function(){
bt.pub.copy_pass($('#ssh_text_key').val());
})
// 下载
$('.btn-download-sshkey').click(function(){
window.open('/download?filename=/root/.ssh/id_rsa')
})
// 添加ip白名单
$(".add_white_ip").click(function(){
layer.open({
type: 1,
title: "Add detection IP white list",
area: '340px',
closeBtn: 2,
shadeClose: false,
btn:['Confirm','Cancel'],
content: '<div class="bt-form pd20">\
<div class="line">\
<span class="tname" style="width: 83px;">IP address</span>\
<div class="info-r" style="margin-left: 83px;">\
<input name="ip_white" placeholder="Please enter the correct IP address" class="bt-input-text mr5" type="text" style="width: 211px;">\
</div>\
</div>\
</div>',
yes:function(index,layers){
var ip_white = $('[name="ip_white"]').val();
if (ip_white == '') {
layer.msg('NO IP address!', {icon: 2});
return false;
}else if(!bt.check_ip(ip_white)){
layer.msg('Wrong IP addressPlease enter the correct IP address!', {icon: 2})
return false;
}
$.post('/ssh_security?action=add_return_ip', {ip:ip_white}, function (res) {
layer.msg(res.msg,{icon:res.status?1:2})
if(res.status){
layer.close(index);
firewall.get_white_ip();
}
})
}
})
})
// 密码开关
$('#ssh_paw').change(function(){
var start = $('#ssh_paw').prop("checked");
if(start){
$.post('/ssh_security?action=set_password', {}, function (res) {layer.msg(res.msg,{icon:res.status?1:2})})
}else{
$.post('/ssh_security?action=stop_password', {}, function (res) {layer.msg(res.msg,{icon:res.status?1:2})})
}
})
// 密钥开关
$('#ssh_key').change(function(){
var start = $('#ssh_key').prop("checked");
if(start){
firewall.set_template_sshkey();
}else{
$.post('/ssh_security?action=stop_key', {}, function (res) {
layer.msg(res.msg,{icon:res.status?1:2})
firewall.get_ssh_config();
})
}
});
// root监控开关
$('#ssh_root_login').change(function(){
var start = $('#ssh_root_login').prop("checked");
if(start){
$.post('/config?action=get_settings2',function(res){
if(res['user_mail']['user_name']){
$.post('/ssh_security?action=start_jian', {}, function (res) {layer.msg(res.msg,{icon:res.status?1:2})})
}else{
layer.msg('Please go to panel Settings-->Message channel-->Set email',{icon:2,time:10000})
$('#ssh_root_login').attr("checked",false);
}
})
}else{
$.post('/ssh_security?action=stop_jian', {}, function (res) {layer.msg(res.msg,{icon:res.status?1:2})})
}
})
$('#ssh_logs').on('click','a',function(e){
var page = $(this).attr('href').replace('/ssh_security?action=get_logs?p=','');
firewall.get_logs_view({p:page});
e.preventDefault();
e.stopPropagation();
});
}
})
},
// 风险提醒
ssh_list_view:function(){
var that = this;
$.post('/ssh_security?action=san_ssh_security',function(res){
that.ssl_scanning_list = res.result;
var _tbody = ''
if(res.result.length > 1){
for(var i =0; i<res.result.length; i++){
_tbody += '<tr>\
<td><span title="'+res.result[i].name+'" style="width:95px" class="overflow_hide_style">'+res.result[i].name+'</span></td>\
<td><span title="'+res.result[i].Suggestions+'" style="width:333px" class="overflow_hide_style">'+res.result[i].Suggestions+'</span></td>\
<td style="text-align:right"><a href="javascript:;" class="btlink" onclick="firewall.ssh_scanning_detail('+i+')">Detail</a></td>\
</tr>'
}
}else{
_tbody='<tr><td colspan="3" style="text-align:center">No data</td></tr>'
}
$('#ssh_scanning').html(_tbody)
})
},
// 详情视图
ssh_scanning_detail:function(index){
var item = this.ssl_scanning_list[index];
layer.open({
type: 1,
title:'View details [ '+ item.name +' ]',
area: '500px',
closeBtn:2,
btn: ['Confirm'],
content:'<div class="detail security_detail">\
<div class="detail_block">\
<div class="detail_title">Risk name</div>\
<div class="detail_conter"><span style="color:red">'+item.name+'</span></div>\
</div>\
<div class="detail_block">\
<div class="detail_title">Reinforcement recommendations</div>\
<div class="detail_conter">\
<span>'+(item.Suggestions || item.ps || '')+'</span>'+(item.repair != item.Suggestions? '<pre class="layui-code">'+item.repair+'</pre>': '')+''+(item.list != undefined ? '<pre class="layui-code">'+item.list+'</pre>' : '')+'\
</div>\
</div>\
<div class="detail_tips">It is recommended to make records and backup during operation</div>\
</div>',
yes:function(index, layero){
layer.close(index);
}
})
},
// 安全扫描详情
ssh_scanning_move:function(num){
console.log(num)
},
set_template_sshkey:function(){
var _this = this;
var loadT = layer.open({
title:'Enable SSH key login',
area:'300px',
type:1,
closeBtn: 2,
content:'<div class="bt-form bt-form pd20 pb70">'+
'<div class="line "><span class="tname" style="width:155px">SSH password login</span><div class="info-r "><select class="bt-input-text mr5 ssh_select_login" style="width:79px"><option value="yes">Open</option><option value="no">Close</option></select></div></div>'+
'<div class="line "><span class="tname" style="width:155px">Key encryption method</span><div class="info-r "><select class="bt-input-text mr5 ssh_select_encryption" style="width:79px"><option value="ed25519">ed25519</option><option value="rsa">rsa</option><option value="dsa">dsa</option></select></div></div>'+
'<div class="bt-form-submit-btn"><button type="button" class="btn btn-sm btn-danger close_ssh_key">Close</button><button type="button" class="btn btn-sm btn-success submit_ssh_key">Submit</button></div>'+
'</div>',
cancel: function(){
$('#ssh_key').prop('checked',false);
}
});
$('.close_ssh_key').click(function(){
$('#ssh_key').prop('checked',false);
layer.close(loadT);
});
$('.submit_ssh_key').click(function(){
var ssh_select_login = $('.ssh_select_login').val();
var ssh_select_encryption = $('.ssh_select_encryption').val();
$.post('/ssh_security?action=set_sshkey', {ssh:ssh_select_login,type:ssh_select_encryption}, function (res) {
layer.msg(res.msg,{icon:res.status?1:2})
_this.get_ssh_config();
layer.close(loadT);
})
});
},
// 获取SSH密钥状态
get_ssh_config:function(){
$.post('/ssh_security?action=get_config', {}, function (res) {
var paw = res.password == 'yes'?true:false;
var key = (res.pubkey == 'yes' && res.rsa_auth == 'yes') ? true : false;
$('#ssh_paw').prop('checked',paw);
$('#ssh_key').prop('checked',key);
if(key){
$.post('/ssh_security?action=get_key', {}, function (res) {
if(res.status){
$('#ssh_text_key').val(res.msg).removeAttr('disabled');
$('.btn-sshkey-group').show();
}else{
layer.msg(res.msg,{icon:2});
}
});
}else{
$('.btn-sshkey-group').hide();
$('#ssh_text_key').val('').attr('disabled','disabled')
}
})
},
// 获取ip地址白名单列表、root用户登录状态
get_white_ip:function(){
// 监控状态
$.post('/ssh_security?action=get_jian', {}, function (res) {
$('#ssh_root_login').prop("checked",res.status)
})
$.post('/ssh_security?action=return_ip',{}, function(res){
var _tab = bt.render({
table:'#ssh_ip_white_table',
columns:[
{ title: "IP address",templet:function(item){
return item;
}},
{ field: 'opt',align:'right',width:50, title: "Operation",templet:function(item){
return '<a href="javascript:;" class="btlink" onclick="firewall.remove_ip_white(\''+item+'\')">Delete</a>';
}}
],
data:res.msg
})
})
},
// 删除ip白名单
remove_ip_white:function(obj){
$.post('/ssh_security?action=del_return_ip', {ip:obj}, function (res) {
layer.msg(res.msg,{icon:res.status?1:2})
if(res.status){
firewall.get_white_ip();
}
})
},
// 登录日志
get_logs_view:function(obj){
$.post('/ssh_security?action=get_logs',{p:obj.p}, function(res){
$("#ssh_logs").html(res.page)
var _tab = bt.render({
table:'#ssh_logs_table',
columns:[
{ title: "Detail",templet:function(item){
return '<span title="'+item.log+'" class="overflow_hide_style" style="width:330px">'+item.log+'</span>';
}},
{ field: 'Login time',align:'right',width:140, title: "Login time",templet:function(item){
return item.addtime
}}
],
data:res.data
})
})
},
///////////SSH安全管理功能结束
get_logs_size:function(){
bt.firewall.get_logs_size(function(rdata){
$("#logSize").text(rdata);
})
},
clear_logs_files:function(){
bt.firewall.clear_logs_files(function(rdata){
$("#logSize").text(rdata);
bt.msg({msg:lan.firewall.empty,icon:1});
})
},
add_accept_port:function(){
var type = $("#firewalldType").val();
var port = $("#AcceptPort").val();
var ps = $("#Ps").val();
bt.firewall.add_accept_port(type,port,ps,function(rdata){
if(rdata.status){
firewall.get_list();
$("#AcceptPort").val('');
$("#Ps").val('');
}
bt.msg(rdata);
})
},
remove_accept_port: function (id,port) {
bt.firewall.del_accept_port(id, port, function (rdata) {
if (rdata.status) {
firewall.get_list();
}
bt.msg(rdata);
})
},
get_list:function(page,search){
if (page == undefined) page = 1;
if (!search) search = $("#SearchValue").val();
bt.firewall.get_list(page, search, function (rdata) {
$('.firewallBody').html(rdata.page);
var ports_ps = {"80": lan.firewall.site_default_port, "3306": lan.firewall.mysql_default_port, "888": lan.firewall.phpmmyadmin_default_port, "22": lan.firewall.ssh_default_port, "20": lan.firewall.ftp1_default_port, "21": lan.firewall.ftp_default_port, "39000-40000": lan.firewall.ftp2_default_port, "30000-40000": lan.firewall.ftp2_default_port,"11211":lan.firewall.mem_default_port,"873":lan.firewall.rsync_default_port,"8888":lan.firewall.bt_default_port}
var _tab = bt.render({
table:'#firewallBody',
columns:[
{ field: 'id', title: lan.firewall.number},
{ field: 'port', title: lan.firewall.behavior,templet:function(item){
var _ps = lan.firewall.accept_port;
if(bt.contains(item.port,'.')){
_ps = lan.firewall.drop_ip;
}
_ps += ':['+item.port+']'
return _ps;
}},
{ field: 'status', title: lan.firewall.status,templet:function(item){
var status = '';
switch(item.status){
case 0:
status = lan.firewall.status_not;
break;
case 1:
status = lan.firewall.status_net;
break;
default:
status = lan.firewall.status_ok;
break;
}
return status;
},help:'https://forum.aapanel.com/d/1088-description-of-firewall-status'},
{ field: 'addtime', title: lan.firewall.add_time},
{ field: 'ps', title: lan.firewall.instructions, templet: function (item) {
if (item.port in ports_ps) return ports_ps[item.port];
return item.ps;
}},
{ field: 'opt',align:'right',width:50, title: lan.firewall.operate,templet:function(item){
return '<a href="javascript:;" class="btlink" onclick="firewall.remove_accept_port('+item.id+',\''+item.port+'\')">'+lan.firewall.del+'</a>';
}}
],
data:rdata.data
})
})
},
get_log_list:function(page,search){
if (page == undefined) page = 1;
if (search == undefined) search = $("#SearchValue").val();
bt.firewall.get_log_list(page,search,function(rdata){
$('.logsBody').html(rdata.page);
var _tab = bt.render({
table:'#logsBody',
columns:[
{ field: 'id', title: lan.firewall.number},
{ field: 'type', title: lan.firewall.operate_type},
{ field: 'log', title: lan.firewall.detail},
{ field: 'addtime', title: lan.firewall.operate_time}
],
data:rdata.data
})
})
},
//查看面板运行日志
get_panel_error_logs: function () {
layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=get_panel_error_logs', {}, function (rdata) {
layer.closeAll();
if (!rdata.status) {
layer.msg(rdata.msg, { icon: 2 });
return;
};
layer.open({
type: 1,
title: '{{data["lan"]["PANEL_LOG"]}}',
area: ['700px', '496px'],
shadeClose: false,
closeBtn: 2,
content: '<div class="setchmod bt-form pb70">'
+ '<pre class="crontab-log" style="overflow: auto; border: 0px none; line-height:23px;padding: 15px; margin: 0px; white-space: pre-wrap; height: 405px; background-color: rgb(51,51,51);color:#f1f1f1;border-radius:0px;font-family: \"微软雅黑\"">' + (rdata.msg == '' ? '{{data["lan"]["LOG_EMPTY"]}}' : rdata.msg) + '</pre>'
+ '<div class="bt-form-submit-btn" style="margin-top: 0px;">'
+ '<button type="button" class="btn btn-danger btn-sm btn-title" style="margin-right:15px;" onclick="firewall.clean_panel_error_logs()">' + lan.public.empty + '</button>'
+ '<button type="button" class="btn btn-success btn-sm btn-title" onclick="layer.closeAll()">' + lan.public.close + '</button>'
+ '</div>'
+ '</div>'
});
setTimeout(function () {
$("#crontab-log").text(rdata.msg);
var div = document.getElementsByClassName('crontab-log')[0]
div.scrollTop = div.scrollHeight;
}, 200)
}).error(function () {
layer.closeAll();
layer.msg('{{data["lan"]["UNABLE_RETRIEVE_LOG"]}}', { icon: 2 });
});
},
//清空面板错误日志
clean_panel_error_logs:function() {
layer.msg(lan.public.the_get, { icon: 16, time: 0, shade: [0.3, '#000'] });
$.post('/config?action=clean_panel_error_logs', {}, function (rdata) {
layer.closeAll();
layer.msg(rdata.msg, { icon: 1 });
});
}
}
firewall.get_init();
</script>
{% endblock %}