// bt.pub.check_install(function (rdata) { // if (rdata === false) bt.index.rec_install(); // }) $("select[name='network-io']").change(function () { var net_key = $(this).val(); if (net_key == 'all') net_key = ''; bt.set_cookie('network_io_key', net_key); }); $("select[name='network-io'],select[name='disk-io']").change(function () { var key = $(this).val(), type = $(this).attr('name'); if (type == 'network-io') { if (key == 'all') key = ''; bt.set_cookie('network_io_key', key); } else { bt.set_cookie('disk_io_key', key); } }); $('.tabs-nav span').click(function () { var indexs = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.tabs-content .tabs-item:eq(' + indexs + ')') .addClass('tabs-active') .siblings() .removeClass('tabs-active'); $('.tabs-down select:eq(' + indexs + ')') .removeClass('hide') .siblings() .addClass('hide'); switch (indexs) { case 0: index.net.table.resize(); break; case 1: index.iostat.table.resize(); break; } }); var interval_stop = false; var index = { warning_list: [], warning_num: 0, warning_list: [], warning_num: 0, series_option: {}, // 配置项 chart_json: {}, // 所有图表echarts对象 chart_view: {}, // 磁盘echarts对象 disk_view: [], // 释放内存标记 chart_result: null, release: false, load_config: [ { title: lan.index.run_block, val: 90, color: '#dd2f00', }, { title: lan.index.run_slow, val: 80, color: '#ff9900', }, { title: lan.index.run_normal, val: 70, color: '#20a53a', }, { title: lan.index.run_fluent, val: 30, color: '#20a53a', }, ], interval: { limit: 10, count: 0, task_id: 0, start: function () { var _this = this; _this.count = 0; _this.task_id = setInterval(function () { if (_this.count >= _this.limit) { _this.reload(); return; } _this.count++; if (!interval_stop) index.reander_system_info(); }, 3000); }, reload: function () { var _this = this; if (_this) clearInterval(_this.task_id); _this.start(); }, }, net: { table: null, data: { uData: [], dData: [], aData: [], }, init: function () { //流量图表 index.net.table = echarts.init(document.getElementById('NetImg')); var obj = {}; obj.dataZoom = []; obj.unit = lan.index.unit + ':KB/s'; obj.tData = index.net.data.aData; obj.list = []; obj.list.push({ name: lan.index.net_up, data: index.net.data.uData, circle: 'circle', itemStyle: { normal: { color: '#f7b851' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: 'rgba(255, 140, 0,1)' }, { offset: 1, color: 'rgba(255, 140, 0,.4)' }, ], false ), }, }, lineStyle: { normal: { width: 1, color: '#f7b851' } }, }); obj.list.push({ name: lan.index.net_down, data: index.net.data.dData, circle: 'circle', itemStyle: { normal: { color: '#52a9ff' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: 'rgba(30, 144, 255,1)' }, { offset: 1, color: 'rgba(30, 144, 255,.4)' }, ], false ), }, }, lineStyle: { normal: { width: 1, color: '#52a9ff' } }, }); option = bt.control.format_option(obj); index.net.table.setOption(option); window.addEventListener('resize', function () { index.net.table.resize(); }); }, add: function (up, down) { var _net = this; var limit = 8; var d = new Date(); if (_net.data.uData.length >= limit) _net.data.uData.splice(0, 1); if (_net.data.dData.length >= limit) _net.data.dData.splice(0, 1); if (_net.data.aData.length >= limit) _net.data.aData.splice(0, 1); _net.data.uData.push(up); _net.data.dData.push(down); _net.data.aData.push(d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()); }, }, iostat: { table: null, data: { uData: [], dData: [], aData: [], tipsData: [], }, init: function () { //流量图表 index.iostat.table = echarts.init(document.getElementById('IoStat')); var obj = {}; obj.dataZoom = []; obj.unit = lan.index.unit + ':MB/s'; obj.tData = index.iostat.data.aData; obj.formatter = function (config) { var _config = config, _tips = 'Time:' + _config[0].axisValue + '
', options = { read_bytes: 'Read Bytes', read_count: 'Read Count ', read_merged_count: 'Read Merged Count', read_time: 'Read Wait', write_bytes: 'Write Bytes', write_count: 'Write Count', write_merged_count: 'Write Merged Count', write_time: 'Write Wait', }, data = index.iostat.data.tipsData[config[0].dataIndex], list = ['read_count', 'write_count', 'read_merged_count', 'write_merged_count', 'read_time', 'write_time']; for (var i = 0; i < config.length; i++) { if (typeof config[i].data == 'undefined') return false; _tips += '  ' + config[i].seriesName + ':' + parseFloat(config[i].data).toFixed(2) + ' MB/s' + '
'; } $.each(list, function (index, item) { _tips += '  ' + options[item] + ':' + data[item] + (item.indexOf('time') > -1 ? ' ms' : ' per sec') + '
'; }); return _tips; }; obj.list = []; obj.list.push({ name: 'Read Bytes', data: index.iostat.data.uData, circle: 'circle', itemStyle: { normal: { color: '#FF4683' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: 'rgba(255,70,131,1)' }, { offset: 1, color: 'rgba(255,70,131,.4' }, ], false ), }, }, lineStyle: { normal: { width: 1, color: '#FF4683' } }, }); obj.list.push({ name: 'Write Bytes', data: index.iostat.data.dData, circle: 'circle', itemStyle: { normal: { color: '#6CC0CF' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient( 0, 0, 0, 1, [ { offset: 0, color: 'rgba(108,192,207,1)' }, { offset: 1, color: 'rgba(108,192,207,.4)' }, ], false ), }, }, lineStyle: { normal: { width: 1, color: '#6CC0CF' } }, }); option = bt.control.format_option(obj); index.iostat.table.setOption(option); window.addEventListener('resize', function () { index.iostat.table.resize(); }); }, add: function (read, write, data) { var _disk = this; var limit = 8; var d = new Date(); if (_disk.data.uData.length >= limit) _disk.data.uData.splice(0, 1); if (_disk.data.dData.length >= limit) _disk.data.dData.splice(0, 1); if (_disk.data.aData.length >= limit) _disk.data.aData.splice(0, 1); if (_disk.data.tipsData.length >= limit) _disk.data.tipsData.splice(0, 1); _disk.data.uData.push(read); _disk.data.dData.push(write); _disk.data.tipsData.push(data); _disk.data.aData.push(d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()); }, }, mem: { status: 1, set_status: function (obj, status, val) { var _this = this; _this.status = status; var _div = $('
1
'); if (status == 2) { obj.find('.mem-re-con').animate({ top: '-400px', opacity: 0 }); //动画 var btlen = parseInt(obj.find('.occupy span').html()); for (var i = 0; i < btlen; i++) { setTimeout(index.set_val(obj.parents('li'), { usage: btlen - i }), i * 30); } obj.addClass('mem-action'); obj.find('.occupy').html(_div.append(lan.index.memre_ok_0 + ' ').html()); } else if (status == 1) { //完成 obj.removeClass('mem-action'); obj .find('.occupy') .removeClass('line') .html('' + val + '%'); } else { obj.find('.occupy').html(_div.append(status).html()); if (bt.contains(status, '
')) obj.find('.occupy').addClass('line'); } }, }, get_init: function () { var _this = this; // setTimeout(function () { _this.get_disk_list(); }, 10); setTimeout(function () { _this.get_warning_list(); }, 20); // setTimeout(function () { _this.get_server_info(); }, 30); _this.reander_system_info(function (rdata) { // 负载悬浮事件 $('#loadChart').hover( function () { var arry = [ [lan.index.avg_load_atlast_onemin, rdata.load.one], [lan.index.avg_load_atlast_fivemin, rdata.load.five], [lan.index.avg_load_atlast_fifteenmin, rdata.load.fifteen], ], tips = ''; $.each(arry || [], function (index, item) { tips += item[0] + ':' + item[1] + '
'; }); $.each(rdata.cpu_times || {}, function (key, item) { tips += key + ':' + item + '
'; }); // '最近1分钟平均负载:' + rdata.load.one + '
最近5分钟平均负载:' + rdata.load.five + '
最近15分钟平均负载:' + rdata.load.fifteen + '' layer.tips(tips, this, { time: 0, tips: [1, '#999'] }); }, function () { layer.closeAll('tips'); } ); // cpu悬浮事件 $('#cpuChart').hover( function () { var cpuText = ''; for (var i = 1; i < rdata.cpu[2].length + 1; i++) { var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1); if (i % 2 != 0) { cpuText += 'CPU-' + i + ':' + cpuUse + '% | '; } else { cpuText += 'CPU-' + i + ':' + cpuUse + '%'; cpuText += `\n`; } } layer.tips(rdata.cpu[3] + '
' + rdata.cpu[5] + ' CPU,' + rdata.cpu[4] + ' Physical core, ' + rdata.cpu[1] + ' Logical core
' + cpuText, this, { time: 0, tips: [1, '#999'] }); }, function () { layer.closeAll('tips'); } ); $('#memChart') .hover( function () { $(this).append('
'); $(this).find('.mem_mask .mem-re-con').animate({ top: '5px' }, 400); $(this).next().hide(); }, function () { $(this).find('.mem_mask').remove(); $(this).next().show(); } ) .click(function () { var that = $(this); var data = _this.chart_result.mem; bt.show_confirm(lan.index.mem_release_sure, '' + lan.index.mem_release_warn + '', function () { _this.release = true; var option = JSON.parse(JSON.stringify(_this.series_option)); // 释放中... var count = ''; var setInter = setInterval(function () { if (count == '...') { count = '.'; } else { count += '.'; } option.series[0].detail.formatter = lan.index.memre_ok_0 + count; option.series[0].detail.fontSize = 15; option.series[0].data[0].value = 0; _this.chart_view.mem.setOption(option, true); that.next().hide(); }, 400); // 释放接口请求 bt.system.re_memory(function (res) { that.next().show(); clearInterval(setInter); option.series[0].detail = $.extend(option.series[0].detail, { formatter: lan.index.memre_ok_1 + '\n' + bt.format_size(data.memRealUsed - res.memRealUsed), lineHeight: 18, padding: [5, 0], }); _this.chart_view.mem.setOption(option, true); setTimeout(function () { _this.release = false; _this.chart_result.mem = res; _this.chart_active('mem'); }, 2000); }); }); }); // 磁盘悬浮事件 // for(var i = 0; i < rdata.disk.length; i++){ // var disk = rdata.disk[i],texts = ""+lan.index.base_info+"
" // texts += "Partition: " + disk.filesystem + "
" // texts += "Type: " + disk.type + "
" // texts += "Mount point: " + disk.path + "

" // texts += ""+ lan.index.inode_info +":
" // texts += lan.index.total+": " + disk.inodes[0] + "
" // texts += lan.index.already_use+": " + disk.inodes[1] + "
" // texts += lan.index.available+": " + disk.inodes[2] + "
" // texts += lan.index.inode_percent+": " + disk.inodes[3] + "

" // texts += ""+lan.index.capacity_info+"
" // texts += lan.index.capacity+": " + disk.size[0] + "
" // texts += lan.index.already_use+": " + disk.size[1] + "
" // texts += lan.index.available+": " + disk.size[2] + "
" // texts += lan.index.usage_rate+": " + disk.size[3] + "
" // $("#diskChart" + i).data('title',texts).hover(function () { // layer.tips($(this).data('title'), this, { time: 0, tips: [1, '#999'] }); // }, function(){ // layer.closeAll('tips'); // }) // } var is_remove_disk = [], idx = 0, taskStatus = []; //扫描状态 for (var i = 0; i < rdata.disk.length; i++) { is_remove_disk.push(true); taskStatus.push(false); var mouseX = 0, mouseY = 0; $(document).mousemove(function (e) { mouseY = e.pageY; mouseX = e.pageX; }); var diskInterval = null; $('#diskChart' + i) .data('disk', rdata.disk[i]) .hover( function () { var disk = $(this).data('disk'); clearInterval(diskInterval); var top = $(this).offset().top, left = $(this).offset().left, used_size = parseFloat(disk.size[3].substring(0, disk.size[3].lastIndexOf('%'))); idx = $(this).prop('id').replace('diskChart', ''); for (var i = 0; i < is_remove_disk.length; i++) { if (i !== parseInt(idx) && is_remove_disk[i]) { $('.disk_scanning_tips' + i).remove(); } } if (!$('.disk_scanning_tips' + idx).length) { layer.open({ type: 1, closeBtn: 1, shade: 0, area: '320px', title: false, skin: 'disk_scanning_tips disk_scanning_tips' + idx, content: '
\
\
\ Disk space:
' + (used_size >= 80 ? 'Lack' : 'Plenty') + '
\
\
\
\
Basic information
\
\
\
Type:' + disk.type + '
\
Mount point:
' + disk.path + '
\
' + disk.size[3] + '
\
Available:' + parseFloat(disk.size[2]) + ' ' + disk.size[2].replace(parseFloat(disk.size[2]), '') + ',Total:' + parseFloat(disk.size[0]) + ' ' + disk.size[0].replace(parseFloat(disk.size[0]), '') + '\n Used:' + parseFloat(disk.size[1]) + ' ' + disk.size[1].replace(parseFloat(disk.size[1]), '') + ',System:' + disk.size[4] + '
\
\
\
\
\
\
Other information
\
\
\
File system:
' + disk.filesystem + '
\
Total Inodes:' + disk.inodes[0] + '
\
Used Inode:' + disk.inodes[1] + '
\
Available Inode:' + disk.inodes[2] + '
\
Usage Inode:' + disk.inodes[3] + '
\
\
\
\
\
\ \
磁盘扫描
\
\
\
正在获取扫描日志
\
\
\ \
\
\
\
文件名
\
大小
\
操作
\
\
\
\
\
\
', success: function (layero, index) { is_remove_disk[idx] = true; // $(layero).find('.layui-layer-close2').addClass('layui-layer-close1').removeClass('layui-layer-close2'); $(layero).find('.layui-layer-close2').remove(); $(layero).css({ top: top + 140 - $(window).scrollTop() + 'px', left: left - 160, }); $(window).resize(function () { for (var i = 0; i < is_remove_disk.length; i++) { if ($('.disk_scanning_tips' + i).length) { $('.disk_scanning_tips' + i).css({ top: $('#diskChart' + i).offset().top + 140 - $(window).scrollTop() + 'px', left: $('#diskChart' + i).offset().left - 160, }); } } }); $(window).scroll(function () { $(layero).css({ top: $('#diskChart' + idx).offset().top + 140 - $(window).scrollTop() + 'px', left: $('#diskChart' + idx).offset().left - 160, }); }); var id = null, // 扫描id taskPath = '', // 扫描目录 taskList = {}; // 扫描缓存列表 //展示收起 // $(layero).find('.disk-item-header').on('click', function () { // if ($(this).parent().hasClass('active')) { // $(this).parent().removeClass('active'); // $(this).find('span').text('展示'); // $(this).find('img').removeAttr('style'); // } else { // $(this).parent().addClass('active'); // $(this).find('span').text('收起'); // $(this).find('img').css('transform', 'rotate(180deg)'); // } // }) // 后退 $(layero) .find('.disk_back_btn') .on('click', function () { var path = $(this).data('path'), index = $(this).data('index'); if (path !== undefined && path !== 'undefined') { if (path === '') { $(layero).find('.filescan-nav-item.present').click(); $(this).data('path', 'undefined'); } else { var rdata = taskList[path.replace('//', '/')]; renderFilesTable(rdata, path); // 渲染文件表格 renderFilesPath(path); // 渲染文件路径 } } else { if (taskStatus[index]) { layer.confirm( '取消扫描,将会中断当前扫描目录进程,是否继续?', { title: '取消扫描', closeBtn: 2, icon: 3, }, function (indexs) { taskStatus[index] = false; layer.close(indexs); cancelScanTaskRequest(id, function (rdata) { if (!rdata.status) return bt_tools.msg(rdata); renderInitView(); }); } ); } else { renderInitView(); } } }); /** * @description 渲染扫描初始化页面 */ function renderInitView() { id = null; taskStatus[idx] = false; taskPath = ''; taskList = {}; $(layero).find('.disk_cont').removeClass('hide').siblings('.disk_scan_cont').addClass('hide'); $(layero).find('.layui-layer-close1').show(); $(layero).find('.disk-file-view,.disk-scan-view').addClass('hide'); $(layero).find('.disk-file-load').css('display', 'none'); } // 扫描 $(layero) .find('.disk_scanning_btn') .unbind('click') .on('click', function () { // if(taskStatus.some(function (item){ return item === true })) { // if(bt.get_cookie('taskStatus') === 'true') { // return layer.tips('有任务在执行,请稍后再操作!', $(this), {tips: [3, '#f00']}); // } is_remove_disk[idx] = false; var $path = $(this).data('path'); //判断是否安装插件 bt.soft.get_soft_find('disk_analysis', function (dataRes) { if (dataRes.setup && dataRes.endtime > 0) { layer.closeAll(); bt.set_cookie('diskPath', $path); bt.set_cookie('taskStatus', true); bt.soft.set_lib_config(dataRes.name, dataRes.title, dataRes.version); } else { var item = { name: 'disk_analysis', pluginName: 'Disk_analysis', ps: 'Quickly analyze disk/Hard disk usage', preview: false, limit: 'ltd', description: ['Check hard disk space', 'Occupancy percentage display'], imgSrc: 'https://www.yakpanel.com/Public/new/plugin/disk_analysis/1.png', }; product_recommend.recommend_product_view( item, { imgArea: ['783px', '718px'], }, 'ltd', 120, item.name ); var is_buy = dataRes.endtime < 0 && dataRes.pid > 0; $('.buyNow') .text(is_buy ? 'Buy now' : 'Install now') .unbind('click') .click(function () { if (is_buy) { bt.soft.product_pay_view({ name: dataRes.title, pid: dataRes.pid, type: dataRes.type, plugin: true, renew: -1, ps: dataRes.ps, ex1: dataRes.ex1, totalNum: 120, }); } else { bt.soft.install('disk_analysis'); } }); } }); return; var ltd = bt.get_cookie('ltd_end'); if (ltd < 0) { var item = { name: 'disk_analysis', pluginName: 'Disk_analysis', ps: 'Quickly analyze disk/Hard disk usage', preview: false, limit: 'ltd', description: ['Check hard disk space', 'Occupancy percentage display'], imgSrc: 'https://www.yakpanel.com/Public/new/plugin/disk_analysis/1.png', }; product_recommend.recommend_product_view( item, { imgArea: ['783px', '718px'], }, 'ltd', 120, item.name ); } else { $.post('/files/size/scan_disk_info', { path: $path }, function (rdata) { if (!rdata.status) { if (rdata['code'] && rdata['code'] === 404) { bt.soft.install('disk_analysis'); } } else { var $scanView = $(layero).find('.disk-scan-view'); var shellView = $(layero).find('.disk-scan-view pre'); $scanView.removeClass('hide'); $(layero).find('.disk-file-view').addClass('hide'); $(layero).find('.disk_cont').addClass('hide').siblings('.disk_scan_cont').removeClass('hide'); taskStatus[$(layero).find('.disk_scanning').data('index')] = true; renderScanTitle(shellView, '开始扫描磁盘目录\n', true); renderScanTitle(shellView, '目录正在扫描中\n'); renderTaskSpeed( function (rdata) { id = rdata.id; $(layero).find('.disk_scanning').data('id', id); }, function () { renderScanTitle(shellView, '扫描完成,等待扫描结果返回\n'); renderFilesView({ path: $path, init: true, }); } ); } }); } }); /** * @description 渲染文件列表 * @param {Object} data 数据 */ function renderFilesView(data, flag) { var param = { root_path: data.path, }; if (data['subdir']) param.path = data.subdir; if (flag) $(layero).find('.disk-file-load').css('display', 'flex'); bt_tools.send({ url: '/files/size/get_scan_log', data: param }, function (rdata) { if (flag) $(layero).find('.disk-file-load').css('display', 'none'); var $fileView = $(layero).find('.disk-file-view'); $fileView.removeClass('hide').prev().addClass('hide'); var path = rdata.fullpath; path = path.replace(/(\\)+/g, '/'); if (data.init) taskPath = path; if (!taskList.hasOwnProperty(path)) taskList[path] = rdata; renderFilesTable(rdata, path); renderFilesPath(path); }); } // 渲染文件表格 function renderFilesTable(rdata, path) { var $fileTableBody = $(layero).find('.filescan-list-body'); var list = rdata.list; var html = ''; for (var i = 0; i < list.length; i++) { var item = list[i]; var isDir = item.type == 1; html += '
' + '
' + '' + '' + item.name + '' + '
' + '
' + bt.format_size(isDir ? item.total_asize : item.asize) + '
' + '
' + '删除' + '
' + '
'; } $fileTableBody.html(html); // 删除文件 $(layero) .find('.remove-files') .click(function (e) { var path = $(this).data('path'), type = $(this).data('type'), fullpath = $(this).data('fullpath'), filename = $(this).data('filename'); delFileDir( { path: path, type: type, filename: filename, }, function (rdata) { bt_tools.msg(rdata); var list = taskList[fullpath].list.filter(function (item) { return item.name !== filename.toString(); }); taskList[fullpath].list = list; renderFilesTable(taskList[fullpath], fullpath); } ); e.stopPropagation(); }); // 打开目录 $(layero) .find('.filescan-list-item') .click(function () { var root_path = $(layero).find('.disk_scanning_btn').data('path'); var path = $(this).data('subdir'), type = $(this).data('type'); if (type !== 'folder' && typeof type !== 'undefined') return false; if (!taskList.hasOwnProperty(path.replace('//', '/'))) { renderFilesView( { path: root_path, subdir: path, }, true ); } else { var rdata = taskList[path.replace('//', '/')]; renderFilesTable(rdata, path); // 渲染文件表格 renderFilesPath(path); // 渲染文件路径 } }); } // 渲染文件路径 function renderFilesPath(path) { var html = ''; var newPath = ''; var pathArr = []; var isLevel = false; var isInit = true; var omission_li = []; pathArr = path.replace(taskPath.replace(/(\/\/)+/g, '/'), '').split('/'); if (pathArr.length >= 1 && pathArr[0] !== '') pathArr.unshift(''); if (pathArr.length > 1 && pathArr[1] !== '') { var upperPath = (getDirPath(path, false) + '/').replace(/(\/\/)+/g, '/'); if (pathArr.length > 1) upperPath = upperPath.replace(/\/$/g, ''); $(layero).find('.disk_back_btn').data('path', upperPath); } if (pathArr.length > 2) isInit = true; for (var i = 0; i < pathArr.length; i++) { var element = pathArr[i]; newPath += '/' + element; if (element === '' && i > 0) continue; var isLast = pathArr.length - 1 === i; var isFirst = i === 0; var currentPath = isFirst ? taskPath : taskPath + newPath; var divider = !isLast ? '>' : ''; var menuPath = isFirst ? '当前目录(' + taskPath + ')' : element; currentPath = currentPath.replace(/\/\//g, '/'); if (i > 1 && i < pathArr.length - 1 && pathArr.length > 3) { if (isInit) { html += '\ ...\
    \
    >'; } omission_li.push({ menuPath: element, currentPath: currentPath }); isInit = false; } else { html += '' + menuPath + '' + divider; } } $(layero).find('#fileScanPath').html(html); if (omission_li.length > 0) { var omission = $(layero).find('.omission'); var ul = omission.find('ul'); for (var i = 0; i < omission_li.length; i++) { var element = omission_li[i]; ul.append( '
  • ' + element.menuPath + '
  • ' ); } $(layero) .find('.omission') .click(function (e) { if ($(this).hasClass('active')) { $(this).removeClass('active'); } else { $(this).addClass('active'); } $(document).click(function (ev) { $(layero).find('.omission').removeClass('active'); ev.stopPropagation(); ev.preventDefault(); }); e.stopPropagation(); e.preventDefault(); }); } //打开目录按钮 $(layero) .find('#fileScanPath .filescan-nav-item') .click(function () { var root_path = $(layero).find('.disk_scanning_btn').data('path'); var path = $(this).data('path'), type = $(this).data('type'); if (type !== 'folder' && typeof type != 'undefined') return layer.msg('文件暂不支持打开', { icon: 0 }); if (!taskList.hasOwnProperty(path.replace('//', '/'))) { renderFilesView({ path: root_path, subdir: path, }); } else { var rdata = taskList[path.replace('//', '/')]; renderFilesTable(rdata, path); // 渲染文件表格 renderFilesPath(path); // 渲染文件路径 } }); } /** * @description 获取目录地址 * @param {string} path 路径 * @param {number} param 参数 */ function getDirPath(path, param) { path.replace(/\/$/, ''); var pathArr = path.split('/'); if (pathArr.length === 1) return path; if (param === -1) pathArr.push(status); if (typeof param === 'boolean') pathArr.pop(); return pathArr.join('/').replace(/(\/)$/, ''); } /** * @description 渲染文件追加功能 * @param {Element} el 控制器 * @param {String} html 文本 * @param {Boolean} isCover 是否覆盖,默认不覆盖 */ function renderScanTitle(el, html, isCover) { var $el = typeof el === 'string' ? $(layero).find(el) : el; if (isCover) { $el.html(html); } else { $el.append(html); } } /** * @description 渲染扫描进度 * @param {Function} callack 回调函数 * @param {Function} end 结束回调函数 */ function renderTaskSpeed(callack, end) { getScanTaskRequest(false, function (rdata) { if (rdata.length === 0 || !taskStatus[$(layero).find('.disk_scanning').data('index')]) { if (end && taskStatus[$(layero).find('.disk_scanning').data('index')]) end(rdata); taskStatus[$(layero).find('.disk_scanning').data('index')] = false; return; } for (var i = 0; i < rdata.length; i++) { var item = rdata[i]; if (item.name.indexOf('扫描目录文件大小') > -1) { if (callack) callack(rdata[0]); break; } } // 扫描目录文件大小 setTimeout(function () { renderTaskSpeed(callack, end); }, 1000); }); } /** * @description 获取扫描任务 * @param {boolean} load 是否显示加载中 * @param {function} callback 回调函数 */ function getScanTaskRequest(load, callback) { var isLoad = typeof load === 'function'; if (isLoad) callback = load; bt_tools.send( 'task/get_task_lists', { status: -3, }, function (rdata) { if (callback) callback(rdata); }, { load: isLoad ? '获取扫描任务详情' : false, } ); } /** * @description 删除文件或目录 * @param {Object} data */ function delFileDir(data, callback) { if (bt.get_cookie('file_recycle_status') === 'true') { bt.simple_confirm( { title: '删除' + data.type + '【' + data.filename + '】', msg: '删除' + data.type + '后,' + data.type + '将迁移至文件回收站,请确认删除的文件是不需要的文件,误删文件可能会导致系统崩溃,是否继续操作?
    ', }, function () { delFileRequest(data, function (res) { if (callback) callback(res); layer.msg(res.msg, { icon: res.status ? 1 : 2, }); }); } ); } else { bt.compute_confirm( { title: '删除' + data.type + '【' + data.filename + '】', msg: '风险操作,当前未开启文件回收站,删除' + data.type + '将彻底删除,无法恢复,请确认删除的文件是不需要的文件,误删文件可能会导致系统崩溃,是否继续操作?', }, function () { delFileRequest(data, function (res) { if (callback) callback(res); layer.msg(res.msg, { icon: res.status ? 1 : 2, }); }); } ); } } /** * @description 删除文件(文件和文件夹) * @param {Object} data 文件目录参数 * @param {Function} callback 回调函数 * @return void */ function delFileRequest(data, callback) { var _req = data.type === '文件' ? 'DeleteFile' : 'DeleteDir'; bt_tools.send( 'files/' + _req, { path: data.path, }, function (res) { if (callback) callback(res); }, { load: '删除文件/目录', } ); } }, cancel: function (index, layero) { if (taskStatus[$(layero).find('.disk_scanning').data('index')]) { layer.confirm( '取消扫描,将会中断当前扫描目录进程,是否继续?', { title: '取消扫描', closeBtn: 2, icon: 3, }, function (indexs) { taskStatus[$(layero).find('.disk_scanning').data('index')] = false; layer.close(indexs); layer.close(index); cancelScanTaskRequest($(layero).find('.disk_scanning').data('id'), function (rdata) { if (!rdata.status) return bt_tools.msg(rdata); }); } ); return false; } }, }); } /** * @description 删除扫描任务 * @param {string} id 任务id * @param {function} callback 回调函数 */ function cancelScanTaskRequest(id, callback) { bt_tools.send( 'task/remove_task', { id: id, }, function (rdata) { if (callback) callback(rdata); }, { load: '取消扫描任务', } ); } }, function () { diskInterval = setInterval(function () { if ($('.disk_scanning_tips' + idx).length) { var diskX = $('.disk_scanning_tips' + idx).offset().left, diskY = $('.disk_scanning_tips' + idx).offset().top, diskW = $('.disk_scanning_tips' + idx).width(), diskH = $('.disk_scanning_tips' + idx).height(); var diskChartY = $('#diskChart' + idx).offset().top, diskChartX = $('#diskChart' + idx).offset().left, diskChartW = $('#diskChart' + idx).width(), diskChartH = $('#diskChart' + idx).height(); var is_move_disk = mouseX >= diskChartX && mouseX <= diskChartX + diskChartW && mouseY >= diskChartY && mouseY <= diskChartY + diskChartH; var is_move = mouseX >= diskX && mouseX <= diskX + diskW && mouseY >= diskY && mouseY <= diskY + diskH; if (!is_move && !is_move_disk) { $('.disk_scanning_tips' + idx).remove(); } } else { clearInterval(diskInterval); } }, 500); } ); if ($('.disk_scanning_tips' + i).length) { var disk = $('#diskChart' + i).data('disk'); var size3 = parseFloat(disk.size[3].substring(0, disk.size[3].lastIndexOf('%'))); $('.disk_scanning_tips' + i + ' .disk-body-list .progressBar span') .text(disk.size[3]) .css({ left: (size3 < 12 ? size3 + 2 : size3 - 11) + '%;', color: size3 < 12 ? '#666;' : '#fff', }); var progressCss = { width: disk.size[3], }; if (size3 === 100) progressCss.borderRadius = '2px'; $('.disk_scanning_tips' + i + ' .disk-body-list .progressBar .progress').css(progressCss); $('.disk_scanning_tips' + i + ' .disk-body-list .progressBar .progress') .removeClass('bg-red bg-org bg-green') .addClass(size3 >= 80 ? (size3 >= 90 ? 'bg-red' : 'bg-org') : 'bg-green'); $('.disk_scanning_tips' + i + ' .disk-body-list.use_disk').html( parseFloat(disk.size[2]) + ' ' + disk.size[2].replace(parseFloat(disk.size[2]), '') + '可用,' + parseFloat(disk.size[1]) + ' ' + disk.size[1].replace(parseFloat(disk.size[1]), '') + '已用,共' + parseFloat(disk.size[0]) + ' ' + disk.size[0].replace(parseFloat(disk.size[0]), '') ); $('.disk_scanning_tips' + i + ' .disk-body-list.inodes0').html('Inode总数:' + disk.inodes[0]); $('.disk_scanning_tips' + i + ' .disk-body-list.inodes1').html('Inode已用:' + disk.inodes[1]); $('.disk_scanning_tips' + i + ' .disk-body-list.inodes2').html('Inode可用:' + disk.inodes[2]); $('.disk_scanning_tips' + i + ' .disk-body-list.inodes3').html('Inode使用率:' + disk.inodes[3]); } } _this.get_server_info(rdata); // 未安装环境时弹出 if (rdata.installed === false) bt.index.rec_install(); if (rdata.user_info.status) { var rdata_data = rdata.user_info.data; bt.set_cookie('bt_user_info', JSON.stringify(rdata.user_info)); $('.bind-user').html(rdata_data.username); } else { $('.bind-weixin a').attr('href', 'javascript:;'); $('.bind-weixin a').click(function () { bt.msg({ msg: '请先绑定 YakPanel 账号!', icon: 2 }); }); } }); setTimeout(function () { _this.interval.start(); }, 40); setTimeout(function () { index.get_index_list(); }, 50); setTimeout(function () { _this.net.init(); }, 60); setTimeout(function () { _this.iostat.init(); }, 60); setTimeout(function () { bt.system.check_update(function (rdata) { if (rdata.status !== false) { var res = rdata.msg; var ignore = res.ignore; var beta = res.beta; var is_beta = res.is_beta; if (ignore.indexOf(is_beta ? beta.version : res.version) == -1) index.check_update(true); $('#toUpdate a').html(lan.index.update + '.'); $('#toUpdate a').css('position', 'relative'); } // if (rdata.msg.is_beta === 1) { // $('#btversion').prepend('Beta'); // $('#btversion').append(' ['+lan.index.find_bug_reward+']'); // } }, false); }, 70); }, get_server_info: function (info) { var memFree = info.memTotal - info.memRealUsed; if (memFree < 64) { $('#messageError').show(); $('#messageError').append('

    ' + lan.index.mem_warning + '

    '); } if (info.isuser > 0) { $('#messageError').show(); $('#messageError').append( '

    ' + lan.index.user_warning + ' [' + lan.index.cant_ignore + '] [' + lan.index.edit_now + ']

    ' ); } if (info.isport === true) { $('#messageError').show(); $('#messageError').append( '

    ' + lan.index.panel_port_tips + ' [' + lan.index.panel_port_tip2 + '] [' + lan.index.panel_port_tip3 + ']

    ' ); } var _system = info.system; $('#info').html(_system); $('#running').html(info.time); if (_system.indexOf('Windows') != -1) { $('.ico-system').addClass('ico-windows'); } else if (_system.indexOf('CentOS') != -1) { $('.ico-system').addClass('ico-centos'); } else if (_system.indexOf('Ubuntu') != -1) { $('.ico-system').addClass('ico-ubuntu'); } else if (_system.indexOf('Debian') != -1) { $('.ico-system').addClass('ico-debian'); } else if (_system.indexOf('Fedora') != -1) { $('.ico-system').addClass('ico-fedora'); } else { $('.ico-system').addClass('ico-linux'); } }, render_disk: function (data) { if (data.items.length > 0) { var _tab = $(data.table); for (var i = 0; i < data.items.length; i++) { var item = data.items[i]; var html = ''; html += '
  • '; html += '

    ' + item.name + '

    '; html += '
    '; html += '
    '; html += '
    '; html += '
    0%
    '; html += '
    '; html += '

    ' + item.title + '

    '; html += '
  • '; var _li = $(html); if (item.masks) { var mask = ''; for (var j = 0; j < item.masks.length; j++) mask += item.masks[j].title + ': ' + item.masks[j].value + '
    '; _li.data('mask', mask); _li.find('.cicle').hover( function () { var _this = $(this); layer.tips(_this.parent().data('mask'), _this, { time: 0, tips: [1, '#999'] }); }, function () { layer.closeAll('tips'); } ); } var color = '#20a53a'; if (parseFloat(item.rate) >= 80) color = '#ff9900'; var size = parseFloat(item.free.substr(0, item.free.length - 1)); var unit = item.free.substr(item.free.length - 1, 1); switch (unit) { case 'G': if (size < 1) color = '#dd2f00'; break; case 'T': if (size < 0.1) color = '#dd2f00'; break; default: color = '#dd2f00'; break; } index.set_val(_li, { usage: item.rate, color: color }); _tab.append(_li); } } }, set_val: function (_li, obj) { //obj.usage = parseInt(obj.usage) if (obj.usage > 50) { setTimeout(function () { _li.find('.bar-right-an').css({ transform: 'rotate(45deg)', transition: 'transform 750ms linear' }); }, 10); setTimeout(function () { _li.find('.bar-left-an').css({ transform: 'rotate(' + (((obj.usage - 50) / 100) * 360 - 135) + 'deg)', transition: 'transform 750ms linear' }); }, 760); } else { if (parseInt(_li.find('.occupy span').html()) > 50) { setTimeout(function () { _li.find('.bar-right-an').css({ transform: 'rotate(' + ((obj.usage / 100) * 360 - 135) + 'deg)', transition: 'transform 750ms linear' }); }, 760); setTimeout(function () { _li.find('.bar-left-an').css({ transform: 'rotate(-135deg)', transition: 'transform 750ms linear' }); }, 10); } else { setTimeout(function () { _li.find('.bar-right-an').css({ transform: 'rotate(' + ((obj.usage / 100) * 360 - 135) + 'deg)', transition: 'transform 750ms linear' }); }, 10); } } if (obj.items) { var item = {}; for (var i = 0; i < obj.items.length; i++) { if (obj.usage <= obj.items[i].val) { item = obj.items[i]; continue; } break; } if (item.title) obj.title = item.title; if (item.color) obj.color = item.color; } if (obj.color) { _li.find('.cicle .bar-left-an').css('border-color', 'transparent transparent ' + obj.color + ' ' + obj.color); _li.find('.cicle .bar-right-an').css('border-color', obj.color + ' ' + obj.color + ' transparent transparent'); _li.find('.occupy').css('color', obj.color); } if (obj.title) _li.find('h4').text(obj.title); _li.find('.occupy span').html(obj.usage); }, /** * @description 渲染系统信息 * @param callback 回调函数 * */ reander_system_info: function (callback) { var _this = this; bt.system.get_net(function (res) { _this.chart_result = res; // 动态添加磁盘,并赋值disk_view if (_this.chart_view.disk == undefined) { for (var i = 0; i < res.disk.length; i++) { var diskHtml = "
  • "; $('#systemInfoList').append(diskHtml); _this.disk_view.push(echarts.init(document.querySelector('#diskChart' + i))); } } // 负载 var loadCount = Math.round((res.load.one / res.load.max) * 100) > 100 ? 100 : Math.round((res.load.one / res.load.max) * 100); loadCount = loadCount < 0 ? 0 : loadCount; var loadInfo = _this.chart_color_active(loadCount); // cpu var cpuCount = res.cpu[0]; var cpuInfo = _this.chart_color_active(cpuCount); // 内存 var memCount = Math.round((res.mem.memRealUsed / res.mem.memTotal) * 1000) / 10; // 返回 memRealUsed 占 memTotal 的百分比 var memInfo = _this.chart_color_active(memCount); bt.set_cookie('memSize', res.mem.memTotal); // 磁盘 var diskList = res.disk; var diskJson = []; for (var i = 0; i < diskList.length; i++) { var ratio = diskList[i].size[3]; ratio = parseFloat(ratio.substring(0, ratio.lastIndexOf('%'))); var diskInfo = _this.chart_color_active(ratio); diskJson.push(diskInfo); } // chart_json存储最新数据 _this.chart_json['load'] = loadInfo; _this.chart_json['cpu'] = cpuInfo; _this.chart_json['mem'] = memInfo; _this.chart_json['disk'] = diskJson; // 初始化 || 刷新 if (_this.chart_view.disk == undefined) { _this.init_chart_view(); } else { _this.set_chart_data(); } $('.rank .titles').show(); var net_key = bt.get_cookie('network_io_key'); if (net_key) { res.up = res.network[net_key].up; res.down = res.network[net_key].down; res.downTotal = res.network[net_key].downTotal; res.upTotal = res.network[net_key].upTotal; res.downPackets = res.network[net_key].downPackets; res.upPackets = res.network[net_key].upPackets; res.downAll = res.network[net_key].downTotal; res.upAll = res.network[net_key].upTotal; } var net_option = ''; $.each(res.network, function (k, v) { var act = k == net_key ? 'selected' : ''; net_option += ''; }); $('select[name="network-io"]').html(net_option); //刷新流量 $('#upSpeed').html(res.up.toFixed(2) + ' KB'); $('#downSpeed').html(res.down.toFixed(2) + ' KB'); $('#downAll').html(bt.format_size(res.downTotal)); $('#upAll').html(bt.format_size(res.upTotal)); index.net.add(res.up, res.down); var disk_key = bt.get_cookie('disk_io_key') || 'ALL', disk_io_data = res.iostat[disk_key || 'ALL'], mb = 1048576, ioTime = disk_io_data.write_time > disk_io_data.read_time ? disk_io_data.write_time : disk_io_data.read_time; $('#readBytes').html(bt.format_size(disk_io_data.read_bytes)); $('#writeBytes').html(bt.format_size(disk_io_data.write_bytes)); $('#diskIops').html(disk_io_data.read_count + disk_io_data.write_count); $('#diskTime') .html(ioTime + ' ms') .css({ color: ioTime > 100 && ioTime < 1000 ? '#ff9900' : ioTime >= 1000 ? 'red' : '#20a53a' }); index.iostat.add((disk_io_data.read_bytes / mb).toFixed(2), (disk_io_data.write_bytes / mb).toFixed(2), disk_io_data); var disk_option = ''; $.each(res.iostat, function (k, v) { disk_option += ''; }); $('select[name="disk-io"]').html(disk_option); if (index.net.table) index.net.table.setOption({ xAxis: { data: index.net.data.aData }, series: [ { name: lan.index.net_up, data: index.net.data.uData }, { name: lan.index.net_down, data: index.net.data.dData }, ], }); if (index.iostat.table) index.iostat.table.setOption({ xAxis: { data: index.iostat.data.aData }, series: [ { name: 'Read Bytes', data: index.iostat.data.uData }, { name: 'Write Bytes', data: index.iostat.data.dData }, ], }); if (callback) callback(res); }); }, /** * @description 渲染画布视图 */ init_chart_view: function () { // 所有图表对象装进chart_view this.chart_view['load'] = echarts.init(document.querySelector('#loadChart')); this.chart_view['cpu'] = echarts.init(document.querySelector('#cpuChart')); this.chart_view['mem'] = echarts.init(document.querySelector('#memChart')); this.chart_view['disk'] = this.disk_view; // 图表配置项 this.series_option = { series: [ { type: 'gauge', startAngle: 90, endAngle: -270, animationDuration: 1500, animationDurationUpdate: 1000, radius: '99%', pointer: { show: false, }, progress: { show: true, overlap: false, roundCap: true, clip: false, itemStyle: { borderWidth: 1, borderColor: '#20a53a', }, }, axisLine: { lineStyle: { width: 7, color: [ [0, 'rgba(204,204,204,0.5)'], [1, 'rgba(204,204,204,0.5)'], ], }, }, splitLine: { show: false, distance: 0, length: 10, }, axisTick: { show: false, }, axisLabel: { show: false, distance: 50, }, data: [ { value: 0, detail: { offsetCenter: ['0%', '0%'], }, itemStyle: { color: '#20a53a', borderColor: '#20a53a', }, }, ], detail: { width: 50, height: 15, lineHeight: 15, fontSize: 17, color: '#20a53a', formatter: '{value}%', fontWeight: 'normal', }, }, ], }; this.set_chart_data(); }, /** * @description 赋值chart的数据 * */ set_chart_data: function () { this.chart_active('load'); this.chart_active('cpu'); if (!this.release) { this.chart_active('mem'); } for (var i = 0; i < this.chart_view.disk.length; i++) { this.series_option.series[0].data[0].value = this.chart_json.disk[i].val; this.series_option.series[0].data[0].itemStyle.color = this.chart_json.disk[i].color; this.series_option.series[0].data[0].itemStyle.borderColor = this.chart_json.disk[i].color; this.series_option.series[0].progress.itemStyle.borderColor = this.chart_json.disk[i].color; this.series_option.series[0].detail.color = this.chart_json.disk[i].color; this.chart_view.disk[i].setOption(this.series_option, true); $('#disk' + i).text(this.chart_result.disk[i].size[1] + ' / ' + this.chart_result.disk[i].size[0]); $('#diskName' + i).text(this.chart_result.disk[i].path); } }, /** * @description 赋值chart的数据 * */ chart_active: function (name) { // 图表数据 this.series_option.series[0].data[0].value = this.chart_json[name].val; this.series_option.series[0].data[0].itemStyle.color = this.chart_json[name].color; this.series_option.series[0].data[0].itemStyle.borderColor = this.chart_json[name].color; this.series_option.series[0].progress.itemStyle.borderColor = this.chart_json[name].color; this.series_option.series[0].detail.color = this.chart_json[name].color; this.chart_view[name].setOption(this.series_option, true); // 文字 var val = ''; switch (name) { case 'load': val = this.chart_json[name].title; break; case 'cpu': val = this.chart_result.cpu[1] + ' ' + lan.index.cpu_core; break; case 'mem': val = this.chart_result.mem.memRealUsed + ' / ' + this.chart_result.mem.memTotal + '(MB)'; break; } $('#' + name).text(val); }, /** * @description 赋值chart的颜色 * */ chart_color_active: function (number) { var activeInfo = {}; for (var i = 0; i < this.load_config.length; i++) { if (number >= this.load_config[i].val) { activeInfo = JSON.parse(JSON.stringify(this.load_config[i])); break; } else if (number <= 30) { activeInfo = JSON.parse(JSON.stringify(this.load_config[3])); break; } } activeInfo.val = number; return activeInfo; }, get_index_list: function () { bt.soft.get_index_list(function (rdata) { var con = ''; var icon = ''; var rlen = rdata.length; var clickName = ''; var setup_length = 0; var softboxsum = 12; var softboxcon = ''; for (var i = 0; i < rlen; i++) { if (rdata[i].setup) { setup_length++; if (rdata[i].admin) { clickName = ' onclick="bt.soft.set_lib_config(\'' + rdata[i].name + "','" + rdata[i].title + '\')"'; } else { clickName = 'onclick="soft.set_soft_config(\'' + rdata[i].name + '\')"'; } var icon = rdata[i].name; if (bt.contains(rdata[i].name, 'php-')) { icon = 'php'; rdata[i].version = ''; } var status = ''; if (rdata[i].status) { status = ''; } else { status = ''; } con += '
    \ \
    \
    \
    ' + rdata[i].title + ' ' + rdata[i].version + status + '
    \
    \
    '; } } $('#indexsoft').html(con); // 推荐安装软件 try { var recomConfig = product_recommend.get_recommend_type(1); if (recomConfig) { var pay_status = product_recommend.get_pay_status(); for (var i = 0; i < recomConfig['list'].length; i++) { const item = recomConfig['list'][i]; if (setup_length > softboxsum) break; if (pay_status.is_pay && item['install']) continue; softboxcon += '
    \
    \
    关闭推荐
    \
    \
    ' + item['title'] + '
    \
    \ ' + (item['isBuy'] && !item['install'] ? '' : 'Preview') + '\
    \
    \
    '; setup_length++; } } } catch (error) { console.log(error); } //软件位置移动 if (setup_length <= softboxsum) { for (var i = 0; i < softboxsum - setup_length; i++) { softboxcon += '
    '; } $('#indexsoft').append(softboxcon); } $('#indexsoft').dragsort({ dragSelector: '.spanmove', dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "
    " }); function saveOrder() { var data = $('#indexsoft > div') .map(function () { return $(this).attr('data-id'); }) .get(); data = data.join('|'); bt.soft.set_sort_index(data); } }); }, check_update: function () { if ($('.layui-layer-dialog').length > 0) return false; var loadT = bt.load(); bt.system.check_update(function (rdata) { loadT.close(); if (rdata.status === false && typeof rdata.msg === 'string') { try { messagebox(); } catch (err) {} layer.msg(rdata.msg, { icon: 2 }); return; } var data = rdata.msg; var is_beta = data.is_beta; var beta = data.beta; var versionData = is_beta ? beta : data; var isOld = rdata.status; if (isOld) { content = '\
    [Linux' + (rdata.msg.is_beta == 1 ? lan.index.test_version : lan.index.final_version) + '] - ' + lan.index.update_log + '
    \ \
    \
    \
    ' + lan.index.have_new_version + '
    \
    ' + lan.index.last_version + '' + lan.index.bt_linux + (is_beta === 1 ? lan.index.test_version : lan.index.final_version) + ' ' + versionData.version + '' + (!isOld ? '  ' + lan.index.update_date + versionData.uptime : '') + '
    \
    \
    ' + (isOld ? '
    ' + versionData.updateMsg + '

    ' : '') + '
    ' + lan.index.last_version_is + (is_beta ? lan.index.final_version : lan.index.test_version) + (is_beta ? data.version : beta.version) + '   ' + lan.index.update_time + ' ' + (is_beta ? data.uptime : beta.uptime) + '   \ ' + (!is_beta ? '' + lan.index.update_verison_click + '' + lan.index.check_detail + '' : '' + lan.index.change_final_click + '' + lan.index.change_final + '') + '\
    \
    \
    \ \ \
    \
    '; } else { content = '\
    \
    \
    \ \ ' + lan.index.last_version_now + '\
    \ \
    \
    \
    \ ' + lan.index.last_version_is + (is_beta ? lan.index.final_version : lan.index.test_version) + (is_beta ? data.version : data.beta.version) + '\ ' + lan.index.update_time + (is_beta ? data.uptime.replaceAll('/', '-') : beta.uptime.replaceAll('/', '-')) + '\
    \ ' + (!is_beta ? '' + lan.index.update_verison_click + '' + lan.index.check_detail + '' : '' + lan.index.change_final + '') + '\ \
    \
    \
    \ '; } bt.open({ type: 1, title: isOld ? false : [ '[Linux' + (rdata.msg.is_beta == 1 ? lan.index.test_version : lan.index.final_version) + '] - ' + lan.index.update_log, 'background-color:#37BC51;color:white;height:36px;padding:0 80px 0 13.5px;', ], area: isOld ? '480px' : '530px', shadeClose: false, skin: 'layui-layer-dialog' + (!isOld ? '' : ' new-layer-update active'), closeBtn: 2, content: content, success: function (layers, indexs) { if (!isOld) $(layers).find('.layui-layer-content').css('padding', '0'); $('.ignore-renew').on('click', function () { bt.send('ignore_version', 'ajax/ignore_version', { version: versionData.version }, function (rdata) { bt.msg(rdata); if (rdata.status) layer.close(indexs); }); }); }, cancel: function () { if (isOld) bt.send('ignore_version', 'ajax/ignore_version', { version: versionData.version }); }, }); }); }, to_update: function () { layer.closeAll(); bt.system.to_update(function (rdata) { if (rdata.status) { bt.msg({ msg: rdata.msg, icon: 1 }); $('#btversion').html(rdata.version); $('#toUpdate').html(''); bt.system.reload_panel(); setTimeout(function () { window.location.reload(); }, 3000); } else { bt.msg({ msg: rdata.msg, icon: 5, time: 5000 }); } }); }, to_not_beta: function () { bt.show_confirm(lan.index.change_final, lan.index.change_test_to_final, function () { bt.send('apple_beta', 'ajax/to_not_beta', {}, function (rdata) { if (rdata.status === false) { bt.msg(rdata); return; } bt.system.check_update(function (rdata) { index.to_update(); }); }); }); }, beta_msg: function () { var new_load = bt.load(); bt.send('get_beta_logs', 'ajax/get_beta_logs', {}, function (data) { var my_list = ''; new_load.close(); if (data.status == false) { layer.msg(data.msg, { icon: 2 }); return false; } for (var i = 0; i < data.list.length; i++) { my_list += '
    \ \
    ' + bt.format_data(data.list[i].uptime).split(' ')[0] + '
    \
    ' + data.list[i].version + '
    \
    ' + data.list[i].upmsg + '
    \
    '; } layer.open({ type: 1, title: lan.index.apply_linux_test_version, area: '650px', shadeClose: false, skin: 'layui-layer-dialog', closeBtn: 2, content: '
    \
    \ ' + lan.index.apply_most_know + '\
    ' + data.beta_ps + '
    \
    \
    \ ' + lan.index.linux_test_version_update_log + '\
    ' + my_list + '
    \
    \
    \
    \ \ \
    \ \
    ', }); var countdown = 5; function settime(val) { if (countdown == 0) { val.removeAttr('disabled'); $('#update_time').text(''); return false; } else { $('#update_time').text(lan.index.second_left_of_click.replace('{1}', countdown)); countdown--; setTimeout(function () { settime(val); }, 1000); } } settime($('#notice')); $('#notice').click(function () { console.log($(this).prop('checked')); if ($(this).prop('checked')) { $('.btn_update_panel_beta').removeAttr('disabled'); } else { $('.btn_update_panel_beta').attr('disabled', 'disabled'); } }); $('.btn_update_panel_beta').click(function () { bt.show_confirm(lan.index.update_test_version, lan.index.check_test_version_detail, function () { var loading = bt.load(); bt.send('apple_beta', 'ajax/apple_beta', {}, function (rdata) { if (rdata.status === false) { bt.msg(rdata); return; } bt.system.check_update(function (res) { loading.close(); index.to_update(); }); }); }); }); }); }, re_panel: function () { layer.confirm(lan.index.rep_panel_msg, { title: lan.index.rep_panel_title, closeBtn: 2, icon: 3 }, function () { bt.system.rep_panel(function (rdata) { if (rdata.status) { bt.msg({ msg: lan.index.rep_panel_ok, icon: 1 }); return; } bt.msg(rdata); }); }); }, re_server: function () { bt.open({ type: 1, title: lan.index.restart_serverorpanel, area: '330px', closeBtn: 2, shadeClose: false, content: '
    ', }); setTimeout(function () { $('.rebt-con a').click(function () { var type = $(this).attr('data-id'); switch (type) { case 'panel': layer.confirm(lan.index.panel_reboot_msg, { title: lan.index.panel_reboot_title, closeBtn: 2, icon: 3 }, function () { var loading = bt.load(); interval_stop = true; bt.system.reload_panel(function (rdata) { loading.close(); bt.msg(rdata); }); setTimeout(function () { window.location.reload(); }, 3000); }); break; case 'server': var rebootbox = bt.open({ type: 1, title: lan.index.reboot_title, area: ['500px', '280px'], closeBtn: 2, shadeClose: false, content: "
    \
    \

    " + lan.index.reboot_warning + "

    \
    \

    " + lan.index.reboot_ps + '

    \

    ' + lan.index.reboot_ps_1 + '

    \

    ' + lan.index.reboot_ps_2 + '

    \

    ' + lan.index.reboot_ps_3 + '

    \

    ' + lan.index.reboot_ps_4 + "

    \
    \
    \
    \ \ \
    \
    ', }); setTimeout(function () { $('.btn-reboot').click(function () { rebootbox.close(); }); $('.WSafeRestart').click(function () { var body = '
    '; $('.bt-window-restart').html(body); $('.SafeRestartCode').append('

    ' + lan.index.reboot_msg_1 + '

    '); bt.pub.set_server_status_by("name={{session['webserver']}}&type=stop", function (r1) { $('.SafeRestartCode p').addClass('c9'); $('.SafeRestartCode').append('

    ' + lan.index.reboot_msg_2 + '...

    '); bt.pub.set_server_status_by('name=mysqld&type=stop', function (r2) { $('.SafeRestartCode p').addClass('c9'); $('.SafeRestartCode').append('

    ' + lan.index.reboot_msg_3 + '...

    '); bt.system.root_reload(function (rdata) { $('.SafeRestartCode p').addClass('c9'); $('.SafeRestartCode').append('

    ' + lan.index.reboot_msg_4 + '...

    '); var sEver = setInterval(function () { bt.system.get_total(function () { clearInterval(sEver); $('.SafeRestartCode p').addClass('c9'); $('.SafeRestartCode').append('

    ' + lan.index.reboot_msg_5 + '...

    '); setTimeout(function () { layer.closeAll(); }, 3000); }); }, 3000); }); }); }); }); }, 100); break; } }); }, 100); }, open_log: function () { return; bt.open({ type: 1, area: '640px', title: lan.index.update_log, closeBtn: 2, shift: 5, shadeClose: false, content: '
    ', }); $.get( 'https://wafapi2.yakpanel.com/api/panel/updateLinuxEn', function (rdata) { var body = ''; for (var i = 0; i < rdata.length; i++) { body += '
    \
    ' + rdata[i].addtime + '
    \
    \

    ' + rdata[i].title + '

    \

    ' + rdata[i].body + '

    \
    \
    '; } $('.DrawRecordCon').html(body); }, 'jsonp' ); }, get_cloud_list: function () { $.post('/plugin?action=get_soft_list', { type: 8, p: 1, force: 1, cache: 1 }, function (rdata) { console.log(lan.index.get_soft_list_success); }); }, // 获取安全风险列表 get_warning_list: function (active, callback) { var that = this, obj = {}; if (active == true) obj = { force: 1 }; bt.send('get_list', 'warning/get_list', obj, function (res) { if (res.status !== false) { that.warning_list = res; that.warning_num = res.risk.length; $('.warning_num') .css('color', that.warning_num > 0 ? 'red' : '#20a53a') .html(that.warning_num); $('.warning_scan_ps').html(that.warning_num > 0 ? 'This scan check ' + that.warning_num + ' risks, Suggested repair!' : 'There is no risk item detected in this scan, please keep it!'); if (callback) callback(res); } }); }, getScanSpeed: function (sele, msg, url) { var that = this; if (!$(sele).length) return; bt_tools.send({ url: url }, function (rdata) { var percentage = rdata.percentage; body = '

    ' + msg + '

    \
    \ ' + percentage + '%
    '; $(sele).prev().hide(); $(sele).css({ 'margin-left': '-37px', width: '380px' }); $(sele).parents('.layui-layer').css({ 'margin-left': '-100px' }); $(sele).html(body); setTimeout(function () { that.getScanSpeed(sele, msg, url); }, 200); }); }, /** * @description 获取时间简化缩写 * @param {Numbre} dateTimeStamp 需要转换的时间戳 * @return {String} 简化后的时间格式 */ get_simplify_time: function (dateTimeStamp) { if (dateTimeStamp === 0) return 'Just'; if (dateTimeStamp.toString().length == 10) dateTimeStamp = dateTimeStamp * 1000; var minute = 1000 * 60, hour = minute * 60, day = hour * 24, halfamonth = day * 15, month = day * 30, now = new Date().getTime(), diffValue = now - dateTimeStamp; if (diffValue < 0) return 'Just'; var monthC = diffValue / month, weekC = diffValue / (7 * day), dayC = diffValue / day, hourC = diffValue / hour, minC = diffValue / minute; if (monthC >= 1) { result = '' + parseInt(monthC) + ' month ago'; } else if (weekC >= 1) { result = '' + parseInt(weekC) + ' weeks ago'; } else if (dayC >= 1) { result = '' + parseInt(dayC) + ' days ago'; } else if (hourC >= 1) { result = '' + parseInt(hourC) + ' hours ago'; } else if (minC >= 1) { result = '' + parseInt(minC) + ' mins ago'; } else { result = 'Just'; } return result; }, /** * @description 渲染安全模块视图 * @return 无返回值 */ reader_warning_view: function () { var that = this; if (!that.warning_num && that.warning_num !== 0) { layer.msg('正在获取安全风险项,请稍后 ...', { icon: 0 }); return false; } function reader_warning_list(data) { var html = '', scan_time = '', arry = [ ['risk', 'Risk'], ['security', 'Security'], ['ignore', 'Ignore'], ], level = [ ['Low risk', '#e8d544'], ['Medium risk', '#E6A23C'], ['High risk', 'red'], ]; bt.each(arry, function (index, item) { var data_item = data[item[0]], data_title = item[1]; html += '
  • ' + '
    ' + '' + data_title + '' + '' + data_item.length + '' + '' + (item[index] == 'risk' && that.warning_num > 0 ? 'Collapse' : 'Details') + '' + '
    ' + (function (index, item) { var htmls = ''; return htmls; })(index, item) + '
  • '; }); $('.warning_scan_body').html(html); scan_time = Date.now() / 1000; // $('.warning_scan_time').html('Checked: ' + bt.format_data(scan_time)+'>>Obtain test report ' ); $('.warning_scan_time').html('Checked: ' + bt.format_data(scan_time)); } var dialog_forbid_data; var danger_check_data = []; bt.open({ type: '1', title: 'Security risk', area: ['850px', '700px'], skin: 'warning_scan_view', content: '
    ' + '
    ' + '' + (that.warning_num > 0 ? 'This scan check ' + that.warning_num + ' risks, Suggested repair!' : 'This scan check no risks, please keep it!') + '' + '' + '' + '' + '
    ' + '
      ' + '
      ', success: function () { //检测按钮 $('.warning_again_scan').click(function () { var loadT = bt.load("
      Re detecting security risks, please wait...
      "); setTimeout(function () { that.getScanSpeed('.myspeed', 'Security risks are being redetected, please wait', '/warning?action=get_scan_bar'); }, 50); that.get_warning_list(true, function () { layer.msg('Scan succeeded', { icon: 1 }); reader_warning_list(that.warning_list); if (that.warning_list.risk.length == 0) { $('.warning_auto_repair').css('display', 'none'); $('.warning_again_scan').css('right', '20px'); } else { $('.warning_auto_repair').css('display', 'inline'); $('.warning_again_scan').css('right', '160px'); } }); }); bt_tools.send({ url: '/warning?action=get_list' }, function (warInfo) { // 显示数据 if (that.warning_list.risk.length == 0) { $('.warning_auto_repair').css('display', 'none'); $('.warning_again_scan').css('right', '20px'); } //一键修复按钮 $('.warning_auto_repair').click(function () { dialog_forbid_data = []; danger_check_data = []; $.each(that.warning_list.risk, function (index_c, item_c) { //可修复项 if (!item_c.cve_id) { if ($.inArray(item_c.m_name, warInfo.is_autofix) != -1) { danger_check_data.push(item_c); } else { dialog_forbid_data.push(item_c); } } else { if ($.inArray(item_c.cve_id, warInfo.is_autofix) != -1) { item_c['title'] = 'System vulnerability'; item_c['ps'] = item_c.vuln_name; danger_check_data.push(item_c); } else { item_c['ps'] = item_c.vuln_name; dialog_forbid_data.push(item_c); } } }); var contentHtml = '
      \
      \
      \
      \ There are ' + dialog_forbid_data.length + ' risks that cannot be repaired with one click\ \ Detail\
      \
      \
      \
      \
      \

      \ The above ' + dialog_forbid_data.length + ' items may lead to normal website access and abnormal service operation after one-click repair (please repair manually)\

      \
      \
      \
      \
      \ Please select the risk items to be repaired (selected: ' + 0 + ')\
      \
      \
      \
      \ If you have installed [System hardening], please turn them off before repairing\ For Professional Version only, please Upgrade now\ \
      \
      '; if (!dialog_forbid_data.length || !danger_check_data.length) height = true; var check_data; var height = false; layer.open({ title: 'One-click repair confirm information', content: contentHtml, btn: false, closeBtn: 2, area: height ? ['640px', '380px'] : ['640px', '480px'], success: function (layero, index) { check_data = bt_tools.table({ el: '#auto_repair', data: danger_check_data, load: true, height: '178px', column: [ { type: 'checkbox', width: 20, }, { fid: 'title', title: 'Test Type', }, { fid: 'ps', title: 'Risk Item', }, { fid: 'level', title: 'Risk Level', width: 100, template: function (row) { return row.level == 1 ? 'High' : row.level == 2 ? 'Medium' : 'Low'; }, }, ], }); // 判定表格选中长度 $('#auto_repair tbody input,#auto_repair thead input').change(function () { $('#danger_length').text(check_data.checkbox_list.length); if (check_data.checkbox_list.length) { $('#confirm_button').attr('disabled', false); $('#confirm_button').css('background-color', '#20a53a'); } else { $('#confirm_button').attr('disabled', true); $('#confirm_button').css('background-color', 'rgb(203, 203, 203)'); } }); // 不存在不可修复项时 if (!dialog_forbid_data.length) { $('#choose_auto_repair').html('Please select the risk items to be repaired (selected: ' + 0 + ')
      '); $('.forbid').css('display', 'none'); $('.dialog').find('hr').css('display', 'none'); } if (!danger_check_data.length) { $('.dialog').find('hr').css('display', 'none'); $('#choose_auto_repair').html('There are no currently repairable risk items!'); $('#confirm_button').attr('disabled', true); $('#confirm_button').css('background-color', 'rgb(203, 203, 203)'); } // 一键修复 $('#confirm_button').click(function (e) { if (check_data.checkbox_list.length != 0) { var danger_selected_data = []; $.each(check_data.checkbox_list, function (index, item) { danger_selected_data.push(danger_check_data[item].m_name || danger_check_data[item].cve_id); }); that.auto_repair(danger_selected_data, that.warning_list); } else { layer.msg('No risk items are currently selected!', { type: 1 }); e.stopPropagation(); e.preventDefault(); } }); // 查看详情列表 var _details = '
      ', thead = '', _tr = ''; $.each(dialog_forbid_data, function (index, item) { _tr += ''; }); thead = ''; _details += thead + '' + _tr + '
      ' + (index + 1) + '' + item.ps + '
      The following ' + dialog_forbid_data.length + ' items cannot be repaired with one click
      '; $('.daily_details_mask').html(_details); $('#look_detail').on('click', function (e) { $('.daily_details_mask').prev('a').css('color', '#23527c'); if (e.target.localName == 'a') { if ($('.daily_details_mask').hasClass('hide')) { $('.daily_details_mask').removeClass('hide').css({ right: 20, top: 50 }); } else { $('.daily_details_mask').addClass('hide'); $('.daily_details_mask').prev('a').removeAttr('style'); } } bt.fixed_table('daliy_details_table'); $(document).click(function (ev) { $('.daily_details_mask').addClass('hide').prev('a').removeAttr('style'); ev.stopPropagation(); }); e.stopPropagation(); }); $('i[data-checkbox=all]').click(); // 是否为专业版 var ltd = parseInt(bt.get_cookie('pro_end') || -1); if (ltd > 0) { $('#is_ltd').css('display', 'none'); } else { $('#is_ltd').prev().hide(); $('#confirm_button').attr('disabled', true); $('#confirm_button').css('background-color', 'rgb(203, 203, 203)'); } $('.openLtd').click(function () { var item = { ps: 'Provide automatic repair solutions for security problems such as vulnerabilities and settings in the scanning server system, and perform automatic one-click repair for risk items scanned', description: ['Automatic Repair Scheme', 'Repair result display'], pluginName: 'Risk one-click repair', preview: false, imgSrc: 'https://www.yakpanel.com/Public/new/plugin/introduce/home/autoRepair.png', }; bt.soft.product_pay_view({ totalNum: 68, limit: 'pro', closePro: true, pluginName: item.pluginName, fun: function () { product_recommend.recommend_product_view(item, undefined, 'pro', 68, 'pro', true); }, }); }); }, }); }); // 3个大的下来的点击事件 $('.warning_scan_body').on('click', '.module_item .module_head', function () { var _parent = $(this).parent(), _parent_index = _parent.index(), _list = $(this).next(); if (parseInt($(this).find('.module_num').text()) > 0) { if (_list.hasClass('active')) { _list.css('height', 0); $(this).find('.module_cut_show i').text('Detail').next().removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down'); setTimeout(function () { _list.removeClass('active').removeAttr('style'); }, 500); } else { $(this).find('.module_cut_show i').text('Collapse').next().removeClass('glyphicon-menu-down').addClass('glyphicon-menu-up'); _list.addClass('active'); var details_list = _list.parent().siblings().find('.module_details_list'); details_list.removeClass('active'); details_list.prev().find('.module_cut_show i').text('Detail').next().removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down'); } } }); $('.warning_repair_scan').click(function () { bt.onlineService(); }); // 右边的操作 $('.warning_scan_body').on('click', '.operate_tools a', function () { var index = $(this).index(), data = $(this).data(); switch (index) { case 0: if ($(this).hasClass('active')) { $(this).parents('.module_details_head').next().hide(); $(this).removeClass('active').text('Detail'); } else { var item = $(this).parents('.module_details_item'), indexs = item.index(); $(this).addClass('active').text('Collapse'); item.siblings().find('.module_details_body').hide(); item.siblings().find('.operate_tools a:eq(0)').removeClass('active').text('Detail'); $(this).parents('.module_details_head').next().show(); $('.module_details_list').scrollTop(indexs * 41); } break; case 1: if (data.type != 'ignore') { bt.confirm({ title: 'Ignore risk', msg: 'Confirm to ignore [' + data.title + '] risk?' }, function () { if (data.type != 'vuln') { that.warning_set_ignore(data.model, function (res) { that.get_warning_list(false, function () { if (!that.warning_list.risk.length) { $('.warning_auto_repair').css('display', 'none'); $('.warning_again_scan').css('right', '40px'); } bt.msg(res); reader_warning_list(that.warning_list); }); }); } else { // console.log('漏洞的'); that.bug_set_ignore(data.id, function (res) { that.get_warning_list(false, function () { if (!that.warning_list.risk.length) { $('.warning_auto_repair').css('display', 'none'); $('.warning_again_scan').css('right', '40px'); } bt.msg(res); reader_warning_list(that.warning_list); }); }); } }); } else { that.warning_set_ignore(data.model, function (res) { that.get_warning_list(false, function () { bt.msg(res); reader_warning_list(that.warning_list); if (that.warning_list.risk.length) { $('.warning_auto_repair').css('display', 'inline'); $('.warning_again_scan').css('right', '160px'); } setTimeout(function () { $('.module_item.ignore').click(); }, 100); }); }); } break; case 2: if (data.type != 'vuln') { that.waring_check_find(data.model, function (res) { that.get_warning_list(false, function () { bt.msg(res); reader_warning_list(that.warning_list); }); }); } else { that.bug_check_find(data.id, function (res) { that.get_warning_list(false, function () { bt.msg(res); reader_warning_list(that.warning_list); }); }); } break; } }); reader_warning_list(that.warning_list); }); }, }); // var that = this; // function reader_warning_list(data){ // var html = '',scan_time = '',arry = [['risk','Risk'],['security','Security'],['ignore','Ignore']],level = [['Low risk','#e8d544'],['Medium risk','#E6A23C'],['High risk','red']] // bt.each(arry,function(index,item){ // var data_item = data[item[0]],data_title = item[1]; // html += '
    1. '+ // '
      '+ // ''+ data_title +''+ // ''+ data_item.length +''+ // ''+ (item[index] == 'risk' && that.warning_num > 0?'Collapse':'Details') +''+ // '
      '+ // (function(index,item){ // var htmls = ''; // return htmls; // }(index,item)) // +'
    2. ' // }); // $('.warning_scan_body').html(html); // $('.warning_scan_time').html('Checked:  '+ bt.format_data(scan_time)); // } // bt.open({ // type:'1', // title:'Security risk', // area:['850px','700px'], // skin:'warning_scan_view', // content:'
      '+ // '
      '+ // ''+ (that.warning_num>0?('This scan check '+ that.warning_num +' risks, Suggested repair!'):'This scan check no risks, please keep it!') +''+ // ''+ // ''+ // '
      '+ // '
        '+ // '
        ', // success:function(){ // $('.warning_again_scan').click(function(){ // var loadT = layer.msg('Re detecting security risks, please wait...',{icon:16}); // that.get_warning_list(true,function(){ // layer.msg('Scan succeeded',{icon:1}); // reader_warning_list(that.warning_list); // }); // }); // $('.warning_scan_body').on('click','.module_item .module_head',function(){ // var _parent = $(this).parent(),_parent_index = _parent.index(),_list = $(this).next(); // if(parseInt($(this).find('.module_num').text()) > 0){ // if(_list.hasClass('active')){ // _list.css('height',0); // $(this).find('.module_cut_show i').text('Detail').next().removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down'); // setTimeout(function(){ // _list.removeClass('active').removeAttr('style'); // },500); // }else{ // $(this).find('.module_cut_show i').text('Collapse').next().removeClass('glyphicon-menu-down').addClass('glyphicon-menu-up'); // _list.addClass('active'); // var details_list = _list.parent().siblings().find('.module_details_list'); // details_list.removeClass('active'); // details_list.prev().find('.module_cut_show i').text('Detail').next().removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down') // } // } // }); // $('.warning_scan_body').on('click','.operate_tools a',function(){ // var index = $(this).index(),data = $(this).data(); // switch(index){ // case 0: // if($(this).hasClass('active')){ // $(this).parents('.module_details_head').next().hide(); // $(this).removeClass('active').text('Detail'); // }else{ // var item = $(this).parents('.module_details_item'),indexs = item.index(); // $(this).addClass('active').text('Collapse'); // item.siblings().find('.module_details_body').hide(); // item.siblings().find('.operate_tools a:eq(0)').removeClass('active').text('Detail'); // $(this).parents('.module_details_head').next().show(); // $('.module_details_list').scrollTop(indexs * 41); // } // break; // case 1: // if(data.type != 'ignore'){ // bt.confirm({title:'Ignore risk',msg:'Confirm to ignore [ '+ data.title +' ] risk?'},function(){ // that.warning_set_ignore(data.model,function(res){ // that.get_warning_list(false,function(){ // bt.msg(res) // reader_warning_list(that.warning_list); // }); // }); // }); // }else{ // that.warning_set_ignore(data.model,function(res){ // that.get_warning_list(false,function(){ // bt.msg(res) // reader_warning_list(that.warning_list); // setTimeout(function(){ // $('.module_item.ignore').click(); // },100) // }); // }); // } // break; // case 2: // that.waring_check_find(data.model,function(res){ // that.get_warning_list(false,function(){ // bt.msg(res) // reader_warning_list(that.warning_list); // }); // }); // break; // } // }); // reader_warning_list(that.warning_list); // } // }) }, /** * @description 安全风险指定模块检查 * @param {String} model_name 模块名称 * @param {Function} callback 成功后的回调 * @return 无返回值 */ waring_check_find: function (model_name, callback) { var loadT = layer.msg('Detecting the specified module, please wait...', { icon: 16, time: 0 }); bt.send('check_find', 'warning/check_find', { m_name: model_name }, function (res) { bt.msg(res); if (res.status !== false) { if (callback) callback(res); } }); }, /** * @description: 安全风险一键修复 * @param {*} params 选中的修复项的数组 * @param {*} data 原先的数组 * @return {*} */ auto_repair: function (params, data) { var that = this; var res_data = []; var loadT = bt.load('
        Fixing the security risk, please wait...
        '); setTimeout(function () { that.getScanSpeed('.repair_speed', 'Fixing security risks', '/safe/security/get_repair_bar'); }, 50); $.post('/safe/security/set_security', { data: JSON.stringify({ m_name: params }) }, function (rdata) { if (rdata.msg == 'The current features are exclusive to the professional edition') { layer.msg(rdata.msg); return; } var res_item = {}; res_data = []; $.each(rdata.success, function (index, item) { res_item.status = item.result.status; res_item.type = item.result.type; res_item.msg = item.result.msg; res_item.m_name = item.m_name; res_data.push(res_item); res_item = {}; }); $.each(rdata.failed, function (index, item) { res_item.status = item.result.status; res_item.type = item.result.type; res_item.msg = item.result.msg; res_item.m_name = item.m_name; res_data.push(res_item); res_item = {}; }); if (rdata.cannot_automatically.length) { $.each(rdata.cannot_automatically, function (index, item) { res_item.m_name = item; res_item.status = 'ignore'; res_data.push(res_item); res_item = {}; }); } var result_table = '

        Repair result: Success ' + rdata.success.length + ' items, Fail ' + rdata.failed.length + ' items, Ignore ' + rdata.cannot_automatically.length + ' items

        ' + '

        After closing, risk items will be automatically re-detected. If you do not re-detect, please manually click the "Retest" button
        If any item fails to be repaired, close the current window and repair the item manually based on the solution

        '; layer.open({ title: 'Result', content: result_table, closeBtn: 2, area: '540px', btn: false, success: function (layero, index) { $('#auto_repair_result').empty(); bt_tools.table({ el: '#auto_repair_result', data: res_data, load: true, height: '240px', column: [ { type: 'text', title: 'Risk item', template: function (row) { var rowData; $.each(data.risk, function (index_d, item_d) { if (!item_d.cve_id) { if (item_d.m_name == row.m_name) { rowData = '' + item_d.title + ''; } } else { rowData = '' + row.m_name + ''; } }); return rowData; }, }, { type: 'text', title: 'Info (website or other)', width: 200, template: function (row) { if (row.type.length) { if (Array.isArray(row.type)) { var data = row.type.join(','); return '' + data + ''; } return '' + row.type + ''; } else { return '--'; } }, }, { title: 'Opt', type: 'text', align: 'right', template: function (row) { if (row.status == false) { return 'Fail'; } else if (row.status == true) { return 'Success'; } else if (row.status == 'ignore') { return 'Ignore risk'; } }, }, ], }); }, cancel: function (index, layers) { res_data = []; layer.close(index); var loadT = layer.msg('Retesting for security risks, please wait...', { icon: 16, }); $('.warning_again_scan').click(); }, }); }); }, /** * @description 安全风险指定模块是否忽略 * @param {String} model_name 模块名称 * @param {Function} callback 成功后的回调 * @return 无返回值 */ warning_set_ignore: function (model_name, callback) { var loadT = layer.msg('Setting the specified module, please wait...', { icon: 16, time: 0 }); bt.send('set_ignore', 'warning/set_ignore', { m_name: model_name }, function (res) { bt.msg(res); if (res.status !== false) { if (callback) callback(res); } }); }, /** * @description 获取当前的产品状态 */ get_product_status: function (callback) { // var loadT = layer.msg('正在获取产品状态,请稍候...', { icon: 16, time: 0 }) bt.send('get_pd', 'ajax/get_pd', {}, function (res) { $('.btpro-gray').replaceWith($(res[0])); bt.set_cookie('pro_end', res[1]); bt.set_cookie('ltd_end', res[2]); if (res[1] === 0) { $('.btpro span').click(function (e) { layer.confirm('切换回免费版可通过解绑账号实现', { icon: 3, btn: ['解绑账号'], closeBtn: 2, title: '是否取消授权' }, function () { $.post('/ssl?action=DelToken', {}, function (rdata) { layer.msg(rdata.msg); setTimeout(function () { window.location.reload(); }, 2000); }); }); e.stopPropagation(); }); } if (callback) callback(); }); }, /** * @description 推荐进阶版产品 */ recommend_paid_version: function () { try { var recomConfig = product_recommend.get_recommend_type(0); var pay_status = product_recommend.get_pay_status(); var is_pay = pay_status.is_pay; var advanced = pay_status.advanced; var end_time = pay_status.end_time; var html = '', list_html = ''; if (!is_pay) advanced = ''; //未购买的时候,使用推荐内容 if (recomConfig) { var item = recomConfig; for (let j = 0; j < item['ps'].length; j++) { const element = item['ps'][j]; list_html += '
        ' + element + '
        '; } var pay_html = ''; if (is_pay) { pay_html = '
        Expired: ' + (end_time === 0 ? 'Lifetime' : (end_time === -2 ? 'Expired' : bt.format_data(end_time, 'yyyy-MM-dd')) + '  Renew') + '
        '; } else { pay_html = '
        '; } html = '
        \
        ' + (!is_pay ? pay_html : '') + '
        ' + (is_pay ? pay_html : '') + '\
        ' + list_html + '
        \
        \
        '; $('#home-recommend').html(html); } } catch (error) { console.log(error); } }, }; index.get_init(); //setTimeout(function () { index.get_cloud_list() }, 800); product_recommend.init(function () { index.get_product_status(function () { index.recommend_paid_version(); }); index.get_index_list(); });