One Hat Cyber Team
  • Dir : ~/www/server/panel/BTPanel/static/vite/oldjs/
  • Edit File: public.js
    '; $('.taskcon').html(lbody); var ob = document.getElementById('exec_log'); ob.scrollTop = ob.scrollHeight; }); } function get_msg_data(a, fun) { a = a == undefined ? 1 : a; $.post('/data?action=getData', 'tojs=remind&table=tasks&result=2,4,6,8&limit=10&search=1&p=' + a, function (g) { fun(g); }); } function remind(a) { get_msg_data(a, function (g) { var e = ''; var f = false; var task_count = 0; for (var d = 0; d < g.data.length; d++) { if (g.data[d].status != '1') { task_count++; continue; } e += '
    ' + g.data[d].name + g.data[d].addtime + '【' + lan.bt.task_ok + '】' + lan.bt.time + (g.data[d].end - g.data[d].start) + lan.bt.s + '
    ' + g.data[d].addtime + ''; } var con = '
    \ \ ' + e + '\
    ' + lan.bt.task_name + '' + lan.bt.task_time + '
    \
    \ \
    \
    '; var msg_count = g.page.match(/\'Pcount\'>.+<\/span>/)[0].replace(/[^0-9]/gi, ''); $('.msg_count').text(parseInt(msg_count) - task_count); $('.taskcon').html(con); $('#taskPage').html(g.page); $('#Rs-checkAll').click(function () { if ($(this).prop('checked')) { $('#remind').find('input').prop('checked', true); } else { $('#remind').find('input').prop('checked', false); } }); }); } function GetReloads() { var a = 0; var mm = $('#taskList').html(); if (mm == undefined || mm.indexOf(lan.bt.task_list) == -1) { clearInterval(speed); a = 0; speed = null; return; } if (speed) return; speed = setInterval(function () { var mm = $('#taskList').html(); if (mm == undefined || mm.indexOf(lan.bt.task_list) == -1) { clearInterval(speed); speed = null; a = 0; return; } a++; $.post('/files?action=GetTaskSpeed', '', function (h) { if (h.task == undefined) { $('.cmdlist').html(lan.bt.task_not_list); return; } if (h.status === false) { clearInterval(speed); speed = null; a = 0; return; } var b = ''; var d = ''; $('#task').text(h.task.length); $('.task_count').text(h.task.length); for (var g = 0; g < h.task.length; g++) { if (h.task[g].status == '-1') { if (h.task[g].type != 'download') { var c = ''; var f = h.msg.split('\n'); for (var e = 0; e < f.length; e++) { c += f[e] + '
    '; } if (h.task[g].name.indexOf(lan.public.scan) != -1) { b = "
  • " + h.task[g].name + "" + lan.bt.task_scan + " | ' + lan.public.close + "
    " + c + '
  • '; } else { b = "
  • " + h.task[g].name + "" + lan.bt.task_install + " | ' + lan.public.close + "
    " + c + '
  • '; } } else { b = "
  • " + h.task[g].name + "" + (ToSize(h.msg.used) + '/' + ToSize(h.msg.total)) + "" + h.msg.pre + "%" + lan.bt.task_downloading + " | ' + lan.public.close + '
  • '; } } else { d += "
  • " + h.task[g].name + "" + lan.bt.task_sleep + " | ' + lan.public.del + '
  • '; } } $('.cmdlist').html(b + d); $('.cmd').html(c); try { if ($('.cmd')[0].scrollHeight) $('.cmd').scrollTop($('.cmd')[0].scrollHeight); } catch (e) { return; } }).error(function () {}); }, 1000); } //检查选中项 function RscheckSelect() { setTimeout(function () { var checkList = $('#remind').find('input'); var count = 0; for (var i = 0; i < checkList.length; i++) { if (checkList[i].checked) count++; } if (count > 0) { $('.buttongroup .btn').removeAttr('disabled'); } else { $('.rs-del,.rs-read').attr('disabled', 'disabled'); } }, 5); } function tasklist(a) { var con = '' + lan.public.task_long_time_not_exec + ''; $('.taskcon').html(con); a = a == undefined ? 1 : a; $.post('/data?action=getData', 'tojs=GetTaskList&table=tasks&limit=10&p=' + a, function (g) { var e = ''; var b = ''; var c = ''; var f = false; var task_count = 0; for (var d = 0; d < g.data.length; d++) { switch (g.data[d].status) { case '-1': f = true; if (g.data[d].type != 'download') { b = "
  • " + g.data[d].name + "" + lan.bt.task_install + " | ' + lan.public.close + "
  • "; } else { b = "
  • " + g.data[d].name + "0.0M/12.5M0%" + lan.bt.task_downloading + " | ' + lan.public.close + '
  • '; } task_count++; break; case '0': c += "
  • " + g.data[d].name + "" + lan.bt.task_sleep + ' | " + lan.public.del + '
  • '; task_count++; break; } } $('.task_count').text(task_count); get_msg_data(1, function (d) { var msg_count = d.page.match(/\'Pcount\'>.+<\/span>/)[0].replace(/[^0-9]/gi, ''); $('.msg_count').text(parseInt(msg_count)); }); $('.cmdlist').html(b + c); GetReloads(); return f; }); } //检查登陆状态 function check_login() { $.post('/ajax?action=CheckLogin', {}, function (rdata) { if (rdata === true) return; }); } //登陆跳转 function to_login() { layer.confirm(lan.public.login_expire, { title: lan.public.session_expire, icon: 2, closeBtn: 1, shift: 5 }, function () { location.reload(); }); } //表格头固定 function table_fixed(name) { var tableName = document.querySelector('#' + name); tableName.addEventListener('scroll', scroll_handle); } function scroll_handle(e) { var scrollTop = this.scrollTop; $(this) .find('thead') .css({ transform: 'translateY(' + scrollTop + 'px)', position: 'relative', 'z-index': '1' }); } var clipboard, interval, socket, term, ssh_login, term_box; var pdata_socket = { x_http_token: document.getElementById('request_token_head').getAttribute('token'), }; var Term = { bws: null, //websocket对象 route: '/webssh', //被访问的方法 term: null, term_box: null, ssh_info: {}, last_body: false, last_cd: null, config: { cols: 0, rows: 0, fontSize: 12, }, // 缩放尺寸 detectZoom: (function () { var ratio = 0, screen = window.screen, ua = navigator.userAgent.toLowerCase(); if (window.devicePixelRatio !== undefined) { ratio = window.devicePixelRatio; } else if (~ua.indexOf('msie')) { if (screen.deviceXDPI && screen.logicalXDPI) { ratio = screen.deviceXDPI / screen.logicalXDPI; } } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) { ratio = window.outerWidth / window.innerWidth; } if (ratio) { ratio = Math.round(ratio * 100); } return ratio; })(), //连接websocket connect: function () { if (!Term.bws || Term.bws.readyState == 3 || Term.bws.readyState == 2) { //连接 ws_url = (window.location.protocol === 'http:' ? 'ws://' : 'wss://') + window.location.host + Term.route; Term.bws = new WebSocket(ws_url); //绑定事件 Term.bws.addEventListener('message', Term.on_message); Term.bws.addEventListener('close', Term.on_close); Term.bws.addEventListener('error', Term.on_error); Term.bws.addEventListener('open', Term.on_open); //if (Term.ssh_info) Term.send(JSON.stringify(Term.ssh_info)) } }, //连接服务器成功 on_open: function (ws_event) { var http_token = $('#request_token_head').attr('token'); Term.send(JSON.stringify({ 'x-http-token': http_token })); if (JSON.stringify(Term.ssh_info) !== '{}') Term.send(JSON.stringify(Term.ssh_info)); // Term.term.FitAddon.fit(); // Term.resize(); // var f_path = $("#fileInputPath").val(); var f_path = $('#fileInputPath').attr('data-path'); if (f_path) { Term.last_cd = 'cd ' + f_path; Term.send(Term.last_cd + '\n'); } }, //服务器消息事件 // on_message: function(ws_event) { // result = ws_event.data; // if (result === "\r'Server connection failed'!\r" || result === "\rWrong user name or password!\r") { // show_ssh_login(result); // Term.close(); // return; // } // Term.term.write(result); // if (result == '\r\n登出\r\n' || result == '登出\r\n' || result == '\r\nlogout\r\n' || result == 'logout\r\n') { // setTimeout(function() { // layer.close(Term.term_box); // }, 500); // Term.close(); // Term.bws = null; // } // }, on_message: function (ws_event) { result = ws_event.data; if ((result.indexOf('@127.0.0.1:') != -1 || result.indexOf('@localhost:') != -1) && result.indexOf('Authentication failed') != -1) { Term.term.write(result); Term.localhost_login_form(result); Term.close(); return; } if (Term.last_cd) { if (result.indexOf(Term.last_cd) != -1 && result.length - Term.last_cd.length < 3) { Term.last_cd = null; return; } } if (result === '\rServer connection failed!\r' || result == '\rWrong user name or password!\r') { Term.close(); return; } if (result.length > 1 && Term.last_body === false) { Term.last_body = true; } Term.term.write(result); if (result == '\r\n登出\r\n' || result == '\r\n注销\r\n' || result == '注销\r\n' || result == '登出\r\n' || result == '\r\nlogout\r\n' || result == 'logout\r\n') { setTimeout(function () { layer.close(Term.term_box); Term.term.dispose(); }, 500); Term.close(); Term.bws = null; } }, //websocket关闭事件 on_close: function (ws_event) { Term.bws = null; }, //websocket错误事件 // on_error: function(ws_event) { // if(ws_event.target.readyState === 3){ // var msg = 'Error: unable to create websocket connection, please close 【Developer mode】 on the settings page'; // layer.msg(msg,{time:5000}) // if(Term.state === 3) return // Term.term.write(msg) // Term.state = 3; // }else{ // console.log(ws_event) // } // }, on_error: function (ws_event) { if (ws_event.target.readyState === 3) { if (Term.state === 3) return; Term.term.write(msg); Term.state = 3; } else { console.log(ws_event); } }, //关闭连接 close: function () { if (Term.bws) { Term.bws.close(); } }, resize: function () { setTimeout(function () { $('#term').height($('.term_box_all .layui-layer-content').height() - 18); Term.term.FitAddon.fit(); Term.send(JSON.stringify({ resize: 1, rows: Term.term.rows, cols: Term.term.cols })); Term.term.focus(); }, 100); }, // resize: function() { // var m_width = 100; // var m_height = 34; // Term.term.resize(m_width, m_height); // Term.term.scrollToBottom(); // Term.term.focus(); // Term.send('new_terminal'); // }, //发送数据 //@param event 唯一事件名称 //@param data 发送的数据 //@param collback 服务器返回结果时回调的函数,运行完后将被回收 send: function (data, num) { //如果没有连接,则尝试连接服务器 if (!Term.bws || Term.bws.readyState == 3 || Term.bws.readyState == 2) { Term.connect(); } //判断当前连接状态,如果!=1,则100ms后尝试重新发送 if (Term.bws.readyState === 1) { Term.bws.send(data); } else { if (Term.state === 3) return; if (!num) num = 0; if (num < 5) { num++; setTimeout(function () { Term.send(data, num++); }, 100); } } }, // run: function (ssh_info) { // var termCols = 100; // var termRows = 34; // var loadT = layer.msg('It is loading the files required by the terminal. Please wait...', { icon: 16, time: 0, shade: 0.3 }); // loadScript([ // "/static/build/xterm.min.js?v=1764233927359", // "/static/build/addons/attach/attach.min.js?v=1764233927359", // "/static/build/addons/fit/fit.min.js?v=1764233927359", // "/static/build/addons/fullscreen/fullscreen.min.js?v=1764233927359", // "/static/build/addons/search/search.min.js?v=1764233927359", // "/static/build/addons/winptyCompat/winptyCompat.js?v=1764233927359" // ], function () { // layer.close(loadT); // Term.term = new Terminal({ cols: termCols, rows: termRows, screenKeys: true, useStyle: true }); // Term.term.setOption('cursorBlink', true); // Term.term_box = layer.open({ // type: 1, // title: lan.public.terminal, // area: ['920px', '630px'], // closeBtn: 2, // shadeClose: false, // content: '\ // \ // [' + lan.public.set + ']\ //
    ', // cancel: function () { // Term.term.destroy(); // }, // success: function () { // Term.term.open(document.getElementById('term')); // Term.resize(); // } // }); // Term.term.on('data', function (data) { // try { // Term.bws.send(data) // } catch (e) { // Term.term.write('\r\nThe connection is lost and you are trying to reconnect!\r\n') // Term.connect() // } // }); // if (ssh_info) Term.ssh_info = ssh_info // Term.connect(); // }) // }, run: function (ssh_info) { // if($("#panel_debug").attr("data") == 'True') { // layer.msg('Error: unable to create websocket connection, please close 【Developer mode】 on the settings page!',{icon:2,time:5000}); // return; // } var loadT = layer.msg('It is loading the files required by the terminal. Please wait...', { icon: 16, time: 0, shade: 0.3 }); loadScript(['/static/js/xterm.js?v=1764233927359'], function () { layer.close(loadT); Term.term = new Terminal({ rendererType: 'canvas', cols: 100, rows: 31, fontSize: 15, screenKeys: true, useStyle: true, }); Term.term.setOption('cursorBlink', true); Term.last_body = false; Term.term_box = layer.open({ type: 1, title: lan.public.terminal, area: ['925px', '630px'], closeBtn: 2, shadeClose: false, skin: 'term_box_all', content: '\
    ', cancel: function (index, lay) { bt.confirm( { msg: '
    Closing the SSH session, the command in progress in the current command line session may be aborted. Continute?
    ', title: 'Cofirm to close the SSH session?', }, function (ix) { Term.term.dispose(); layer.close(index); layer.close(ix); Term.close(); } ); return false; }, success: function () { $('.term_box_all').css('background-color', '#000'); Term.term.open(document.getElementById('term')); Term.term.FitAddon = new FitAddon.FitAddon(); Term.term.loadAddon(Term.term.FitAddon); Term.term.WebLinksAddon = new WebLinksAddon.WebLinksAddon(); Term.term.loadAddon(Term.term.WebLinksAddon); Term.term.focus(); }, }); Term.term.onData(function (data) { try { Term.bws.send(data); } catch (e) { Term.term.write('\r\nThe connection is lost and you are trying to reconnect!\r\n'); Term.connect(); } }); if (ssh_info) Term.ssh_info = ssh_info; Term.connect(); }); }, reset_login: function () { var ssh_info = { data: JSON.stringify({ host: $("input[name='host']").val(), port: $("input[name='port']").val(), username: $("input[name='username']").val(), password: $("input[name='password']").val(), }), }; $.post('/term_open', ssh_info, function (rdata) { if (rdata.status === false) { layer.msg(rdata.msg); return; } layer.closeAll(); Term.connect(); Term.term.scrollToBottom(); Term.term.focus(); }); }, localhost_login_form: function (result) { var template = '
    Login failed, please fill the local server information!
    \
    \ Server IP\
    \ \ \
    \
    \
    \ SSH account\
    \ \
    \
    \
    \ Verification\
    \
    \ \ \
    \
    \
    \
    \ Password\
    \ \
    \
    \
    '; $('.term-box').after(template); $('.auth_type_checkbox').click(function () { var index = $(this).index(); $(this).addClass('btn-success').removeClass('btn-default').siblings().removeClass('btn-success').addClass('btn-default'); switch (index) { case 0: $('.c_password_view').addClass('show').removeClass('hidden'); $('.c_pkey_view').addClass('hidden').removeClass('show').find('input').val(''); break; case 1: $('.c_password_view').addClass('hidden').removeClass('show').find('input').val(''); $('.c_pkey_view').addClass('show').removeClass('hidden'); break; } }); $('.localhost-form-view > button').click(function () { var form = {}; $('.localhost-form-view input,.localhost-form-view textarea').each(function (index, el) { var name = $(this).attr('name'), value = $(this).val(); form[name] = value; switch (name) { case 'port': if (!bt.check_port(value)) { bt.msg({ status: false, msg: 'Server port format error!' }); return false; } break; case 'username': if (value == '') { bt.msg({ status: false, msg: 'Server user name cannot be empty!' }); return false; } break; case 'password': if (value == '' && $('.c_password_view').hasClass('show')) { bt.msg({ status: false, msg: 'Server password cannot be empty!' }); return false; } break; case 'pkey': if (value == '' && $('.c_pkey_view').hasClass('show')) { bt.msg({ status: false, msg: 'The server key cannot be empty!' }); return false; } break; } }); form.ps = 'Local server'; if (result) { if (result.indexOf('@127.0.0.1') != -1) { var user = result.split('@')[0].split(',')[1]; var port = result.split('1:')[1]; $("input[name='username']").val(user); $("input[name='port']").val(port); } } var loadT = bt.load('Adding server information, please wait...'); bt.send('create_host', 'xterm/create_host', form, function (res) { loadT.close(); bt.msg(res); if (res.status) { bt.msg({ status: true, msg: 'Login successful!' }); $('.layui-layer-shade').remove(); $('.term_box_all').remove(); Term.term.dispose(); Term.close(); web_shell(); } }); }); $('.localhost-form-view [name="password"]') .keyup(function (e) { if (e.keyCode == 13) { $('.localhost-form-view > button').click(); } }) .focus(); }, }; function web_shell() { Term.run(); } socket = { emit: function (data, data2) { if (data === 'webssh') { data = data2; } if (typeof data === 'object') { return; } Term.send(data); }, }; function show_ssh_login(is_config) { if ($("input[name='ssh_user']").attr('autocomplete')) return; var s_body = '
    \ \
    IP
    \
    Port
    \
    Username
    \
    Method
    \
    Password
    \ \
    \

    Only support login to this server

    \
    '; ssh_login = layer.open({ type: 1, title: is_config ? 'Please fill in the SSH connection configuration' : 'Please enter the SSH login account and password', area: '500px', closeBtn: 0, shadeClose: false, content: s_body, }); setTimeout(function removeReadonly() { $("input[name='ssh_user']").removeAttr('readonly'); $("input[name='ssh_passwd']").removeAttr('readonly'); $("input[name='ssh_passwd']").focus(); $("input[name='ssh_passwd']").keydown(function (e) { if (e.keyCode == 13) { $('.ssh-login').click(); } }); }, 500); } function pass_check() { $('#pass_check').attr('class', 'ssh_check_s2'); $('#rsa_check').attr('class', 'ssh_check_s1'); $('.ssh_pkey').hide(); $('.ssh_passwd').show(); } function rsa_check() { $('#pass_check').attr('class', 'ssh_check_s1'); $('#rsa_check').attr('class', 'ssh_check_s2'); $('.ssh_pkey').show(); $('.ssh_passwd').hide(); } function send_ssh_info() { pdata = { host: $("input[name='ssh_host']").val(), port: Number($("input[name='ssh_port']").val()), password: $("input[name='ssh_passwd']").val(), username: $("input[name='ssh_user']").val(), pkey: $("textarea[name='ssh_pkey']").val(), }; if (pdata['host'] !== '127.0.0.1' && pdata['host'] !== 'localhost') { layer.msg('Connection address can only be [ 127.0.0.1 or localhost ]'); $("input[name='ssh_host']").focus(); return; } if (pdata['port'] < 1 || pdata['port'] > 65535) { layer.msg('Port range is incorrect [1-65535]'); $("input[name='ssh_port']").focus(); return; } if (!pdata['username']) { layer.msg('Username can not be empty!'); $("input[name='ssh_user']").focus(); return; } if ($('#rsa_check').attr('class') === 'ssh_check_s2') { pdata['c_type'] = 'True'; if (!pdata['pkey']) { layer.msg('Private key cannot be empty!'); $("input[name='ssh_pkey']").focus(); return; } } else { if (!pdata['password']) { layer.msg('Password can not be blank!'); $("input[name='ssh_passwd']").focus(); return; } } if ($('#ssh_is_save').prop('checked')) { pdata['is_save'] = '1'; } var loadT = layer.msg('Trying to log in to SSH...', { icon: 16, time: 0, shade: 0.3 }); $.post('/term_open', { data: JSON.stringify(pdata) }, function () { layer.close(loadT); Term.send('reset_connect'); layer.close(ssh_login); Term.term.focus(); }); } acme = { speed_msg: "
    [MSG]
    ", loadT: null, //获取订单列表 get_orders: function (callback) { acme.request( 'get_orders', {}, function (rdata) { callback(rdata); }, 'Getting order list...' ); }, //取指定订单 get_find: function (index, callback) { acme.request( 'get_order_find', { index: index }, function (rdata) { callback(rdata); }, 'Getting order information...' ); }, //下载指定证书包 download_cert: function (index, callback) { acme.request( 'update_zip', { index: index }, function (rdata) { if (!rdata.status) { bt.msg(rdata); return; } if (callback) { callback(rdata); } else { window.location.href = '/download?filename=' + rdata.msg; } }, 'Preparing to download..' ); }, //删除订单 remove: function (index, callback) { acme.request('remove_order', { index: index }, function (rdata) { bt.msg(rdata); if (callback) callback(rdata); }); }, //吊销证书 revoke: function (index, callback) { acme.request( 'revoke_order', { index: index }, function (rdata) { bt.msg(rdata); if (callback) callback(rdata); }, 'Revoking certificate...' ); }, //验证域名(手动DNS申请) auth_domain: function (index, callback) { acme.show_speed_window('Verifying DNS...', function () { acme.request( 'apply_dns_auth', { index: index }, function (rdata) { callback(rdata); }, false ); }); }, //取证书基本信息 get_cert_init: function (pem_file, siteName, callback) { acme.request( 'get_cert_init_api', { pem_file: pem_file, siteName: siteName }, function (cert_init) { callback(cert_init); }, 'Getting certificate information...' ); }, //显示进度 show_speed: function () { bt.send( 'get_lines', 'ajax/get_lines', { num: 10, filename: '/www/server/panel/logs/letsencrypt.log', }, function (rdata) { if ($('#create_lst').text() === '') return; if (rdata.status === true) { $('#create_lst').text(rdata.msg); $('#create_lst').scrollTop($('#create_lst')[0].scrollHeight); } setTimeout(function () { acme.show_speed(); }, 1000); } ); }, //显示进度窗口 show_speed_window: function (msg, callback) { acme.loadT = layer.open({ title: false, type: 1, closeBtn: 0, shade: 0.3, area: '500px', offset: '30%', content: acme.speed_msg.replace('[MSG]', msg), success: function (layers, index) { setTimeout(function () { acme.show_speed(); }, 1000); if (callback) callback(); }, }); }, //一键申请 //domain 域名列表 [] //auth_type 验证类型 model/http //auth_to 验证路径 网站根目录或dnsapi //auto_wildcard 是否自动组合通配符 1.是 0.否 默认0 apply_cert: function (domains, auth_type, auth_to, auto_wildcard, callback) { acme.show_speed_window('Applying for a certificate...', function () { if (auto_wildcard === undefined) auto_wildcard = '0'; pdata = { domains: JSON.stringify(domains), auth_type: auth_type, auth_to: auth_to, auto_wildcard: auto_wildcard, }; if (acme.id) pdata['id'] = acme.id; if (acme.siteName) pdata['siteName'] = acme.siteName; acme.request( 'apply_cert_api', pdata, function (rdata) { callback(rdata); }, false ); }); }, //续签证书 renew: function (index, callback) { acme.show_speed_window('Renewing certificate...', function () { acme.request( 'renew_cert', { index: index }, function (rdata) { callback(rdata); }, false ); }); }, //获取用户信息 get_account_info: function (callback) { acme.request('get_account_info', {}, function (rdata) { callback(rdata); }); }, //设置用户信息 set_account_info: function (account, callback) { acme.request('set_account_info', account, function (rdata) { bt.msg(rdata); if (callback) callback(rdata); }); }, //发送到请求 request: function (action, pdata, callback, msg) { if (msg == undefined) msg = 'Processing, please wait...'; if (msg) { var loadT = layer.msg(msg, { icon: 16, time: 0, shade: 0.3 }); } $.post('/acme?action=' + action, pdata, function (res) { if (msg) layer.close(loadT); if (callback) callback(res); }); }, }; /** 消息通道 **/ function MessageChannelSettings() { MessageChannel.get_channel_settings(function (rdata) { layer.open({ type: 1, area: '600px', title: 'Setting up notification', skin: 'layer-channel-auth', closeBtn: 2, shift: 5, shadeClose: false, content: '
    \
    \
    \

    Email

    \

    Telegram

    \
    \
    \
    \
    \
    \
    \ \ \
    \
    \
    \
    EmailOperating
    \
    \
    \
    \
    \
    \ \
    \
    \
    \
    ', success: function () { $('.addTelegram').click(function () { var _id = $('[name=telegram_id]').val(), _token = $('[name=telegram_token]').val(); if (_id == '' || _token == '') return layer.msg('input box cannot be empty!'); var loadT = layer.msg('The notification is being generated, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=set_tg_bot', { bot_token: _token, my_id: _id }, function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); }); $('.delTelegram').click(function () { var loadTs = layer.msg('Deleting notification, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=del_tg_info', function (rdata) { layer.close(loadTs); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); if (rdata.status) { $('[name=telegram_id]').val(''); $('[name=telegram_token]').val(''); $('.delTelegram').hide(); } }); }); }, }); $('.bt-w-menu p').click(function () { var index = $(this).index(); $(this).addClass('bgw').siblings().removeClass('bgw'); $('.conter_box').eq(index).show().siblings().hide(); }); MessageChannel.get_receive_list(); }); } var MessageChannel = { //获取推送设置 get_channel_settings: function (callback) { var loadT = layer.msg('Getting profile, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=get_settings2', function (rdata) { layer.close(loadT); if (callback) callback(rdata); }); }, // 获取收件者列表 get_receive_list: function () { $.post('/config?action=get_settings2', function (rdata) { var _html = '', _list = rdata.user_mail.mail_list; if (_list.length > 0) { for (var i = 0; i < _list.length; i++) { _html += '\ ' + _list[i] + '\ Del\ '; } } else { _html = 'No Data'; } $('#receive_table').html(_html); }); }, // 添加收件者 add_receive_info: function () { var _this = this; layer.open({ type: 1, area: '400px', title: 'Add recipient email', closeBtn: 2, shift: 5, shadeClose: false, content: '
    \
    \ Recipient mailbox\
    \ \
    \
    \
    \ \ \
    \
    ', success: function (layers, index) { $('.CreaterReceive').click(function () { var _receive = $('input[name=creater_email_value]').val(); if (_receive != '') { var loadT = layer.msg('Please wait while creating recipient list...', { icon: 16, time: 0, shade: [0.3, '#000'] }); layer.close(index); $.post('/config?action=add_mail_address', { email: _receive }, function (rdata) { layer.close(loadT); // 刷新收件列表 _this.get_receive_list(); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } else { layer.msg('Recipient mailbox cannot be empty!!', { icon: 2 }); } }); $('.smtp_closeBtn').click(function () { layer.close(index); }); }, }); }, // 删除收件者 del_email: function (mail) { var loadT = layer.msg('Deleting[' + mail + '],please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }), _this = this; $.post('/config?action=del_mail_list', { email: mail }, function (rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); _this.get_receive_list(); }); }, // 设置发送者邮箱信息 sender_info_edit: function () { var loadT = layer.msg('Getting profile, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=get_settings2', function (rdata) { layer.close(loadT); var qq_mail = rdata.user_mail.info.msg.qq_mail ? rdata.user_mail.info.msg.qq_mail : '', qq_stmp_pwd = rdata.user_mail.info.msg.qq_stmp_pwd ? rdata.user_mail.info.msg.qq_stmp_pwd : '', hosts = rdata.user_mail.info.msg.hosts ? rdata.user_mail.info.msg.hosts : '', port = rdata.user_mail.info.msg.port ? rdata.user_mail.info.msg.port : '', is_custom = $.inArray(port, ['25', '465', '587', '']) != -1; //是否自定义 layer.open({ type: 1, area: '460px', title: 'Set sender email information', closeBtn: 2, shift: 5, shadeClose: false, content: '
    \
    \ Sender email\
    \ \
    \
    \
    \ SMTP password\
    \ \
    \
    \
    \ SMTP server\
    \ \
    \
    \
    \ SMTP port\
    \ \ \
    \
    \
      \
    • 465 port is recommended, the protocol is SSL/TLS
    • \
    • Port 25 is SMTP protocol, port 587 is STARTTLS protocol
    • \
    \
    \ ' + (qq_mail != '' ? '' : '') + '\ \
    \
    ', success: function (layers, index) { var _option = ''; if (is_custom) { if (port == '465' || port == '') { _option = ''; } else if (port == '25') { _option = ''; } else { _option = ''; } } else { _option = ''; } $('#port_select').html(_option); $('#port_select').change(function (e) { if (e.target.value == 'other') { $('#port_select').css('width', '100px'); $('input[name=channel_email_port]').css('display', 'inline-block'); } else { $('#port_select').css('width', '300px'); $('input[name=channel_email_port]').css('display', 'none'); } }); $('.SetChannelEmail').click(function () { var _email = $('input[name=channel_email_value]').val(); var _passW = $('input[name=channel_email_password]').val(); var _server = $('input[name=channel_email_server]').val(), _port = ''; if ($('#port_select').val() == 'other') { _port = $('input[name=channel_email_port]').val(); } else { _port = $('#port_select').val(); } if (!_email) return layer.msg('Email address cannot be empty!', { icon: 2 }); if (!_passW) return layer.msg('STMP password cannot be empty!', { icon: 2 }); if (!_server) return layer.msg('STMP server address cannot be empty!', { icon: 2 }); if (!_port) return layer.msg('STMP server port cannot be empty!', { icon: 2 }); var loadT = layer.msg('The notification is being generated, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=user_mail_send', { email: _email, stmp_pwd: _passW, hosts: _server, port: _port }, function (rdata) { layer.close(loadT); if (rdata.status) { layer.close(index); MessageChannel.get_channel_settings(); } layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); }); $('.smtp_closeBtn').click(function () { layer.close(index); }); $('.set_empty').click(function () { var loadTs = layer.msg('notification, please wait...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/config?action=set_empty', { type: 'mail' }, function (rdata) { layer.close(loadTs); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); if (rdata.status) { layer.close(index); } }); }); }, }); }); }, }; /** 消息通道 end**/ var product_recommend = { data: null, /** * @description 初始化 */ init: function (callback) { var _this = this; if (location.pathname.indexOf('bind') > -1) return; this.get_product_type(function (rdata) { _this.data = rdata; if (callback) callback(rdata); }); }, /** * @description 获取推荐类型 * @param {object} type 参数{type:类型} */ get_recommend_type: function (type) { var config = null, pathname = location.pathname.replace('/', '') || 'home'; for (var i = 0; i < this.data.length; i++) { var item = this.data[i]; if (item.type == type && item.show) config = item; } return config; }, /** * @description 或指定版本事件 * @param {} name */ get_version_event: function (item, param) { var pay_status = this.get_pay_status(); bt.soft.get_soft_find(item.name, function (res) { if ((res.type === 12 && pay_status.is_pay && pay_status.advanced !== 'ltd') || !pay_status.is_pay) { product_recommend.recommend_product_view(item); } else if (!res.setup) { bt.soft.install(item.name); } else { bt.plugin.get_plugin_byhtml(item.name, function (html) { if (typeof html === 'string') { layer.open({ type: 1, shade: 0, skin: 'hide', content: html, success: function () { var is_event = false; for (var i = 0; i < item.eventList.length; i++) { var data = item.eventList[i]; var oldVersion = data.version.replace('.', ''), newVersion = res.version.replace('.', ''); if (newVersion <= oldVersion) { is_event = true; setTimeout(function () { new Function(data.event.replace('$siteName', param))(); }, 100); break; } } if (!is_event) new Function(item.eventList[item.eventList.length - 1].event.replace('$siteName', param))(); }, }); } }); } }); }, /** * @description 获取支付状态 */ get_pay_status: function () { var pro_end = parseInt(bt.get_cookie('pro_end') || -1); var ltd_end = parseInt(bt.get_cookie('ltd_end') || -1); var is_pay = pro_end > -1 || ltd_end > -1; // 是否购买付费版本 var advanced = 'pro'; // 已购买,专业版优先显示 if (pro_end === -2 || pro_end > -1) advanced = 'pro'; if (ltd_end === -2 || ltd_end > -1) advanced = 'ltd'; var end_time = advanced === 'ltd' ? ltd_end : pro_end; // 到期时间 return { advanced: advanced, is_pay: is_pay, end_time: end_time }; }, pay_product_sign: function (type, source) { switch (type) { case 'pro': bt.soft['updata_' + type](source); break; case 'ltd': bt.soft['updata_' + type](false, source); break; } }, /** * @description 获取项目类型 * @param {Function} callback 回调函数 */ get_product_type: function (callback) { bt.send('get_pay_type', 'ajax/get_pay_type', {}, function (rdata) { bt.set_storage('session', 'get_pay_type', JSON.stringify(rdata)); if (callback) callback(rdata); }); }, /** * @description 推荐购买产品 * @param {Object} pay_id 购买的入口id */ recommend_product_view: function (config) { var name = config.name.split('_')[0]; var status = this.get_pay_status(); console.log(status); bt.open({ title: false, area: '650px', btn: false, content: '
    \
    \
    \
    ' + config.pluginName + '
    \
    ' + config.ps + '
    \
    \ 产品预览\
    \
    \
    ', success: function () { // 产品预览 $('.product_view img').click(function () { layer.open({ type: 1, title: '查看图片', area: ['650px', '450px'], closeBtn: 2, btn: false, content: '', }); }); // 立即购买 $('.buyNow').click(function () { bt.set_cookie('pay_source', config.pay); bt.soft['updata_' + status.advanced](); }); }, }); }, }; var rsa = { publicKey: null, /** * @name 使用公钥加密 * @param {string} text * @returns string */ encrypt_public: function (text) { this.publicKey = document.querySelector('.public_key').attributes.data.value; if (this.publicKey.length < 10) return text; var encrypt = new JSEncrypt(); encrypt.setPublicKey(this.publicKey); return encrypt.encrypt(text); }, /** * @name 使用公钥解密 * @param {string} text * @returns string */ decrypt_public: function (text) { this.publicKey = document.querySelector('.public_key').attributes.data.value; if (this.publicKey.length < 10) return null; var decrypt = new JSEncrypt(); decrypt.setPublicKey(this.publicKey); return decrypt.decryptp(text); }, }; /** * @description 渲染邮箱配置视图 */ function renderMailConfigView(data) { layer.open({ type: 1, title: 'Set sender email information', area: ['470px', '376px'], btn: [lan.public.save, lan.public.cancel], skin: 'alert-send-view', content: '
    \
    \ Sender email\
    \ \
    \
    \
    \ SMTP password\
    \ \
    \
    \
    \ SMTP server\
    \ \
    \
    \
    \ SMTP port\
    \ \
    \
    \
      \
    • 465 port is recommended, the protocol is SSL/TLS
    • \
    • Port 25 is SMTP protocol, port 587 is STARTTLS protocol
    • \
    \
    ', success: function () { if (!$.isEmptyObject(data) && !$.isEmptyObject(data.data.send)) { var send = data.data.send, mail_ = send.qq_mail || '', stmp_pwd_ = send.qq_stmp_pwd || '', hosts_ = send.hosts || '', port_ = send.port || ''; $('input[name=sender_mail_value]').val(mail_); $('input[name=sender_mail_password]').val(stmp_pwd_); $('input[name=sender_mail_server]').val(hosts_); $('input[name=sender_mail_port]').val(port_); } else { $('input[name=sender_mail_port]').val('465'); } }, yes: function (indexs) { var _email = $('input[name=sender_mail_value]').val(), _passW = $('input[name=sender_mail_password]').val(), _server = $('input[name=sender_mail_server]').val(), _port = $('input[name=sender_mail_port]').val(); if (_email == '') return layer.msg('Email address cannot be empty!', { icon: 2 }); if (_passW == '') return layer.msg('STMP password cannot be empty!', { icon: 2 }); if (_server == '') return layer.msg('STMP server address cannot be empty!', { icon: 2 }); if (_port == '') return layer.msg('STMP server port cannot be empty!', { icon: 2 }); if (!data.setup) { bt_tools.send( { url: '/config?action=install_msg_module&name=' + data.name, data: {} }, function (res) { if (res.status) { bt_tools.send( { url: '/config?action=set_msg_config&name=mail', data: { send: 1, qq_mail: _email, qq_stmp_pwd: _passW, hosts: _server, port: _port } }, function (configM) { if (configM.status) { layer.close(indexs); layer.msg(configM.msg, { icon: configM.status ? 1 : 2, }); if ($('.alert-view-box').length >= 0) $('.alert-view-box .tab-nav-border span:eq(1)').click(); } }, 'Setting email Settings' ); } else { layer.msg(res.msg, { icon: 2 }); } }, 'Creating ' + data.title + ' module' ); } else { bt_tools.send( { url: '/config?action=set_msg_config&name=mail', data: { send: 1, qq_mail: _email, qq_stmp_pwd: _passW, hosts: _server, port: _port, }, }, function (configM) { if (configM.status) { layer.close(indexs); layer.msg(configM.msg, { icon: configM.status ? 1 : 2, }); } }, 'Setting email Settings' ); } }, }); } /** * @description 渲染url通道方式视图 */ function renderAlertUrlTypeChannelView(data) { var isEmpty = $.isEmptyObject(data.data); layer.open({ type: 1, title: data['title'] + ' robot configuration', area: ['480px', '345px'], btn: [lan.public.save, lan.public.cancel], skin: 'alert-send-view', content: '
    \
    \ Name\
    \ \
    \
    \ \
    ', success: function () { if (!$.isEmptyObject(data.data)) { var url = data['data'][data.name + '_url'] || ''; $('textarea[name=channel_url_value]').val(url); } }, yes: function (indexs) { var _index = $('.alert-view-box span.on').index(); var _url = $('textarea[name=channel_url_value]').val(), _name = $('input[name=chatName]').val(); if (_name == '') return layer.msg('Please enter the robot name or remarks', { icon: 2 }); if (_url == '') return layer.msg('Please enter the robot url', { icon: 2 }); if (!data.setup) { bt_tools.send( { url: '/config?action=install_msg_module&name=' + data.name, data: {} }, function (res) { if (res.status) { setTimeout(function () { bt_tools.send( { url: '/config?action=set_msg_config&name=' + data.name, data: { url: _url, title: _name, atall: 'True', }, }, function (rdata) { layer.close(indexs); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2, }); if ($('.alert-view-box').length >= 0) { $('.alert-view-box .tab-nav-border span:eq(' + _index + ')').click(); } }, 'Setting ' + data.title + ' configuration' ); }, 100); } else { layer.msg(res.msg, { icon: 2 }); } }, 'Creating ' + data.title + ' module' ); } else { bt_tools.send( { url: '/config?action=set_msg_config&name=' + data.name, data: { url: _url, title: _name, atall: 'True', }, }, function (rdata) { layer.close(indexs); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2, }); if ($('.alert-view-box').length >= 0) { $('.alert-view-box .tab-nav-border span:eq(' + _index + ')').click(); } }, 'Setting ' + data.title + ' module' ); } }, }); } function renderTelegramConfigView(data) { layer.open({ type: 1, title: 'Telegram configuration', area: ['460px', '320px'], btn: [lan.public.save, lan.public.cancel], skin: 'alert-send-view', content: '
    \
    \ ID\
    \ \
    \
    \
    \ TOKEN\
    \ \
    \
      \
    • ID: Your telegram user ID
    • \
    • Token: Your telegram bot token
    • \
    • e.g: [ 12345677:AAAAAAAAA_a0VUo2jjr__CCCCDDD ] Help
    • \
    \
    \
    ', success: function () { var res = data.data; if (res) { $('[name="telegram_id"]').val(res.my_id); $('[name="telegram_token"]').val(res.bot_token); } }, yes: function (indexs) { var id = $('input[name=telegram_id]').val(); var token = $('input[name=telegram_token]').val(); var _index = $('.alert-view-box span.on').index(); if (id == '') return layer.msg('Please enter Telegram ID!', { icon: 2 }); if (token == '') return layer.msg('Please enter Telegram token', { icon: 2 }); function saveConfig() { bt_tools.send( { url: '/config?action=set_msg_config&name=' + data.name, data: { my_id: id, bot_token: token, }, }, function (rdata) { layer.close(indexs); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2, }); if ($('.alert-view-box').length >= 0) { $('.alert-view-box .tab-nav-border span:eq(' + _index + ')').click(); } }, 'Setting ' + data.title + ' module' ); } if (!data.setup) { bt_tools.send( { url: '/config?action=install_msg_module&name=' + data.name, data: {}, }, function (res) { if (res.status) { saveConfig(); } else { layer.msg(res.msg, { icon: 2 }); } }, 'Creating ' + data.title + ' module' ); } else { saveConfig(); } }, }); } // true: 消息推送 false: 消息通道 var ConfigIsPush = false; // 消息推送弹框 var ConfigIndex = -1; // 打开消息通道/消息推送 function open_three_channel_auth(stype) { var _title = 'Set Notification'; var _area = '650px'; var isPush = false; var assign = ''; if (stype === 'MsgPush') { // 类型为消息推送 _title = 'Set message push'; _area = ['900px', '603px']; isPush = true; } else if (typeof stype != 'undefined' && stype) { // 指定选择消息通道的某个菜单 assign = stype; } ConfigIsPush = isPush; ConfigIndex = layer.open({ type: 1, area: _area, title: _title, closeBtn: 2, shift: 5, shadeClose: false, content: '\
    \
    \
    \
    \
    \
    \
    \
    \
    ', success: function () { // 获取菜单配置 getMsgConfig(assign ? assign : ''); // 卸载/禁用模块 $('.alarm-view').on('click', '.btn-uninstall', function () { uninstallMsgModuleConfig(); }); // 立即更新 $('.alarm-view').on('click', '.btn-update', function () { installMsgModuleConfig(); }); }, }); } // 获取模板配置 function getTemplateMsgConfig(item, shtml) { $.post( '/' + (ConfigIsPush ? 'push' : 'config') + '?action=get_module_template', { module_name: item.name, }, function (res) { if (res.status) { // 添加菜单内容 $('.bt-w-main .plugin_body').html(res.msg.trim()); // 添加底部内容 var updateInfo = ''; // 是否更新 if (item.version !== item.info.version) { updateInfo = '【' + item['title'] + '】模块存在新的版本,为了不影响使用,请更新。'; } // $(".bt-w-main .plugin_update").html('\ //
    \ //
    ' + updateInfo + '
    \ //
    \ //
    '); } else { $('.bt-w-main .plugin_body').html(shtml); } new Function(item.name + '.init()')(); } ); } // 获取消息配置 function getMsgConfig(openType) { var _api = '/config?action=get_msg_configs'; if (ConfigIsPush) _api = '/push?action=get_modules_list'; $.post(_api, function (rdata) { var _menu = ''; var menu_data = $('.alarm-view .bt-w-menu p.bgw').data('data'); $('.alarm-view .bt-w-menu').html(''); $.each(rdata, function (index, item) { var _default = item.data && item.data.default; var _flag = ''; if (_default) { _flag = ''; } _menu = $("

    " + item['title'] + _flag + '

    ').data('data', item); $('.alarm-view .bt-w-menu').append(_menu); }); // $('.alarm-view .bt-w-menu').append('更新列表'); $('.alarm-view .bt-w-menu p').click(function () { $(this).addClass('bgw').siblings().removeClass('bgw'); var _item = $(this).data('data'); var shtml = ''; if (_item['setup']) { getTemplateMsgConfig(_item, shtml); } else { $('.bt-w-main .plugin_body').html(shtml); $('.bt-w-main .plugin_update').html(''); } }); if (menu_data) { $('.men_' + menu_data['name']).click(); } else { if (typeof openType != 'undefined' && openType) { $('.alarm-view .bt-w-menu p.men_' + openType).trigger('click'); } else { $('.alarm-view .bt-w-menu p').eq(0).trigger('click'); } } }); } function installMsgModuleConfig(name) { var _api = '/config?action=install_msg_module'; if (ConfigIsPush) _api = '/push?action=install_module'; name = name ? '.men_' + name : ''; var _item = $('.alarm-view .bt-w-menu p.bgw' + name).data('data'); var spt = '安装'; if (_item.setup) spt = '更新'; layer.confirm( '是否要' + spt + '【' + _item.title + '】模块', { title: '安装模块', closeBtn: 2, icon: 0, }, function () { var loadT = layer.msg('正在' + spt + _item.title + '模块中,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'], }); $.post(_api + '&name=' + _item.name + '', function (res) { getMsgConfig(); layer.close(loadT); layer.msg(res.msg, { icon: res.status ? 1 : 2, }); }); } ); } function uninstallMsgModuleConfig() { var _api = '/config?action=uninstall_msg_module'; if (ConfigIsPush) _api = '/push?action=uninstall_module'; var _item = $('.alarm-view .bt-w-menu p.bgw').data('data'); layer.confirm( '是否确定要卸载【' + _item.title + '】模块', { title: '卸载模块', closeBtn: 2, icon: 0, }, function () { var loadT = layer.msg('正在卸载' + _item.title + '模块中,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'], }); $.post(_api + '&name=' + _item.name + '', function (res) { layer.close(loadT); getMsgConfig(); layer.msg(res.msg, { icon: res.status ? 1 : 2, }); }); } ); } function refreshThreeChannelAuth() { var _api = '/config?action=get_msg_configs'; if (ConfigIsPush) _api = '/push?action=get_modules_list'; var loadT = layer.msg('正在更新模块列表中,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'], }); layer.confirm( '是否确定获取最新的模块列表', { title: '刷新列表', closeBtn: 2, icon: 0, }, function (index) { layer.close(index); layer.close(ConfigIndex); $.post( _api, { force: 1, }, function (rdata) { layer.close(loadT); open_three_channel_auth(ConfigIsPush ? 'MsgPush' : ''); } ); } ); }