setTimeout(function(){ getSshInfo(); },500); setTimeout(function(){ showAccept(1); },1000); setTimeout(function(){ getLogs(1); },1500); function closeLogs(){ $.post('/files?action=CloseLogs','',function(rdata){ $("#logSize").html(rdata); layer.msg(lan.firewall.empty,{icon:1}); },'json'); } $(function(){ $.post('/files/get_dir_size','path=/Users/midoks/Desktop/fwww/wwwlogs', function(rdata){ $("#logSize").html(rdata); },'json'); }) $("#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); }); function getSshInfo(){ $.post('/firewall/get_ssh_info', '',function(rdata){ console.log(rdata); var SSHchecked = '' if(rdata.status){ SSHchecked = "" }else{ SSHchecked = "" $("#mstscSubmit").attr('disabled','disabled') $("#mstscPort").attr('disabled','disabled') } $("#in_safe").html(SSHchecked) $("#mstscPort").val(rdata.port) var isPint = "" if(rdata.ping){ isPing = "" }else{ isPing = "" } $("#isPing").html(isPing) },'json'); } /** * 修改远程端口 */ function mstsc(port) { layer.confirm(lan.firewall.ssh_port_msg, {title: lan.firewall.ssh_port_title}, function(index) { var data = "port=" + port; var loadT = layer.load({ shade: true, shadeClose: false }); $.post('/firewall?action=SetSshPort', data, function(ret) { layer.msg(ret.msg,{icon:ret.status?1:2}) layer.close(loadT) getSshInfo() }); }); } /** * 更改禁ping状态 * @param {Int} state 0.禁ping 1.可ping */ function ping(status){ var msg = status==0?lan.firewall.ping_msg:lan.firewall.ping_un_msg; layer.confirm(msg,{title:lan.firewall.ping_title,closeBtn:2,cancel:function(){ if(status == 1){ $("#noping").prop("checked",true); } else{ $("#noping").prop("checked",false); } }},function(){ layer.msg(lan.public.the,{icon:16,time:20000}); $.post('/firewall?action=SetPing','status='+status, function(ret) { layer.closeAll(); if (ret.status == true) { if(status == 0){ layer.msg(lan.firewall.ping, {icon: 1}); } else{ layer.msg(lan.firewall.ping_un, {icon: 1}); } setTimeout(function(){window.location.reload();},3000); } else { layer.msg(lan.firewall.ping_err, {icon: 2}); } }) },function(){ if(status == 1){ $("#noping").prop("checked",true); } else{ $("#noping").prop("checked",false); } } ) } /** * 设置远程服务状态 * @param {Int} state 0.启用 1.关闭 */ function SetMstscStatus(){ status = $("#sshswitch").prop("checked")==true?1:0; var msg = status==1?lan.firewall.ssh_off_msg:lan.firewall.ssh_on_msg; layer.confirm(msg,{title:lan.public.warning,closeBtn:2,cancel:function(){ if(status == 0){ $("#sshswitch").prop("checked",false); } else{ $("#sshswitch").prop("checked",true); } }},function(index){ if(index > 0){ layer.msg(lan.public.the,{icon:16,time:20000}); $.post('/firewall?action=SetSshStatus','status='+status,function(rdata){ layer.closeAll(); layer.msg(rdata.msg,{icon:rdata.status?1:2}); refresh(); }) } },function(){ if(status == 0){ $("#sshswitch").prop("checked",false); } else{ $("#sshswitch").prop("checked",true); } }) } /** * 取回数据 * @param {Int} page 分页号 */ function showAccept(page,search) { search = search == undefined ? '':search; var loadT = layer.load(); $.post('/firewall/get_list','limit=10&p=' + page+"&search="+search, function(data) { layer.close(loadT); var body = ''; for (var i = 0; i < data.data.length; i++) { var status = ''; switch(data.data[i].status){ case 0: status = '未使用'; break; case 1: status = '外网不通'; break; default: status = '正常'; break; } body += "