One Hat Cyber Team
  • Dir : ~/www/server/panel/BTPanel/static/js/
  • Edit File: soft.js
    ') tabCon.append('') tabCon.append(bt.render_help([lan.get('config_edit_ps', [version])])) var fileName = bt.soft.get_config_path(version); if (data.php_ini) fileName = data.php_ini; var loadT = bt.load(lan.soft.get); bt.send('GetFileBody', 'files/GetFileBody', { path: fileName }, function(rdata) { loadT.close(); $("#textBody").text(rdata.data); $(".CodeMirror").remove(); var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), { extraKeys: { "Ctrl-Space": "autocomplete" }, lineNumbers: true, matchBrackets: true, }); editor.focus(); $(".CodeMirror-scroll").css({ "height": "510px", "margin": 0, "padding": 0 }); $("#OnlineEditFileBtn").click(function() { $("#textBody").text(editor.getValue()); bt.soft.save_config(fileName, editor.getValue()) }); }) break; case 'fpm_config': var tabCon = $(".soft-man-con").empty(); tabCon.append('

    ' + lan.bt.edit_ps + '

    '); tabCon.append('
    ') tabCon.append('') var _arry = ['If you do not understand the php-fpm configuration file, please do not modify it!']; tabCon.append(bt.render_help(_arry)) $('.return_php_info').click(function(){ $('.bt-soft-menu p:eq(12)').click(); }); var fileName = bt.soft.get_config_path(version).replace('php.ini','php-fpm.conf'); var loadT = bt.load(lan.soft.get); var config = bt.aceEditor({el:'textBody',path:fileName}); $("#OnlineEditFileBtn").click(function () { bt.saveEditor(config); }); break; case 'change_version': var _list = []; var opt_version = ''; for (var i = 0; i < data.versions.length; i++) { if (data.versions[i].setup) opt_version = data.name + ' ' + data.versions[i].m_version; _list.push({ value: data.name + ' ' + data.versions[i].m_version, title: data.name + ' ' + data.versions[i].m_version }); } var _form_data = { title: lan.soft.select_version, items: [{ name: 'phpVersion', width: '160px', type: 'select', value: opt_version, items: _list }, { name: 'btn_change_version', type: 'button', text: lan.soft.version_to, callback: function(ldata) { if (ldata.phpVersion == opt_version) { bt.msg({ msg: 'Is already[' + opt_version + ']', icon: 2 }) return; } if (data.name == 'mysql') { var ver = ldata.phpVersion.split("mysql "), pdata = {sName: 'mysql', version: ver[1], type: 0}; $.post('/plugin?action=check_install_limit', pdata ,function(rdata) { if(rdata !==null && rdata.status == false) { bt.msg({msg: rdata.msg,icon: 2,time: 3000}); return false } bt.database.get_list(1, '', function(ddata) { if (ddata.data.length > 0) { bt.msg({ msg: lan.soft.mysql_d, icon: 5, time: 5000 }) return; } bt.soft.install_soft(data, ldata.phpVersion.split(" ")[1], 0); }) }); } else { bt.soft.install_soft(data, ldata.phpVersion.split(" ")[1], 0); } } } ] } bt.render_form_line(_form_data, '', $(".soft-man-con").empty()) break; case 'change_data_path': bt.send('GetMySQLInfo', 'database/GetMySQLInfo', {}, function(rdata) { var form_data = { items: [{ type: 'text', name: 'datadir', value: rdata.datadir, event: { css: 'glyphicon-folder-open', callback: function(obj) { bt.select_path(obj); } } }, { name: 'btn_change_path', type: 'button', text: lan.soft.mysql_to, callback: function(ldata) { var loadT = bt.load(lan.soft.mysql_to_msg1); bt.send('SetDataDir', 'database/SetDataDir', { datadir: ldata.datadir }, function(rdata) { loadT.close(); bt.msg(rdata); }); } } ] } bt.render_form_line(form_data, '', $(".soft-man-con").empty()); }); break; case 'change_mysql_port': bt.send('GetMySQLInfo', 'database/GetMySQLInfo', {}, function(rdata) { var form_data = { items: [{ type: 'text', width: '100px', name: 'port', value: rdata.port }, { name: 'btn_change_port', type: 'button', text: lan.public.edit, callback: function(ldata) { var loadT = bt.load(); bt.send('SetMySQLPort', 'database/SetMySQLPort', { port: ldata.port }, function(rdata) { loadT.close(); bt.msg(rdata); }); } } ] } bt.render_form_line(form_data, '', $(".soft-man-con").empty()); }); break; case 'change_mysql_ssl': bt.send('check_mysql_ssl_status', 'database/check_mysql_ssl_status', {}, function(rdata) { var form_data = { title: 'Mysql SSL', items: [{ type: 'switch', name: 'write_ssl', value: rdata } ] }; bt.render_form_line(form_data, '', $(".soft-man-con").empty()); var downssl = "/www/server/data/ssl.zip"; $(".soft-man-con").append(bt.render_help(["After setting, manually restart the database to take effect","Download Mysql SSL self-signed certificate【SSL.zip】"])); $("a.downssl").click(function() { window.open('/download?filename=' + encodeURIComponent(downssl)); }); $("#write_ssl").change(function() { var loadT = bt.load(); $.post('/database?action=write_ssl_to_mysql', function(rdata) { loadT.close(loadT); var open_type = $("#write_ssl").prop('checked')?'turned on':'turned off', loadP = layer.confirm('The SSL setting is '+open_type+' successfully.
    Do you need to restart the database immediately to make it effective?', { btn: ['Restart now', 'Restart later'], icon: 3, title: 'Confirm Restart?' }, function() { bt.pub.set_server_status('mysql','restart'); }, function() { layer.close(loadP); }); }); }); }); break; case 'get_mysql_run_status': bt.send('GetRunStatus', 'database/GetRunStatus', {}, function(rdata) { var cache_size = ((parseInt(rdata.Qcache_hits) / (parseInt(rdata.Qcache_hits) + parseInt(rdata.Qcache_inserts))) * 100).toFixed(2) + '%'; if (cache_size == 'NaN%') cache_size = 'OFF'; var title10 = ((1 - rdata.Threads_created / rdata.Connections) * 100).toFixed(2); var title11 = ((1 - rdata.Key_reads / rdata.Key_read_requests) * 100).toFixed(2); var title12 = ((1 - rdata.Innodb_buffer_pool_reads / rdata.Innodb_buffer_pool_read_requests) * 100).toFixed(2); var title14 = ((rdata.Created_tmp_disk_tables / rdata.Created_tmp_tables) * 100).toFixed(2); var Con = '
    \ \ \ \ \ \ \
    ' + lan.soft.mysql_status_title1 + '' + getLocalTime(rdata.Run) + '' + lan.soft.mysql_status_title5 + '' + parseInt(rdata.Questions / rdata.Uptime) + '
    ' + lan.soft.mysql_status_title2 + '' + rdata.Connections + '' + lan.soft.mysql_status_title6 + '' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + '
    ' + lan.soft.mysql_status_title3 + '' + ToSize(rdata.Bytes_sent) + '' + lan.soft.mysql_status_title7 + '' + rdata.File + '
    ' + lan.soft.mysql_status_title4 + '' + ToSize(rdata.Bytes_received) + '' + lan.soft.mysql_status_title8 + '' + rdata.Position + '
    \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
    ' + lan.soft.mysql_status_title9 + '' + rdata.Threads_running + '/' + rdata.Max_used_connections + '' + lan.soft.mysql_status_ps1 + '
    ' + lan.soft.mysql_status_title10 + '' + (!isNaN(title10) ? title10 : '0') + '%' + lan.soft.mysql_status_ps2 + '
    ' + lan.soft.mysql_status_title11 + '' + (!isNaN(title11) ? title11 : '0') + '%' + lan.soft.mysql_status_ps3 + '
    ' + lan.soft.mysql_status_title12 + '' + (!isNaN(title12) ? title12 : '0') + '%' + lan.soft.mysql_status_ps4 + '
    ' + lan.soft.mysql_status_title13 + '' + cache_size + '' + lan.soft.mysql_status_ps5 + '
    ' + lan.soft.mysql_status_title14 + '' + (!isNaN(title14) ? title14 : '0') + '%' + lan.soft.mysql_status_ps6 + '
    ' + lan.soft.mysql_status_title15 + '' + rdata.Open_tables + '' + lan.soft.mysql_status_ps7 + '
    ' + lan.soft.mysql_status_title16 + '' + rdata.Select_full_join + '' + lan.soft.mysql_status_ps8 + '
    ' + lan.soft.mysql_status_title17 + '' + rdata.Select_range_check + '' + lan.soft.mysql_status_ps9 + '
    ' + lan.soft.mysql_status_title18 + '' + rdata.Sort_merge_passes + '' + lan.soft.mysql_status_ps10 + '
    ' + lan.soft.mysql_status_title19 + '' + rdata.Table_locks_waited + '' + lan.soft.mysql_status_ps11 + '
    ' $(".soft-man-con").html(Con); }) break; case 'get_mysql_status': bt.send('GetDbStatus', 'database/GetDbStatus', {}, function(rdata) { var key_buffer_size = bt.format_size(rdata.mem.key_buffer_size, false, 0, 'MB') var query_cache_size = bt.format_size(rdata.mem.query_cache_size, false, 0, 'MB') var tmp_table_size = bt.format_size(rdata.mem.tmp_table_size, false, 0, 'MB') var innodb_buffer_pool_size = bt.format_size(rdata.mem.innodb_buffer_pool_size, false, 0, 'MB') var innodb_additional_mem_pool_size = bt.format_size(rdata.mem.innodb_additional_mem_pool_size, false, 0, 'MB') var innodb_log_buffer_size = bt.format_size(rdata.mem.innodb_log_buffer_size, false, 0, 'MB') var sort_buffer_size = bt.format_size(rdata.mem.sort_buffer_size, false, 0, 'MB') var read_buffer_size = bt.format_size(rdata.mem.read_buffer_size, false, 0, 'MB') var read_rnd_buffer_size = bt.format_size(rdata.mem.read_rnd_buffer_size, false, 0, 'MB') var join_buffer_size = bt.format_size(rdata.mem.join_buffer_size, false, 0, 'MB') var thread_stack = bt.format_size(rdata.mem.thread_stack, false, 0, 'MB') var binlog_cache_size = bt.format_size(rdata.mem.binlog_cache_size, false, 0, 'MB') var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size var memSize = a + rdata.mem.max_connections * b var mysql_select = { '1': { title: '1-2GB', data: { key_buffer_size: 128, query_cache_size: 64, tmp_table_size: 64, innodb_buffer_pool_size: 256, sort_buffer_size: 768, read_buffer_size: 768, read_rnd_buffer_size: 512, join_buffer_size: 1024, thread_stack: 256, binlog_cache_size: 64, thread_cache_size: 64, table_open_cache: 128, max_connections: 100 } }, '2': { title: '2-4GB', data: { key_buffer_size: 256, query_cache_size: 128, tmp_table_size: 384, innodb_buffer_pool_size: 384, sort_buffer_size: 768, read_buffer_size: 768, read_rnd_buffer_size: 512, join_buffer_size: 2048, thread_stack: 256, binlog_cache_size: 64, thread_cache_size: 96, table_open_cache: 192, max_connections: 200 } }, '3': { title: '4-8GB', data: { key_buffer_size: 384, query_cache_size: 192, tmp_table_size: 512, innodb_buffer_pool_size: 512, sort_buffer_size: 1024, read_buffer_size: 1024, read_rnd_buffer_size: 768, join_buffer_size: 2048, thread_stack: 256, binlog_cache_size: 128, thread_cache_size: 128, table_open_cache: 384, max_connections: 300 } }, '4': { title: '8-16GB', data: { key_buffer_size: 512, query_cache_size: 256, tmp_table_size: 1024, innodb_buffer_pool_size: 1024, sort_buffer_size: 2048, read_buffer_size: 2048, read_rnd_buffer_size: 1024, join_buffer_size: 4096, thread_stack: 384, binlog_cache_size: 192, thread_cache_size: 192, table_open_cache: 1024, max_connections: 400 } }, '5': { title: '16-32GB', data: { key_buffer_size: 1024, query_cache_size: 384, tmp_table_size: 2048, innodb_buffer_pool_size: 4096, sort_buffer_size: 4096, read_buffer_size: 4096, read_rnd_buffer_size: 2048, join_buffer_size: 8192, thread_stack: 512, binlog_cache_size: 256, thread_cache_size: 256, table_open_cache: 2048, max_connections: 500 } } } var mysql_arrs = [{ value: 0, title: lan.soft.mysql_set_select }] for (var key in mysql_select) mysql_arrs.push({ value: key, title: mysql_select[key].title }) var form_datas = [{ items: [{ title: lan.soft.mysql_set_msg, name: 'mysql_set', type: 'select', items: mysql_arrs, callback: function(item) { if (item.val() > 0) { var data = mysql_select[item.val()].data; for (var key in data) $('.' + key).val(data[key]); if (!data.query_cache_size) data['query_cache_size'] = 0; $("input[name='max_connections']").trigger('change') } } }, { title: lan.soft.mysql_set_maxmem, name: 'memSize', width: '70px', disabled: true, value: memSize.toFixed(2), ps: 'MB' } ] }, { title: 'key_buffer_size', type: 'number', name: 'key_buffer_size', width: '70px', value: key_buffer_size, ps: 'MB, ' + lan.soft.mysql_set_key_buffer_size + '' }, { title: 'query_cache_size', type: 'number', name: 'query_cache_size', width: '70px', value: query_cache_size, ps: 'MB, ' + lan.soft.mysql_set_query_cache_size + '' }, { title: 'tmp_table_size', type: 'number', name: 'tmp_table_size', width: '70px', value: tmp_table_size, ps: 'MB, ' + lan.soft.mysql_set_tmp_table_size + '' }, { title: 'innodb_buffer_pool_size', type: 'number', name: 'innodb_buffer_pool_size', value: innodb_buffer_pool_size, width: '70px', ps: 'MB, ' + lan.soft.mysql_set_innodb_buffer_pool_size + '' }, { title: 'innodb_log_buffer_size', type: 'number', name: 'innodb_log_buffer_size', value: innodb_log_buffer_size, width: '70px', ps: 'MB, ' + lan.soft.mysql_set_innodb_log_buffer_size + '' }, { title: 'sort_buffer_size', type: 'number', name: 'sort_buffer_size', width: '70px', value: (sort_buffer_size * 1024), ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_sort_buffer_size + '' }, { title: 'read_buffer_size', type: 'number', name: 'read_buffer_size', width: '70px', value: (read_buffer_size * 1024), ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_buffer_size + '' }, { title: 'read_rnd_buffer_size', type: 'number', name: 'read_rnd_buffer_size', width: '70px', value: (read_rnd_buffer_size * 1024), ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_rnd_buffer_size + '' }, { title: 'join_buffer_size', type: 'number', name: 'join_buffer_size', width: '70px', value: (join_buffer_size * 1024), ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_join_buffer_size + '' }, { title: 'thread_stack', type: 'number', name: 'thread_stack', width: '70px', value: (thread_stack * 1024), ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_thread_stack + '' }, { title: 'binlog_cache_size', type: 'number', name: 'binlog_cache_size', value: (binlog_cache_size * 1024), width: '70px', ps: 'KB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_binlog_cache_size + '' }, { title: 'thread_cache_size', type: 'number', name: 'thread_cache_size', value: rdata.mem.thread_cache_size, width: '70px', ps: lan.soft.mysql_set_thread_cache_size }, { title: 'table_open_cache', type: 'number', name: 'table_open_cache', value: rdata.mem.table_open_cache, width: '70px', ps: lan.soft.mysql_set_table_open_cache }, { title: 'max_connections', type: 'number', name: 'max_connections', value: rdata.mem.max_connections, width: '70px', ps: lan.soft.mysql_set_max_connections }, { items: [{ text: lan.soft.mysql_set_restart, type: 'button', name: 'bt_mysql_restart', callback: function(ldata) { bt.pub.set_server_status('mysqld', 'restart'); } }, { text: lan.public.save, type: 'button', name: 'bt_mysql_save', callback: function(ldata) { ldata.query_cache_type = 0; if (ldata.query_cache_size > 0) ldata.query_cache_type = 1; ldata['max_heap_table_size'] = ldata.tmp_table_size; bt.send('SetDbConf', 'database/SetDbConf', ldata, function(rdata) { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } } ] } ] var tabCon = $(".soft-man-con").empty().append("
    "); for (var i = 0; i < form_datas.length; i++) { bt.render_form_line(form_datas[i], '', $('.tab-db-status')); } $(".tab-db-status input[name*='size'],.tab-db-status input[name='max_connections'],.tab-db-status input[name='thread_stack']").change(function() { var key_buffer_size = parseInt($("input[name='key_buffer_size']").val()); var query_cache_size = parseInt($("input[name='query_cache_size']").val()); var tmp_table_size = parseInt($("input[name='tmp_table_size']").val()); var innodb_buffer_pool_size = parseInt($("input[name='innodb_buffer_pool_size']").val()); var innodb_log_buffer_size = parseInt($("input[name='innodb_log_buffer_size']").val()); var sort_buffer_size = $("input[name='sort_buffer_size']").val() / 1024; var read_buffer_size = $("input[name='read_buffer_size']").val() / 1024; var read_rnd_buffer_size = $("input[name='read_rnd_buffer_size']").val() / 1024; var join_buffer_size = $("input[name='join_buffer_size']").val() / 1024; var thread_stack = $("input[name='thread_stack']").val() / 1024; var binlog_cache_size = $("input[name='binlog_cache_size']").val() / 1024; var max_connections = $("input[name='max_connections']").val(); var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size var memSize = a + max_connections * b $("input[name='memSize']").val(memSize.toFixed(2)); }); }) break; case 'mysql_log': var loadT = bt.load(); bt.send('BinLog', 'database/BinLog', { status: 1 }, function(rdata) { loadT.close(); var limitCon = '

    \ ' + lan.soft.mysql_log_bin + ' ' + ToSize(rdata.msg) + '\ \

    ' + lan.soft.mysql_log_err + '

    \ \

    ' $(".soft-man-con").html(limitCon); //设置二进制日志 $(".btn-bin").click(function() { var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 }); $.post('/database?action=BinLog', "", function(rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); soft.get_tab_contents('mysql_log') }); }) //清空日志 $(".btn-clear").click(function() { var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 }); $.post('/database?action=GetErrorLog', "close=1", function(rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); soft.get_tab_contents('mysql_log') }); }) bt.send('GetErrorLog', 'database/GetErrorLog', {}, function(error_body) { if (error_body.status === false) { layer.msg(error_body.msg, { icon: 5 }); error_body = lan.soft.mysql_log_ps1; } if (error_body == "") error_body = lan.soft.mysql_log_ps1; $("#error_log").text(error_body); var ob = document.getElementById('error_log'); ob.scrollTop = ob.scrollHeight; }); }) break; case 'mysql_slow_log': var loadT = bt.load(); bt.send('GetSlowLogs', 'database/GetSlowLogs', {}, function(logs) { loadT.close(); if (!logs.status) { logs.msg = ''; } if (logs.msg == '') logs.msg = lan.soft.no_slow_log; var phpCon = ''; $(".soft-man-con").html(phpCon); var ob = document.getElementById('error_log'); ob.scrollTop = ob.scrollHeight; }) break; case 'log': var loadT = bt.load(lan.public.the_get); bt.send('GetOpeLogs', 'ajax/GetOpeLogs', { path: '/www/wwwlogs/nginx_error.log' }, function(rdata) { loadT.close(); if (rdata.msg == '') rdata.msg = lan.soft.no_log; var ebody = '
    '; $(".soft-man-con").html(ebody); var ob = document.getElementById('error_log'); ob.scrollTop = ob.scrollHeight; }) break; case 'nginx_status': var loadT = bt.load(); bt.send('GetNginxStatus', 'ajax/GetNginxStatus', {}, function(rdata) { loadT.close(); $(".soft-man-con").html("
    "); var arrs = [] arrs[lan.bt.nginx_active] = rdata.active; arrs[lan.bt.nginx_accepts] = rdata.accepts; arrs[lan.bt.nginx_handled] = rdata.handled; arrs[lan.bt.nginx_requests] = rdata.requests; arrs[lan.bt.nginx_reading] = rdata.Reading; arrs[lan.bt.nginx_writing] = rdata.Writing; arrs[lan.bt.nginx_waiting] = rdata.Waiting; arrs[lan.bt.nginx_worker] = rdata.worker; arrs[lan.bt.nginx_workercpu] = rdata.workercpu; arrs[lan.bt.nginx_workermen] = rdata.workermen; bt.render_table("tab-nginx-status", arrs); }) break; case 'nginx_format_log': var loadT = bt.load(); bt.send('get_nginx_access_log_format', 'config/get_nginx_access_log_format', {}, function(rdata) { $(".soft-man-con").html("
    NameFormatOpt
    "); bt.send('get_nginx_access_log_format_parameter', 'config/get_nginx_access_log_format_parameter', {}, function(res) { loadT.close(); var _format_ul = ''; for (const j in rdata) { if (rdata.hasOwnProperty(j)) { const result = rdata[j]; var _format = result.map(function(item, index){ return Object.keys(item)[0]; }); var element = '' + _format.join('') + '', _td = ''+j+'\ '+element+'\ Apply | Set | Del'; $("#tab-nginx-logs-format tbody").append(_td); //表格头固定 $('#tab-nginx-logs-format').parent().on('scroll', function () { var scrollTop = $('#tab-nginx-logs-format').parent().scrollTop(); $('#tab-nginx-logs-format thead').css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"}); }); } } $('.table-add-format, .table-set-format').click(function() { if($(this).hasClass('table-set-format')) { var format_title = 'Set format', first_format = '', add_type = 'edit', td_format = $(this).parent().prev().find('.nginx-one-format'); format_name = $(this).parent().attr('data-name'); for (var i = 0; i < td_format.length; i++) { first_format += '
    \
    \
    \
    '+td_format.eq(i).text()+'
    \ \
    \
    \ Del\
    '; } }else{ var format_title = 'Add format', format_name = '', add_type = 'add', first_format = '', format_list = ['$http_x_forwarded_for','$remote_addr','-','[$time_local]','$request','$status','$body_bytes_sent','$http_referer','$http_user_agent']; for (var i = 0; i < format_list.length; i++) { first_format += '
    \
    \
    \
    '+format_list[i]+'
    \ \
    \
    \ Del\
    '; } } layer.open({ type: 1, title: format_title, closeBtn: 2, area: '375px', btn: ['Confirm', 'Cancel'], content: '
    \
    \ Name: \ \
    \ Format:\
    \
    '+first_format+'
    \ '+_format_ul+'\
    \ \
    • The format are executed in the order of parameters.
    \
    ', success: function(index, layero) { $('.nginx-add-format [name=log_format_name]').val(format_name); $('.nginx-add-format').parents('.layui-layer-content').css('overflow','inherit'); $('.nginx-add-format').on('click', '.bt-select-input', function (e) { if($(this).hasClass('active')){ $('.nginx-add-format .bt-select-list').removeClass('active'); $(this).removeClass('active').find('.bt-down-icon').css('transform','rotate(-45deg)'); }else{ var _choose = $(this).find('.bt-select-val').text(); $('.bt-select-list li').removeClass('active'); $('.active.bt-select-input').removeClass('active').find('.bt-down-icon').css('transform','rotate(-45deg)') $('.bt-select-list li:contains('+_choose+')').addClass('active'); $('.nginx-add-format .bt-select-list').addClass('active').css('top',$(this).offset().top-$('.format-table').offset().top+33); $(this).addClass('active').find('.bt-down-icon').css('transform','rotate(135deg)'); } e.stopPropagation(); $(document).click(function(e){ $('.active.bt-select-list').removeClass('active'); $(this).find('.bt-down-icon').css('transform','rotate(-45deg)'); e.preventDefault(); e.stopPropagation(); }); }); $('.nginx-add-format').on('click', '.bt-select-list li', function (e) { var _value = $(this).attr('data-val'); $('.active.bt-select-input').find('.bt-select-val').attr('data-active',_value).text(_value); $('.nginx-add-format .bt-select-list,.active.bt-select-input').removeClass('active'); }); $('.btn-add-format').click(function (e) { var _new_line = '
    \
    \
    \
    $server_name
    \ \
    \
    \ Del\
    '; $('.format-table').append(_new_line); $('.format-table').scrollTop(10000000) }); $('.nginx-add-format').on('click', '.del-format', function (e) { if ($('.del-format').length == 1) { layer.msg('This is the last parameter.', {icon: 2}); return false; } $(this).parent().remove(); }); }, yes: function(index, layero) { if ($('.nginx-add-format [name=log_format_name]').val()=='') { layer.msg('The format name cannot be empty!', {icon: 2}); return false; } var log_format = []; $(".nginx-add-format .format-table .bt-select-val").each(function(){ log_format.push($(this).attr("data-active")); }); var format_data = { "log_format_name": $('.nginx-add-format [name=log_format_name]').val(), "log_format": JSON.stringify(log_format), "act": add_type } bt.send('add_nginx_access_log_format', 'config/add_nginx_access_log_format', format_data, function(res) { layer.close(index); $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }) } }) }); $('#tab-nginx-logs-format').on('click', '.table-del-format', function (e) { var log_format_name = $(this).parent().attr('data-name'), loadP = layer.confirm('Confirm to delete【'+log_format_name+'】this logs format?', { title: 'Confirm Delete?', closeBtn: 2 }, function() { layer.close(loadP); bt.send('del_nginx_access_log_format', 'config/del_nginx_access_log_format', {'log_format_name': log_format_name}, function(res) { if(res.status) $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }); }); }); $('#tab-nginx-logs-format').on('click', '.table-apply-format', function (e) { var log_format_name = $(this).parent().attr('data-name'); bt.send('get_nginx_access_log_format_parameter', 'config/get_nginx_access_log_format_parameter', {'log_format_name':log_format_name}, function(res) { if (Object.keys(res.site_list).length == 0) { layer.msg('There is no site can apply!', {icon: 2}); return false; } var _site_ul = ''; layer.open({ type: 1, title: 'Website apply format', closeBtn: 2, btn: ['Confirm', 'Cancel'], content: '
    \
    \ Site: \ '+_site_ul+'\
    \
    The checked site would used the format.
    \
    ', success: function(index, layero) { $('.nginx-add-site').on('click', '.format-site-list li', function (e) { if ($(this).find('.bt_checkbox_groups').hasClass('active')) { $(this).find('.bt_checkbox_groups').removeClass('active'); } else { $(this).find('.bt_checkbox_groups').addClass('active'); } }); }, yes: function(index, layero) { var sites = []; $(".nginx-add-site .format-site-list .bt_checkbox_groups.active").each(function(){ sites.push($(this).attr("data-val")); }); var format_data = { "log_format_name": log_format_name, "sites": JSON.stringify(sites) } bt.send('set_format_log_to_website', 'config/set_format_log_to_website', format_data, function(res) { layer.close(index); if(res.status) $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }) } }) }); }); }); }); break; case 'apache_format_log': var loadT = bt.load(); bt.send('get_httpd_access_log_format', 'config/get_httpd_access_log_format', {}, function(rdata) { $(".soft-man-con").html("
    NameFormatOpt
    "); bt.send('get_httpd_access_log_format_parameter', 'config/get_httpd_access_log_format_parameter', {}, function(res) { loadT.close(); var _format_ul = ''; for (const j in rdata) { if (rdata.hasOwnProperty(j)) { const result = rdata[j]; var _format = result.map(function(item, index){ return Object.keys(item)[0]; }); var element = '' + _format.join('') + '', _td = ''+j+'\ '+element+'\ Apply | Set | Del'; $("#tab-nginx-logs-format tbody").append(_td); //表格头固定 $('#tab-nginx-logs-format').parent().on('scroll', function () { var scrollTop = $('#tab-nginx-logs-format').parent().scrollTop(); $('#tab-nginx-logs-format thead').css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"}); }); } } $('.table-add-format, .table-set-format').click(function() { if($(this).hasClass('table-set-format')) { var format_title = 'Set format', first_format = '', add_type = 'edit', td_format = $(this).parent().prev().find('.nginx-one-format'); format_name = $(this).parent().attr('data-name'); for (var i = 0; i < td_format.length; i++) { first_format += '
    \
    \
    \
    '+td_format.eq(i).text()+'
    \ \
    \
    \ Del\
    '; } }else{ var format_title = 'Add format', format_name = '', add_type = 'add', first_format = '', format_list = ['%{X-Forwarded-For}i','%h','%l','%u','%t','%r','%>s','%b','%{Referer}i','%{User-agent}i']; for (var i = 0; i < format_list.length; i++) { first_format += '
    \
    \
    \
    '+format_list[i]+'
    \ \
    \
    \ Del\
    '; } } layer.open({ type: 1, title: format_title, closeBtn: 2, area: '375px', btn: ['Confirm', 'Cancel'], content: '
    \
    \ Name: \ \
    \ Format:\
    \
    '+first_format+'
    \ '+_format_ul+'\
    \ \
    • The format are executed in the order of parameters.
    \
    ', success: function(index, layero) { $('.nginx-add-format [name=log_format_name]').val(format_name); $('.nginx-add-format').parents('.layui-layer-content').css('overflow','inherit'); $('.nginx-add-format').on('click', '.bt-select-input', function (e) { if($(this).hasClass('active')){ $('.nginx-add-format .bt-select-list').removeClass('active'); $(this).removeClass('active').find('.bt-down-icon').css('transform','rotate(-45deg)'); }else{ var _choose = $(this).find('.bt-select-val').text(); $('.bt-select-list li').removeClass('active'); $('.active.bt-select-input').removeClass('active').find('.bt-down-icon').css('transform','rotate(-45deg)') $('.bt-select-list li:contains('+_choose+')').addClass('active'); $('.nginx-add-format .bt-select-list').addClass('active').css('top',$(this).offset().top-$('.format-table').offset().top+33); $(this).addClass('active').find('.bt-down-icon').css('transform','rotate(135deg)'); } e.stopPropagation(); $(document).click(function(e){ $('.active.bt-select-list').removeClass('active'); $(this).find('.bt-down-icon').css('transform','rotate(-45deg)'); e.preventDefault(); e.stopPropagation(); }); }); $('.nginx-add-format').on('click', '.bt-select-list li', function (e) { var _value = $(this).attr('data-val'); $('.active.bt-select-input').find('.bt-select-val').attr('data-active',_value).text(_value); $('.nginx-add-format .bt-select-list,.active.bt-select-input').removeClass('active'); }); $('.btn-add-format').click(function (e) { var _new_line = '
    \
    \
    \
    %>s
    \ \
    \
    \ Del\
    '; $('.format-table').append(_new_line); $('.format-table').scrollTop(10000000) }); $('.nginx-add-format').on('click', '.del-format', function (e) { if ($('.del-format').length == 1) { layer.msg('This is the last parameter.', {icon: 2}); return false; } $(this).parent().remove(); }); }, yes: function(index, layero) { if ($('.nginx-add-format [name=log_format_name]').val()=='') { layer.msg('The format name cannot be empty!', {icon: 2}); return false; } var log_format = []; $(".nginx-add-format .format-table .bt-select-val").each(function(){ log_format.push($(this).attr("data-active")); }); var format_data = { "log_format_name": $('.nginx-add-format [name=log_format_name]').val(), "log_format": JSON.stringify(log_format), 'act':add_type } bt.send('add_httpd_access_log_format', 'config/add_httpd_access_log_format', format_data, function(res) { layer.close(index); if(res.status) $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }) } }) }); $('#tab-nginx-logs-format').on('click', '.table-del-format', function (e) { var log_format_name = $(this).parent().attr('data-name'), loadP = layer.confirm('Confirm to delete【'+log_format_name+'】this logs format?', { title: 'Confirm Delete?', closeBtn: 2 }, function() { layer.close(loadP); bt.send('del_httpd_access_log_format', 'config/del_httpd_access_log_format', {'log_format_name': log_format_name}, function(res) { if(res.status) $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }); }); }); $('#tab-nginx-logs-format').on('click', '.table-apply-format', function (e) { var log_format_name = $(this).parent().attr('data-name'); bt.send('get_httpd_access_log_format_parameter', 'config/get_httpd_access_log_format_parameter', {'log_format_name':log_format_name}, function(res) { if (Object.keys(res.site_list).length == 0) { layer.msg('There is no site can apply!', {icon: 2}); return false; } var _site_ul = ''; layer.open({ type: 1, title: 'Website apply format', closeBtn: 2, btn: ['Confirm', 'Cancel'], content: '
    \
    \ Site: \ '+_site_ul+'\
    \
    The checked site would used the format.
    \
    ', success: function(index, layero) { $('.nginx-add-site').on('click', '.format-site-list li', function (e) { if ($(this).find('.bt_checkbox_groups').hasClass('active')) { $(this).find('.bt_checkbox_groups').removeClass('active'); } else { $(this).find('.bt_checkbox_groups').addClass('active'); } }); }, yes: function(index, layero) { var sites = []; $(".nginx-add-site .format-site-list .bt_checkbox_groups.active").each(function(){ sites.push($(this).attr("data-val")); }); var format_data = { "log_format_name": log_format_name, "sites": JSON.stringify(sites) } bt.send('set_httpd_format_log_to_website', 'config/set_httpd_format_log_to_website', format_data, function(res) { layer.close(index); if(res.status) $('.bt-soft-menu p:contains("Logs format")').click(); layer.msg(res.msg, {icon: res.status ? 1 : 2}); }) } }) }); }); }); }); break; case 'apache_status': var loadT = bt.load(); bt.send('GetApacheStatus', 'ajax/GetApacheStatus', {}, function(rdata) { loadT.close(); $(".soft-man-con").html("
    "); var arrs = [] arrs[lan.bt.apache_uptime] = rdata.UpTime; arrs[lan.bt.apache_idleworkers] = rdata.IdleWorkers; arrs[lan.bt.apache_totalaccesses] = rdata.TotalAccesses; arrs[lan.bt.apache_totalkbytes] = rdata.TotalKBytes; arrs[lan.bt.apache_workermem] = rdata.workermem; arrs[lan.bt.apache_workercpu] = rdata.workercpu; arrs[lan.bt.apache_reqpersec] = rdata.ReqPerSec; arrs[lan.bt.apache_restarttime] = rdata.RestartTime; arrs[lan.bt.apache_busyworkers] = rdata.BusyWorkers; bt.render_table("tab-Apache-status", arrs); }) break; case 'nginx_set': var loadT = bt.load(); bt.send('GetNginxValue', 'config/GetNginxValue', {}, function(rdata) { loadT.close(); var form_datas = [] for (var i = 0; i < rdata.length; i++) { if (rdata[i].name == 'worker_processes') { form_datas.push({ title: rdata[i].name, name: rdata[i].name, width: '60px', value: rdata[i].value, ps: rdata[i].ps, text: '' }) } else if (rdata[i].name == 'gzip') { form_datas.push({ title: rdata[i].name, type: 'select', items: [{ title: lan.soft.on, value: 'on' }, { title: lan.soft.off, value: 'off' }], name: rdata[i].name, width: '60px', value: rdata[i].value, ps: rdata[i].ps, text: '' }) } else { form_datas.push({ title: rdata[i].name, type: 'number', name: rdata[i].name, width: '60px', value: rdata[i].value, ps: rdata[i].ps, text: '' }) } } form_datas.push({ items: [{ text: lan.public.save, type: 'button', name: 'bt_nginx_save', callback: function(item) { delete item['bt_nginx_save'] bt.send('SetNginxValue', 'config/SetNginxValue', item, function(rdata) { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } }] }) $(".soft-man-con").empty().append('
    '); for (var i = 0; i < form_datas.length; i++) { bt.render_form_line(form_datas[i], '', $(".soft-man-con .set_nginx_config")); } }); break; case 'apache_set': var loadT = bt.load(); bt.send('GetNginxValue', 'config/GetApacheValue', {}, function(rdata) { loadT.close(); var form_datas = [] for (var i = 0; i < rdata.length; i++) { if (rdata[i].name == 'KeepAlive') { form_datas.push({ title: rdata[i].name, type: 'select', items: [{ title: lan.soft.on, value: 'on' }, { title: lan.soft.off, value: 'off' }], name: rdata[i].name, width: '65px', value: rdata[i].value, ps: rdata[i].ps, text: '' }) } else { form_datas.push({ title: rdata[i].name, type: 'number', name: rdata[i].name, width: '65px', value: rdata[i].value, ps: rdata[i].ps, text: '' }) } } form_datas.push({ items: [{ text: lan.public.save, type: 'button', name: 'bt_apache_save', callback: function(item) { delete item['bt_apache_save']; bt.send('SetApacheValue', 'config/SetApacheValue', item, function(rdata) { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); }); } }] }) $(".soft-man-con").empty().append('
    '); for (var i = 0; i < form_datas.length; i++) { bt.render_form_line(form_datas[i], '', $(".soft-man-con .set_Apache_config")); } }); break; case 'memcached_status': case 'memcached_set': var loadT = bt.load(lan.public.get_the); bt.send('GetMemcachedStatus', 'ajax/GetMemcachedStatus', {}, function(rdata) { loadT.close(); if (key == 'memcached_set') { var form_data = [{ title: 'BindIP', name: 'ip', width: '120px', value: rdata.bind, ps: lan.soft.listen_ip_tips }, { title: 'PORT', name: 'port', type: 'number', width: '120px', value: rdata.port, ps: lan.soft.listen_port_tips }, { title: 'CACHESIZE', name: 'cachesize', type: 'number', width: '120px', value: rdata.cachesize, ps: lan.soft.cache_size }, { title: 'MAXCONN', name: 'maxconn', type: 'number', width: '120px', value: rdata.maxconn, ps: lan.soft.mac_connect }, { title: ' ', items: [{ text: lan.public.save, name: 'btn_set_memcached', type: 'button', callback: function(ldata) { if (ldata.ip.split('.').length < 4) { layer.msg(lan.soft.ip_format_err, { icon: 2 }); return; } if (ldata.port < 1 || ldata.port > 65535) { layer.msg(lan.soft.port_range_err, { icon: 2 }); return; } if (ldata.cachesize < 8) { layer.msg(lan.soft.cache_too_small, { icon: 2 }); return; } if (ldata.maxconn < 4) { layer.msg(lan.soft.connect_too_small, { icon: 2 }); return; } var loadT = bt.load(lan.public.the); bt.send('SetMemcachedCache', 'ajax/SetMemcachedCache', ldata, function(rdata) { loadT.close(); bt.msg(rdata) }); } }] } ] var tabCon = $(".soft-man-con").empty(); for (var i = 0; i < form_data.length; i++) { bt.render_form_line(form_data[i], '', tabCon); } return; } else { var arr = {}; arr['BindIP'] = [rdata.bind, lan.soft.listen_ip]; arr['PORT'] = [rdata.port, lan.soft.listen_port]; arr['CACHESIZE'] = [rdata.cachesize + ' MB', lan.soft.max_cache]; arr['MAXCONN'] = [rdata.maxconn, lan.soft.max_connect_limit]; arr['curr_connections'] = [rdata.curr_connections, lan.soft.curr_connect]; arr['cmd_get'] = [rdata.cmd_get, lan.soft.get_request_num]; arr['get_hits'] = [rdata.get_hits, lan.soft.get_hit_num]; arr['get_misses'] = [rdata.get_misses, lan.soft.get_miss_num]; arr['hit'] = [rdata.hit.toFixed(2) + ' %', lan.soft.get_hit_percent]; arr['curr_items'] = [rdata.curr_items, lan.soft.curr_cache_rows]; arr['evictions'] = [rdata.evictions, lan.soft.mem_not_enough]; arr['bytes'] = [ToSize(rdata.bytes), lan.soft.curr_mem_use]; arr['bytes_read'] = [ToSize(rdata.bytes_read), lan.soft.request_size_total]; arr['bytes_written'] = [ToSize(rdata.bytes_written), lan.soft.send_size_total]; var con = "
    " + lan.soft.field + "" + lan.soft.curr_val + "" + lan.soft.instructions + "
    "; $(".soft-man-con").html(con); bt.render_table('tab_memcached_status', arr, true); } }) break; case 'phpmyadmin_php': bt.send('GetPHPVersion', 'site/GetPHPVersion', {}, function(rdata) { var sdata = $('.bt-soft-menu').data('data'); var body = "
    " + lan.soft.php_version + "
    '; $(".soft-man-con").html(body); $('.btn-success').click(function() { var loadT = bt.load(lan.public.the); bt.send('setPHPMyAdmin', 'ajax/setPHPMyAdmin', { phpversion: $("#get_phpVersion").val() }, function(rdata) { loadT.close(); bt.msg(rdata); if (rdata.status) { setTimeout(function() { window.location.reload(); }, 3000); } }) }) }) break; case 'phpmyadmin_safe': var sdata = $('.bt-soft-menu').data('data'), sslPortNum = ''; var con = '
    \ ' + lan.soft.pma_port + '\ \ \
    \
    \ Open SSL\ \ \ \
    \
    \ SSL port\ \ \
    \
    \ ' + lan.soft.pma_pass + '\ \ \ \
    \
    \

    ' + lan.soft.pma_user + '

    \

    ' + lan.soft.pma_pass1 + '

    \

    ' + lan.soft.pma_pass2 + '

    \

    \
    \ '; $(".soft-man-con").html(con); if (sdata.ext.port) { $(".user_pw").show(); } function get_phpmyadmin_ssl() { var loading = bt.load('Getting SSL Status...'); bt.send('get_phpmyadmin_ssl', 'ajax/get_phpmyadmin_ssl', {}, function(tdata) { loading.close(); $('#ssl_safe_checkbox').prop("checked", tdata.status); $('#sslport').val(tdata.port) }) } get_phpmyadmin_ssl() $('.phpmyadmin_port').click(function() { var pmport = $("#pmport").val(); var loadT = bt.load(lan.public.the); bt.send('setPHPMyAdmin', 'ajax/setPHPMyAdmin', { port: pmport }, function(rdata) { loadT.close(); bt.msg(rdata); }) }) $('.ssl_safe_label').click(function() { var stat = $('#ssl_safe_checkbox').prop("checked"); bt.send('set_phpmyadmin_ssl', 'ajax/set_phpmyadmin_ssl', { v: !stat ? 1 : 0 }, function(rdata) { bt.msg(rdata) }) setTimeout(function() { get_phpmyadmin_ssl(); }, 500) }) $('.ssl_port_button').click(function() { var sslPort = $('#sslport').val(); if (!bt.check_port(sslPort)) { layer.msg(lan.firewall.port_err, { icon: 2 }); return; } var loadTo = bt.load(lan.public.the); if (sslPort > 0) { bt.send('change_phpmyadmin_ssl_port', 'ajax/change_phpmyadmin_ssl_port', { port: sslPort }, function(rdata) { loadTo.close(); bt.msg(rdata); }) } }) $('.phpmyadmin_safe').click(function() { var stat = $("#phpmyadminsafe").prop("checked"); if (stat) { $(".user_pw").hide(); set_phpmyadmin('close'); } else { $(".user_pw").show(); } }) $('.phpmyadmin_safe_save').click(function() { set_phpmyadmin('get'); }) function set_phpmyadmin(msg) { var type = 'password'; if (msg == 'close') { bt.confirm({ msg: lan.soft.pma_pass_close }, function() { var loading = bt.load(lan.public.the); bt.send('setPHPMyAdmin', 'ajax/setPHPMyAdmin', { password: msg, siteName: 'phpmyadmin' }, function(rdata) { loading.close(); bt.msg(rdata); }) }) return; } else { username = $("#username_get").val() password_1 = $("#password_get_1").val() password_2 = $("#password_get_2").val() if (username.length < 1 || password_1.length < 1) { bt.msg({ msg: lan.soft.pma_pass_empty, icon: 2 }) return; } if (password_1 != password_2) { bt.msg({ msg: lan.soft.pass_err_re, icon: 2 }) return; } } var loading = bt.load(lan.public.the); bt.send('setPHPMyAdmin', 'ajax/setPHPMyAdmin', { password: password_1, username: username, siteName: 'phpmyadmin' }, function(rdata) { loading.close(); bt.msg(rdata); setTimeout(function () { location.reload(); }, 1000); }) } break; case 'set_php_config': if (!obj.notLoading) var loading = bt.load(lan.public.the); bt.soft.php.get_config(version, function(rdata) { if (!obj.notLoading) loading.close(); obj.notLoading = false; var divObj = document.getElementById('phpextdiv'); var scrollTopNum = 0; if (divObj) scrollTopNum = divObj.scrollTop; $(".soft-man-con").empty().append('
    '); var list = []; for (var i = 0; i < rdata.libs.length; i++) { if (rdata.libs[i].versions.indexOf(version) == -1) continue; list.push(rdata.libs[i]); } var _tab = bt.render({ table: '#tab_phpext', data: list, columns: [{ field: 'name', title: lan.soft.php_ext_name }, { field: 'type', title: lan.soft.php_ext_type, width: 64 }, { field: 'msg', title: lan.soft.php_ext_ps }, { field: 'status', title: lan.soft.php_ext_status, width: 40, templet: function(item) { return '' } }, { field: 'opt', title: lan.public.action, width: 60, templet: function(item) { var opt = '' + lan.soft.install + '' if (item['task'] == '-1' && item.phpversions.indexOf(version) != -1) { opt = '' + lan.soft.the_install + '' } else if (item['task'] == '0' && item.phpversions.indexOf(version) != -1) { opt = '' + lan.soft.sleep_install + '' } else if (item.status) { opt = '' + lan.soft.uninstall + '' } return opt; } }, ] }) var helps = [lan.soft.php_plug_tips1, lan.soft.php_plug_tips2] $(".soft-man-con").append(bt.render_help(helps)); var divObj = document.getElementById('phpextdiv'); if (divObj) divObj.scrollTop = scrollTopNum; $('a').click(function() { var _obj = $(this); if (_obj.hasClass('lib-uninstall')) { bt.soft.php.un_install_php_lib(version, _obj.attr('data-name'), _obj.attr('data-title'), function(rdata) { setTimeout(function() { soft.get_tab_contents('set_php_config', obj); }, 1000) }); } else if (_obj.hasClass('lib-install')) { bt.soft.php.install_php_lib(version, _obj.attr('data-name'), _obj.attr('data-title'), function(rdata) { setTimeout(function() { soft.get_tab_contents('set_php_config', obj); }, 1000) }); } }) setTimeout(function() { if ($(".bt-soft-menu .bgw").text() === 'Install extensions') { obj.notLoading = true; soft.get_tab_contents('set_php_config', obj); } }, 3000) }) break; case 'get_phpinfo': var con = ''; var p_status = { true: 'Yes', false: 'No' }; var loading = bt.load(lan.public.the); $.post('/ajax?action=php_info', { php_version: version }, function(php_info) { loading.close(); con += '' con += '

    ' + lan.soft.php_base_info + '

    ' con += '
    '; con += '' con += '' con += '' con += '
    ' + lan.soft.version + '' + php_info.phpinfo.php_version + '' + lan.soft.install_path + '' + php_info.phpinfo.php_path + '
    php.ini' + php_info.phpinfo.php_ini + '
    ' + lan.soft.loaded + '' + php_info.phpinfo.modules + '
    '; Object.keys(php_info).sort().forEach(function(k) { if (k !== 'phpinfo') { con += '

    ' + php_info.phpinfo.keys[k] + '

    ' con += ''; var nkey = 0; Object.keys(php_info[k]).forEach(function(key) { if (nkey == 0) con += ''; con += '' nkey++; if (nkey >= 3) { nkey = 0; con += ''; } }); con += '
    ' + key + '' + p_status[php_info[k][key]] + '
    '; } }) $(".soft-man-con").html(con); $('#btn_phpinfo').click(function() { var loadT = bt.load(lan.soft.get); bt.send('GetPHPInfo', 'ajax/GetPHPInfo', { version: version }, function(rdata) { loadT.close(); var content = rdata.replace('a:link {color: #009; text-decoration: none; background-color: #fff;}', '').replace('a:link {color: #000099; text-decoration: none; background-color: #ffffff;}', ''); bt.open({ type: 1, title: "PHP-" + version + "-PHPINFO", area: ['73%', '90%'], closeBtn: 2, shadeClose: true, content: '
    '+content+'
    ' }) }) }) }); break; case 'config_edit': bt.soft.php.get_php_config(version, function(rdata) { var mlist = ''; for (var i = 0; i < rdata.length; i++) { var w = '70' if (rdata[i].name == 'error_reporting') w = '250'; var ibody = ''; switch (rdata[i].type) { case 0: var selected_1 = (rdata[i].value == 1) ? 'selected' : ''; var selected_0 = (rdata[i].value == 0) ? 'selected' : ''; ibody = '' break; case 1: var selected_1 = (rdata[i].value == 'On') ? 'selected' : ''; var selected_0 = (rdata[i].value == 'Off') ? 'selected' : ''; ibody = '' break; } mlist += '

    ' + rdata[i].name + '' + ibody + ', ' + rdata[i].ps + '

    ' } var tabCon = $(".soft-man-con").empty() tabCon.append('
    ' + mlist + '
    ') var datas = { title: ' ', items: [{ name: 'btn_fresh', text: lan.public.fresh, type: 'button', callback: function(ldata) { soft.get_tab_contents(key, obj); } }, { name: 'btn_save', text: lan.public.save, type: 'button', callback: function(ldata) { var loadT = bt.load(); ldata['version'] = version; bt.send('SetPHPConf', 'config/SetPHPConf', ldata, function(rdata) { loadT.close(); soft.get_tab_contents(key, obj); bt.msg(rdata) }); } } ] } var _form_data = bt.render_form_line(datas); $('.conf_p').append(_form_data.html) bt.render_clicks(_form_data.clicks); $(".conf_p > .line").css("margin-top","25px"); }); break; case 'set_upload_limit': bt.soft.php.get_limit_config(version, function(ret) { var datas = [{ items: [{ title: '', type: 'number', width: '100px', value: ret.max, unit: 'MB', name: 'phpUploadLimit' }, { name: 'btn_limit_get', text: lan.public.save, type: 'button', callback: function(ldata) { var max = ldata.phpUploadLimit; if (max < 2) { layer.msg(lan.soft.php_upload_size, { icon: 2 }); return; } bt.soft.php.set_upload_max(version, max, function(rdata) { if (rdata.status) { soft.get_tab_contents(key, obj); } bt.msg(rdata); }) } } ] }] var clicks = []; var tabCon = $(".soft-man-con").empty().append("
    ") for (var i = 0; i < datas.length; i++) { var _form_data = bt.render_form_line(datas[i]); $('.set_upload_limit').append(_form_data.html); clicks = clicks.concat(_form_data.clicks); } bt.render_clicks(clicks); }) break; case 'set_timeout_limit': bt.soft.php.get_limit_config(version, function(ret) { var datas = [{ items: [{ title: '', type: 'number', width: '100px', value: ret.maxTime, name: 'phpTimeLimit', unit: 'Sec' }, { name: 'btn_limit_get', text: lan.public.save, type: 'button', callback: function(ldata) { var max = ldata.phpTimeLimit; bt.soft.php.set_php_timeout(version, max, function(rdata) { if (rdata.status) { soft.get_tab_contents(key, obj); } bt.msg(rdata); }) } } ] }] var clicks = []; var tabCon = $(".soft-man-con").empty().append("
    ") for (var i = 0; i < datas.length; i++) { var _form_data = bt.render_form_line(datas[i]); $('.set_timeout_limit').append(_form_data.html); clicks = clicks.concat(_form_data.clicks); } bt.render_clicks(clicks); }) break; case 'set_dis_fun': var loading = bt.load(lan.public.the); bt.soft.php.get_config(version, function(rdata) { loading.close(); var list = []; var disable_functions = rdata.disable_functions.split(','); for (var i = 0; i < disable_functions.length; i++) { if (disable_functions[i] == '') continue; list.push({ name: disable_functions[i] }) } var _bt_form = $("
    ") var tabCon = $(".soft-man-con").empty().append(_bt_form); var _line = bt.render_form_line({ title: '', items: [{ name: 'disable_function_val', placeholder: lan.soft.fun_ps1, width: '410px' }, { name: 'btn_disable_function_val', text: lan.public.save, type: 'button', callback: function(ldata) { var disable_functions = rdata.disable_functions.split(',') if ($.inArray(ldata.disable_function_val, disable_functions) >= 0) { bt.msg({ msg: lan.soft.fun_msg, icon: 5 }); return; } disable_functions.push(ldata.disable_function_val); set_disable_functions(version, disable_functions.join(',')) } } ] }, '', _bt_form) bt.render_clicks(_line.clicks); _bt_form.append("
    ") var _tab = bt.render({ table: '#blacktable', data: list, columns: [{ field: 'name', title: lan.soft.php_ext_name }, { field: 'opt', title: lan.public.action, width: 50, templet: function(item) { var new_disable_functions = disable_functions.slice() new_disable_functions.splice($.inArray(item.name, new_disable_functions), 1) return '' + lan.soft.del + ''; } } ] }) tabCon.append(bt.render_help([lan.soft.fun_ps2, lan.soft.fun_ps3])); }) break; case 'set_fpm_config': bt.soft.php.get_fpm_config(version, function(rdata) { var datas = { '1GB Ram': { max_children: 30, start_servers: 5, min_spare_servers: 5, max_spare_servers: 20 }, '2GB Ram': { max_children: 50, start_servers: 5, min_spare_servers: 5, max_spare_servers: 30 }, '4GB Ram': { max_children: 80, start_servers: 10, min_spare_servers: 10, max_spare_servers: 30 }, '8GB Ram': { max_children: 120, start_servers: 10, min_spare_servers: 10, max_spare_servers: 30 }, '16GB Ram': { max_children: 200, start_servers: 15, min_spare_servers: 15, max_spare_servers: 50 }, '32GB Ram': { max_children: 300, start_servers: 20, min_spare_servers: 20, max_spare_servers: 50 } } var limits = [], pmList = []; var my_selected = ''; var num_max = Number(rdata.max_children); for (var k in datas) { if (datas[k].max_children === num_max) { my_selected = k; } limits.push({ title: k, value: k }); } var _form_datas = [{ title: lan.soft.concurrency_type, name: 'limit', value: my_selected, type: 'select', items: limits, callback: function(iKey) { var item = datas[iKey.val()] for (var sk in item) $('.' + sk).val(item[sk]); } }, { title: 'Connection', name: 'listen', value: rdata.unix, type: 'select', items: [ { title: 'UNIX socket', value: 'unix' }, { title: 'TCP socket', value: 'tcp' } ], ps: '* UNIX socket recommended' }, { title: lan.soft.php_fpm_model, name: 'pm', value: rdata.pm, type: 'select', items: [{ title: lan.bt.static, value: 'static' }, { title: lan.bt.dynamic, value: 'dynamic' }, { title:'On-demand', value: 'ondemand' } ], ps: '*' + lan.soft.php_fpm_ps1 }, { title: 'max_children', name: 'max_children', value: rdata.max_children, type: 'number', width: '100px', ps: '*' + lan.soft.php_fpm_ps2 }, { title: 'start_servers', name: 'start_servers', value: rdata.start_servers, type: 'number', width: '100px', ps: '*' + lan.soft.php_fpm_ps3 }, { title: 'min_spare_servers', name: 'min_spare_servers', value: rdata.min_spare_servers, type: 'number', width: '100px', ps: '*' + lan.soft.php_fpm_ps4 }, { title: 'max_spare_servers', name: 'max_spare_servers', value: rdata.max_spare_servers, type: 'number', width: '100px', ps: '*' + lan.soft.php_fpm_ps5 }, { title: ' ', text: lan.public.save, name: 'btn_children_submit', css: 'btn-success', type: 'button', callback: function(ldata) { bt.pub.get_menm(function(memInfo) { var limit_children = parseInt(memInfo['memTotal'] / 8); if (limit_children < parseInt(ldata.max_children)) { layer.msg(lan.soft.php_child_process.replace('{1}', limit_children), { icon: 2 }); $("input[name='max_children']").focus(); return; } if (parseInt(ldata.max_children) < parseInt(ldata.max_spare_servers)) { layer.msg(lan.soft.php_fpm_err1, { icon: 2 }); return; } if (parseInt(ldata.min_spare_servers) > parseInt(ldata.start_servers)) { layer.msg(lan.soft.php_fpm_err2, { icon: 2 }); return; } if (parseInt(ldata.max_spare_servers) < parseInt(ldata.min_spare_servers)) { layer.msg(lan.soft.php_fpm_err3, { icon: 2 }); return; } if (parseInt(ldata.max_children) < parseInt(ldata.start_servers)) { layer.msg(lan.soft.php_fpm_err4, { icon: 2 }); return; } if (parseInt(ldata.max_children) < 1 || parseInt(ldata.start_servers) < 1 || parseInt(ldata.min_spare_servers) < 1 || parseInt(ldata.max_spare_servers) < 1) { layer.msg(lan.soft.php_fpm_err5, { icon: 2 }); return; } ldata['version'] = version; bt.soft.php.set_fpm_config(version, ldata, function(rdata) { soft.get_tab_contents(key, obj); bt.msg(rdata); }) }) } } ] var tabCon = $(".soft-man-con").empty() var _c_form = $('
    ') var clicks = []; for (var i = 0; i < _form_datas.length; i++) { var _form = bt.render_form_line(_form_datas[i]); _c_form.append(_form.html) clicks = clicks.concat(_form.clicks); } _c_form.append('') tabCon.append(_c_form); bt.render_clicks(clicks); }); break; case 'get_php_status': bt.soft.php.get_php_status(version, function(rdata) { var arr = {}; arr[lan.bt.php_pool] = rdata.pool; arr[lan.bt.php_manager] = ((rdata['process manager'] == 'dynamic') ? lan.bt.dynamic : lan.bt.static); arr[lan.bt.php_start] = rdata['start time']; arr[lan.bt.php_accepted] = rdata['accepted conn']; arr[lan.bt.php_queue] = rdata['listen queue']; arr[lan.bt.php_max_queue] = rdata['max listen queue']; arr[lan.bt.php_len_queue] = rdata['listen queue len']; arr[lan.bt.php_idle] = rdata['idle processes']; arr[lan.bt.php_active] = rdata['active processes']; arr[lan.bt.php_total] = rdata['total processes']; arr[lan.bt.php_max_active] = rdata['max active processes']; arr[lan.bt.php_max_children] = rdata['max children reached']; arr[lan.bt.php_slow] = rdata['slow requests']; var con = "
    "; $(".soft-man-con").html(con); bt.render_table('tab_php_status', arr); }) break; case 'get_php_session': bt.soft.php.get_php_session(version, function(res) { $(".soft-man-con").html('
    ' + '
    ' + '' + lan.soft.storage_mode + '' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '' + lan.soft.ip_addr + '' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '' + lan.soft.port + '' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '' + lan.soft.passwd + '' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '' + '
    ' + '
      ' + '
    • ' + lan.soft.php_seesion_tips1 + '
    • ' + '
    • ' + lan.soft.php_seesion_tips2 + '
    • ' + '
    • ' + lan.soft.php_seesion_tips3 + '
    • ' + '
    ' + '
    ' + '
    ' + lan.soft.clear_seesion_files + '
    ' + '
    '); if (res.save_handler == 'files') { bt.soft.php.get_session_count(function(res) { $('.clear_conter').html('
    ' + lan.soft.total_seesion_files + '' + res.total + '
    ' + lan.soft.can_clear_seesion + '' + res.oldfile + '
    ') $('.clear_session_file').click(function() { bt.soft.php.clear_session_count({ title: lan.soft.clear_php_seesion_files, msg: lan.soft.sure_clear_php_seesion_files }, function(res) { layer.msg(res.msg, { icon: res.status ? 1 : 2 }); setTimeout(function() { $('.bt-soft-menu p:eq(9)').click(); }, 2000); }); }) }); } else { $('.clear_conter').html(lan.soft.only_files_storage_mode_can_clear).attr('style', 'color:#666') } switch_type(res.save_handler); $('.change_select_session').change(function() { switch_type($(this).val()); switch ($(this).val()) { case 'redis': $('[name="ip"]').val('127.0.0.1'); $('[name="port"]').val('6379'); break; case 'memcache': $('[name="ip"]').val('127.0.0.1'); $('[name="port"]').val('11211'); break; case 'memcached': $('[name="ip"]').val('127.0.0.1'); $('[name="port"]').val('11211'); break; } }); $('.btn_conf_save').click(function() { bt.soft.php.set_php_session({ version: version, save_handler: $('[name="save_handler"]').val(), ip: $('[name="ip"]').val(), port: $('[name="port"]').val(), passwd: $('[name="passwd"]').val() }, function(res) { layer.msg(res.msg, { icon: res.status ? 1 : 2 }); // setTimeout(function() { // $('.bt-soft-menu p:eq(9)').click(); // }, 2000); }) }); function switch_type(type) { switch (type) { case 'files': $('[name="ip"]').attr('disabled', 'disabled').val(''); $('[name="port"]').attr('disabled', 'disabled').val(''); $('[name="passwd"]').attr('disabled', 'disabled').val(''); break; case 'redis': $('[name="ip"]').attr('disabled', false); $('[name="port"]').attr('disabled', false); $('[name="passwd"]').attr('disabled', false); break; case 'memcache': $('[name="ip"]').attr('disabled', false); $('[name="port"]').attr('disabled', false); $('[name="passwd"]').attr('disabled', 'disabled').val(''); break; case 'memcached': $('[name="ip"]').attr('disabled', false); $('[name="port"]').attr('disabled', false); $('[name="passwd"]').attr('disabled', 'disabled').val(''); break; } } }); break case 'get_fpm_logs': bt.soft.php.get_fpm_logs(version, function(logs) { var phpCon = ''; $(".soft-man-con").html(phpCon); var ob = document.getElementById('error_log'); ob.scrollTop = ob.scrollHeight; }) break; case 'get_slow_logs': bt.soft.php.get_slow_logs(version, function(logs) { var phpCon = ''; $(".soft-man-con").html(phpCon); var ob = document.getElementById('error_log'); ob.scrollTop = ob.scrollHeight; }) break; case 'get_redis_status': bt.soft.redis.get_redis_status(function(rdata) { var hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2); var arrs = []; arrs['uptime_in_days'] = [rdata.uptime_in_days, lan.soft.run_days]; arrs['tcp_port'] = [rdata.tcp_port, lan.soft.curr_listen_port]; arrs['connected_clients'] = [rdata.connected_clients, lan.soft.connected_clients]; arrs['used_memory_rss'] = [bt.format_size(rdata.used_memory_rss), lan.soft.used_memory_rss]; arrs['used_memory'] = [bt.format_size(rdata.used_memory), lan.soft.used_memory]; arrs['mem_fragmentation_ratio'] = [rdata.mem_fragmentation_ratio, lan.soft.mem_fragmentation_ratio]; arrs['total_connections_received'] = [rdata.total_connections_received, lan.soft.total_connections_received]; arrs['total_commands_processed'] = [rdata.total_commands_processed, lan.soft.total_commands_processed]; arrs['instantaneous_ops_per_sec'] = [rdata.instantaneous_ops_per_sec, lan.soft.instantaneous_ops_per_sec]; arrs['keyspace_hits'] = [rdata.keyspace_hits, lan.soft.keyspace_hits]; arrs['keyspace_misses'] = [rdata.keyspace_misses, lan.soft.keyspace_misses]; arrs['hit'] = [hit, lan.soft.db_his]; arrs['latest_fork_usec'] = [rdata.latest_fork_usec, lan.soft.latest_fork_usec]; var con = "
    " + lan.soft.field + "" + lan.soft.curr_val + "" + lan.soft.instructions + "
    "; $(".soft-man-con").html(con); bt.render_table('tab_get_redis_status', arrs, true); }) break; case 'openliMa_set': var loadT = bt.load(); $.post('config?action=get_ols_value', function(rdata) { loadT.close(); var _mlist_data='', tips_i = 0, help_tips=['#Enables GZIP/Brotli compression for both static and dynamic responses.', '#Specifies the level of GZIP compression applied to dynamic content. Ranges from 1 (lowest) to 9 (highest).', '', '#Specifies the maximum number of concurrent connections that the server can accept.
    \ #This includes both plain TCP connections and SSL connections', '#Specifies the maximum number of concurrent SSL connections the server will accept
    \ #Since total concurrent SSL and non-SSL connections cannot exceed the limit specified by “Max Connections”,
    \ #the actual number of concurrent SSL connections allowed must be lower than this limit.', '#Specifies the maximum connection idle time (seconds) allowed during processing one request', '#Specifies the maximum number of requests that can be served through a keep-alive (persistent) session']; for (var i in rdata) { var mlist = {title: '',items: []},list = {}; list.name = i; list.width = '130px'; list.value = rdata[i]; list.type = i=='enableGzipCompress'?'switch':'input'; list.ps_help = help_tips[tips_i]; mlist.items.push(list); mlist.title = i; _mlist_data += bt.render_form_line(mlist).html; tips_i++; } var tabCon = $(".soft-man-con").empty(); tabCon.append('
    ' + _mlist_data + '
    '); var datas = { title: ' ', class: 'openlite_button', items: [{ name: 'btn_fresh', text: lan.public.fresh, type: 'button', callback: function(ldata) { soft.get_tab_contents(key, obj); } }, { name: 'btn_save', text: lan.public.save, type: 'button', width: '62px', callback: function(ldata) { var datal = {}, loadP = bt.load(); delete ldata.btn_fresh; delete ldata.btn_save; ldata['enableGzipCompress']=$("#enableGzipCompress").prop('checked')?1:0; ldata = JSON.stringify(ldata); datal = { array: ldata }; bt.send('set_ols_value', 'config/set_ols_value', datal, function(res) { loadP.close(); soft.get_tab_contents(key, obj); bt.msg(res); }); } } ] } var _form_data = bt.render_form_line(datas); $('.openlite_set').append(_form_data.html); bt.render_clicks(_form_data.clicks); $('.enableGzipCompress_help').css('margin-left','104px'); $(".openlite_set").on("mouseenter", ".bt-ico-ask", function () { var idd = $(this).attr('class').split(" ")[1], tip = $(this).attr('tip'); layer.tips(tip, '.' + idd + '', { tips: [1, '#d4d4d4'], time: 0, area: '300px'}); }); $(".openlite_set").on("mouseleave", ".bt-ico-ask", function () { layer.closeAll('tips'); }); }); break; } }, update_zip_open: function() { $("#update_zip").on("change", function() { var files = $("#update_zip")[0].files; if (files.length == 0) { return; } soft.update_zip(files[0]); $("#update_zip").val('') }); $("#update_zip").click(); }, update_zip: function(file) { var formData = new FormData(); formData.append("plugin_zip", file); $.ajax({ url: "/plugin?action=update_zip", type: "POST", data: formData, processData: false, contentType: false, success: function(data) { if (data.status === false) { layer.msg(data.msg, { icon: 2 }); return; } var loadT = layer.open({ type: 1, area: "500px", title: lan.soft.install_third_party_apps, closeBtn: 2, shift: 5, shadeClose: false, content: '\
    \ \ \
    \
    ' }); }, error: function(responseStr) { layer.msg(lan.soft.upload_fail2, { icon: 2 }); } }); }, input_zip: function (plugin_name,tmp_path,data) { bt.soft.show_speed_window({title:'Installing, this may take a few minutes...',status:true},function(){ $.post('/plugin?action=input_zip', { plugin_name: plugin_name, tmp_path: tmp_path }, function (rdata) { layer.closeAll() if (rdata.status) { soft.get_list(); } setTimeout(function () { layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }) }, 1000); }); }); } }; function soft_td_width_auto() { var thead_width = '', winWidth = $(window).width(); if (winWidth <= 1370 && winWidth > 1280) { thead_width = winWidth / 4; } else if (winWidth <= 1280 && winWidth > 1210) { thead_width = winWidth / 5; } else if (winWidth <= 1210) { thead_width = winWidth / 6; } else { thead_width = winWidth / 3.5; } //$('#softList thead th:eq(2)').width(thead_width); $('#softList tbody tr td:nth-child(8n+2)>span').width(thead_width + 75); } function set_disable_functions(version, data) { bt.soft.php.disable_functions(version, data, function(rdata) { if (rdata.status) { soft.get_tab_contents('set_dis_fun', $(".bgw")); } bt.msg(rdata); }) } var openId = add = null; function AddDeployment(maction) { if (maction == 1) { var pdata = 'title=' + $("input[name='title']").val() + '&dname=' + $("input[name='name']").val() + '&ps=' + $("input[name='ps']").val() + '&version=' + $("input[name='version']").val() + '&rewrite=' + ($("input[name='rewrite']").attr('checked') ? 1 : 0) + '&shell=' + ($("input[name='shell']").attr('checked') ? 1 : 0) + '&php=' + $("input[name='php']").val() + '&md5=' + $("input[name='md5']").val() + '&download=' + $("input[name='download']").val() var loadT = layer.msg('Submitting ', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post('/deployment?action=AddPackage', pdata, function(rdata) { layer.close(loadT); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); if (rdata.status) { GetSrcList(); layer.close(openId); } }); return; } openId = layer.open({ type: 1, skin: 'demo-class', area: '480px', title: '添加源码包', closeBtn: 2, shift: 5, shadeClose: false, content: 'Title:
    \ Identification:
    \ Description:
    \ Version:
    \ Whether to use URL rewrite:
    \ Whether to execute the installation script:
    \ Supported PHP version:
    \ md5:\ Download link:
    \ ' }); } $(".searchInput").keyup(function(e) { if (e.keyCode == 13) { GetSrcList(); } }); function AddSite(codename, title) { var array; var str = ""; var domainlist = ''; var domain = array = $("#mainDomain").val().split("\n"); var Webport = []; var checkDomain = domain[0].split('.'); if (checkDomain.length < 1) { layer.msg('The domain name is not in the correct format. Please re-enter!', { icon: 2 }); return; } for (var i = 1; i < domain.length; i++) { domainlist += '"' + domain[i] + '",'; } Webport = domain[0].split(":")[1]; //主域名端口 if (Webport == undefined) { Webport = "80"; } domainlist = domainlist.substring(0, domainlist.length - 1); //子域名json mainDomain = domain[0].split(':')[0]; domain = '{"domain":"' + domain[0] + '","domainlist":[' + domainlist + '],"count":' + domain.length + '}'; //拼接json var php_version = $("select[name='version']").val(); var loadT = layer.msg('Creating site ', { icon: 16, time: 0, shade: [0.3, "#000"] }) var data = $("#addweb").serialize() + "&port=" + Webport + "&webname=" + domain + '&ftp=false&sql=true&address=localhost&codeing=utf8&version=' + php_version; $.post('/site?action=AddSite', data, function(ret) { layer.close(loadT) if (!ret.siteStatus) { layer.msg(ret.msg, { icon: 5 }); return; } layer.close(add) var sqlData = ''; if (ret.databaseStatus) { sqlData = "

    Database account information

    \

    Database name:" + ret.databaseUser + "

    \

    User:" + ret.databaseUser + "

    \

    Password:" + ret.databasePass + "

    \ " } var pdata = 'dname=' + codename + '&site_name=' + mainDomain + '&php_version=' + php_version; var loadT = layer.msg('
    Submitting
    ', { icon: 16, time: 0, shade: [0.3, "#000"] }); setTimeout(function() { GetSpeed(); }, 2000); $.post('/deployment?action=SetupPackage', pdata, function(rdata) { layer.close(loadT) if (!rdata.status) { layer.msg(rdata.msg, { icon: 5, time: 10000 }); return; } if (rdata.msg.admin_username != '') { sqlData = "

    Successfully deployed, no need to install, please login to modify the default account password.

    \

    User:" + rdata.msg.admin_username + "

    \

    Password:" + rdata.msg.admin_password + "

    \ " } sqlData += "

    Visit site:http://" + mainDomain + rdata.msg.success_url + "

    "; layer.open({ type: 1, area: '600px', title: 'Successfully deployed [' + title + ']', closeBtn: 2, shadeClose: false, content: "
    \
    \
    \ " + sqlData + "\
    \
    ", }); if ($(".success-msg").height() < 150) { $(".success-msg").find("img").css({ "width": "150px", "margin-top": "30px" }); } }); }); } function GetSpeed() { if (!$('.depSpeed')) return; $.get('/deployment?action=GetSpeed', function(speed) { if (speed.status === false) return; if (speed.name == 'Download file') { speed = '

    正在' + speed.name + '

    \
    ' + speed.pre + '%
    \

    ' + ToSize(speed.used) + '/' + ToSize(speed.total) + '' + ToSize(speed.speed) + '/s

    '; $('.depSpeed').prev().hide(); $('.depSpeed').css({ "margin-left": "-37px", "width": "380px" }); $('.depSpeed').parents(".layui-layer").css({ "margin-left": "-100px" }); } else { speed = '

    ' + speed.name + '

    '; $('.depSpeed').prev().show(); $('.depSpeed').removeAttr("style"); $('.depSpeed').parents(".layui-layer").css({ "margin-left": "0" }); } $('.depSpeed').html(speed); setTimeout(function() { GetSpeed(); }, 1000); }); } function onekeyCodeSite(codename, versions, title, enable_functions) { $.post('/site?action=GetPHPVersion', function(rdata) { var php_version = ""; var n = 0; for (var i = rdata.length - 1; i >= 0; i--) { if (versions.indexOf(rdata[i].version) != -1) { php_version += ""; n++; } } if (n == 0) { layer.msg('Missing supported PHP version, please install!', { icon: 5 }); return; } var default_path = bt.get_cookie('sites_path'); if (!default_path) default_path = '/www/wwwroot'; var con = '\
    Domain\
    \
    Fill in a domain name per line, the default is 80 ports
    Pan-analysis add method *.domain.com
    If the additional port format is www.domain.com:88
    \
    \
    \
    Note\
    \
    \
    Document Root\
    \
    \
    Database\
    \ \ \
    \
    \
    Source code\ \ Prepare the source code for your deployment\
    \
    PHP Version\ \ Please select the php version supported by the source program.\
    \
    \ \ \
    \ '; add = layer.open({ type: 1, title: "aaPanel One-Click [" + title + ']', area: '560px', closeBtn: 2, shadeClose: false, content: con }); if (enable_functions.length > 2) { layer.msg("Note: The following functions will be released when deploying this project.:
    " + enable_functions + "
    ", { icon: 7, time: 10000 }); } var placeholder = "
    Fill in a domain name per line, the default is 80 ports
    Pan-analysis add method *.domain.com
    If the additional port format is www.domain.com:88
    "; $(".onekeycodeclose").click(function() { layer.close(add); }); $('#mainDomain').after(placeholder); $(".placeholder").click(function() { $(this).hide(); $('#mainDomain').focus(); }) $('#mainDomain').focus(function() { $(".placeholder").hide(); }); $('#mainDomain').blur(function() { if ($(this).val().length == 0) { $(".placeholder").show(); } }); //FTP账号数据绑定域名 $('#mainDomain').on('input', function() { var defaultPath = bt.get_cookie('sites_path'); if (!defaultPath) defaultPath = '/www/wwwroot'; var array; var res, ress; var str = $(this).val(); var len = str.replace(/[^\x00-\xff]/g, "**").length; array = str.split("\n"); ress = array[0].split(":")[0]; res = ress.replace(new RegExp(/([-.])/g), '_'); if (res.length > 15) res = res.substr(0, 15); if ($("#inputPath").val().substr(0, defaultPath.length) == defaultPath) $("#inputPath").val(defaultPath + '/' + ress); if (!isNaN(res.substr(0, 1))) res = "sql" + res; if (res.length > 15) res = res.substr(0, 15); $("#Wbeizhu").val(ress); $("#datauser").val(res); }) $('#Wbeizhu').on('input', function() { var str = $(this).val(); var len = str.replace(/[^\x00-\xff]/g, "**").length; if (len > 20) { str = str.substring(0, 20); $(this).val(str); layer.msg('Do not exceed 20 characters', { icon: 0 }); } }) //获取当前时间时间戳,截取后6位 var timestamp = new Date().getTime().toString(); var dtpw = timestamp.substring(7); $("#datauser").val("sql" + dtpw); $("#datapassword").val(_getRandomString(10)); }); } //生成n位随机密码 function _getRandomString(len) { len = len || 32; var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; // 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1 var maxPos = $chars.length; var pwd = ''; for (i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; } var score = { total: 1, type: '', data: [], // 获取评论信息 get_score_info: function(obj, callback) { var loadT = layer.msg('
    Getting comment information
    ', { icon: 16, time: 0, shade: [0.3, "#000"] }); bt.send('get_score', 'plugin/get_score', { pid: obj.pid, p: obj.p, limit_num: obj.limit_num }, function(res) { layer.close(loadT); if (res.status === false) { layer.msg(res.msg, { icon: 2 }); return false; } if (callback) callback(res); }); }, render_score_info: function(obj, callback) { var config = { pid: obj.pid }, _this = this; obj.p == undefined ? config.p = 1 : config.p = parseInt(obj.p) obj.limit_num == undefined ? config.limit_num = '' : config.limit_num = obj.limit_num score.get_score_info(config, function(res) { var _split_score = res.split.reverse(), _average_score = (_split_score[4] * 1 + _split_score[3] * 2 + _split_score[2] * 3 + _split_score[1] * 4 + _split_score[0] * 5) / res.total, _data = res.data, _html = ''; _this.total = res.total; $('.comment_user_count').text(obj.count); $('.comment_num').text((res.total !== 0 ? _average_score : 0).toFixed(1)); $('.comment_partake').text(res.total); $('.comment_rate').text(res.total !== 0 ? ((((_split_score[0] + _split_score[1]) / res.total).toFixed(2) * 100) + '%') : '0%'); for (var i = 0; i < 5; i++) { $('.comment_star_group:eq(' + i + ')').find('.comment_progress .comment_progress_bgw').css('width', ((_split_score[i] / res.total).toFixed(2) * 100) + '%') } $('.comment_tab span:eq(1)').find('i').text(_split_score[0] + _split_score[1]); $('.comment_tab span:eq(2)').find('i').text(_split_score[2] + _split_score[3]); $('.comment_tab span:eq(3)').find('i').text(_split_score[4]); for (var j = 0; j < _data.length; j++) { _html += '
    \
    \ \ \ \ \ \ \ \ ' + _data[j].nickname + '\ ' + timeago(_data[j].addtime * 1000) + '\
    \
    ' + (getLength(_data[j].ps) > 65 ? reBytesStr(_data[j].ps, 65) + '... Details' : _data[j].ps) + '
    \
    ' // console.log(getLength(_data[j].ps)>70?reBytesStr(_data[j].ps,70)+' 详情':_data[j].ps); } _this.data = _this.data.concat(_data); if (res.total > 10 && _data.length === 10) { _html += '
    Click for more comments
    ' } $('.comment_content').find('.get_next_page').remove(); $('.comment_content').append(_html); if ($('.comment_content .comment_box').length > 6) { $('.comment_content').addClass('box-shadow'); } else { $('.comment_content').removeClass('box-shadow'); } if (callback) callback(res); }); }, // 设置评论信息 set_score_info: function(obj, callback) { var loadT = layer.msg('
    Submitting comment
    ', { icon: 16, time: 0, shade: [0.3, "#000"] }); bt.send('set_score', 'plugin/set_score', { pid: obj.pid, num: obj.num, ps: obj.ps }, function(res) { layer.close(loadT); if (res.status === false) { layer.msg(res.msg, { icon: 2 }); return false; } if (callback) callback(res); }); }, open_score_view: function(_pid, _name, _count) { layer.open({ type: 1, title: '[ ' + _name + '] Score', area: ['550px', '350px'], closeBtn: 2, shadeClose: false, content: '
    \
    \
    --
    \
      \
    • user count --
    • \
    •  -- people participated in the score
    • \
    • -- Favorable rate
    • \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    \
    \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    \
    \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    \
    \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    \
    \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    \
    \
    \
    \
    \
    \
    \
    \ All evaluation\ Praise -- \ Average -- \ Bad review -- \
    \
    \
    \
    \
    \ \ \ \ \ \
    \
    Recommended: 5 points
    \ \ Can also enter 60 words\
    \
    \ Participate in the score\
    \
    ', success: function(index, layero) { score.data = []; score.render_score_info({ pid: _pid, count: _count }, function() { $('.score_info_view').show(); }); score.score_icon_time = null; $('.score_icon_group span').hover(function() { var _active = $(this).hasClass('active'); // if($(this).prevAll().length == 0 && $(this).nextAll('.active').length == 0 && _active){ // $(this).removeClass('active').nextAll().removeClass('active') // $('.score_icon_group_tips').html('选择以上图标选择评分等级1-5'); // $('.score_icon_group').attr('data-icon',0) // }else{ // $(this).addClass('active').nextAll().removeClass('active'); // $(this).prevAll().addClass('active'); // $('.score_icon_group').attr('data-icon',$(this).prevAll().length +1) // var _title = $(this).attr('title'); // $('.score_icon_group_tips').text(_title); // } }); $('.score_icon_group span').click(function() { var _active = $(this).hasClass('active'); if ($(this).prevAll().length == 0 && $(this).nextAll('.active').length == 0 && _active) { $('.edit_view').addClass('active'); $(this).removeClass('active').nextAll().removeClass('active') $('.score_icon_group_tips').html('Click on the selection icon to rate 1-5 stars'); $('.score_icon_group').attr('data-icon', 0) } else { $('.edit_view').removeClass('active'); $(this).addClass('active').nextAll().removeClass('active'); $(this).prevAll().addClass('active'); $('.score_icon_group').attr('data-icon', $(this).prevAll().length + 1) var _title = $(this).attr('title'); $('.score_icon_group_tips').text(_title); } }); $('.comment_tab span').click(function(e) { var _num = $(this).attr('data-num'); $('.comment_content').removeClass('box-shadow'); $(this).addClass('active').siblings().removeClass('active'); $('.comment_content').html(''); score.data = [] score.type = _num; score.render_score_info({ pid: _pid, limit_num: _num, count: _count }); }); $('.comment_content').on('click', '.get_next_page', function() { var _next_page = ($('.comment_content .comment_box').length / 10) + 1; score.render_score_info({ pid: _pid, limit_num: score.type, p: _next_page, count: _count }); }); $('.comment_content').on('click', '.comment_box', function() { if (!$(this).hasClass('get_next_page')) { var _index = $(this).attr('data-index'); layer.open({ type: 1, title: false, area: ['350px', '200px'], closeBtn: 2, shadeClose: false, content: '
    ' + $(this).html() + '
    ', success: function(index, layers) { $('.score_details .comment_box_content').html(score.data[_index]['ps']); } }); } }); $('.edit_view').click(function() { if ($('.edit_view').hasClass('active')) { // layer.msg('请选择评分等级',{icon:2}); $('.score_icon_group_tips').css('color', 'red'); setTimeout(function() { $('.score_icon_group_tips').removeAttr('style') }, 1000); return false } var _num = parseInt($('.score_icon_group').attr('data-icon')), _ps = $('.score_input').val(); if (_num == 0) { layer.msg('Rating level cannot be empty', { icon: 2 }); return false; } if (120 - getLength(_ps) < 0) { layer.msg('Evaluation information cannot exceed 60 words', { icon: 2 }); return false; } score.set_score_info({ pid: _pid, num: _num, ps: _ps == '' ? 'User did not make any evaluation' : _ps }, function(res) { layer.msg(res.msg, { icon: 1 }); score.render_score_info({ pid: _pid, limit_num: score.type, count: _count }); soft.flush_cache(); layer.close(index); }); return false layer.open({ type: 1, title: 'Add review', area: ['400px', '350px'], closeBtn: 2, shadeClose: false, btn: ['Confirm', 'Cancel'], content: '
    \
    \ \ \ \ \ \
    \
    (Click on the icon above to select rating 1-5)
    \ \ Can also enter 60 words\
    ', success: function() { $('.score_icon_group span').click(function() { var _active = $(this).hasClass('active'); if ($(this).prevAll().length == 0 && $(this).nextAll('.active').length == 0 && _active) { $(this).removeClass('active').nextAll().removeClass('active') $('.score_icon_group_tips').html('(Click on the icon above to select rating 1-5)'); $('.score_icon_group').attr('data-icon', 0) } else { $(this).addClass('active').nextAll().removeClass('active'); $(this).prevAll().addClass('active'); $('.score_icon_group').attr('data-icon', $(this).prevAll().length + 1) var _title = $(this).attr('title'); $('.score_icon_group_tips').text(_title); } }); $('.score_input').on('keydown keyup focus click', function() { var _val = $('.score_input').val(), _size = 120 - getLength(_val); if (_size > 0) { $('.score_input_tips i').css('color', _size > 20 ? '#666' : 'red').text(parseInt(_size / 2)); $('.score_input').attr('style', ''); } else { $('.score_input_tips i').text(0) $('.score_input').css({ 'outline-color': 'red', 'border': '1px solid red' }); } }); }, yes: function(index, layero) { var _num = parseInt($('.score_icon_group').attr('data-icon')), _ps = $('.score_input').val(); if (_num == 0) { layer.msg('Rating level cannot be empty', { icon: 2 }); return false; } if (120 - getLength(_ps) < 0) { layer.msg('Evaluation information cannot exceed 60 words', { icon: 2 }); return false; } score.set_score_info({ pid: _pid, num: _num, ps: _ps == '' ? 'User did not make any evaluation' : _ps }, function(res) { layer.msg(res.msg, { icon: 1 }); score.render_score_info({ pid: _pid, limit_num: score.type, count: _count }); soft.flush_cache(); layer.close(index); }); } }); }); } }) } } function timeago(dateTimeStamp) { //dateTimeStamp是一个时间毫秒,注意时间戳是秒的形式,在这个毫秒的基础上除以1000,就是十位数的时间戳。13位数的都是时间毫秒。 if (dateTimeStamp.toString().length < 10) dateTimeStamp = dateTimeStamp * 1000 var minute = 1000 * 60, hour = minute * 60, day = hour * 24, week = day * 7, halfamonth = day * 15, month = day * 30, now = new Date().getTime(), //获取当前时间毫秒 diffValue = now - dateTimeStamp; //时间差 if (diffValue <= 0) { return 'Just a moment ago'; } var minC = diffValue / minute, //计算时间差的分,时,天,周,月 hourC = diffValue / hour, dayC = diffValue / day, weekC = diffValue / week, monthC = diffValue / month, result = 'Just a moment ago'; if (monthC >= 1 && monthC <= 3) { result = " " + parseInt(monthC) + "month ago" } else if (weekC >= 1 && weekC <= 3) { result = " " + parseInt(weekC) + "week ago" } else if (dayC >= 1 && dayC <= 6) { result = " " + parseInt(dayC) + "day ago" } else if (hourC >= 1 && hourC <= 23) { result = " " + parseInt(hourC) + "hour ago" } else if (minC >= 1 && minC <= 59) { result = " " + parseInt(minC) + "minute ago" } else if (diffValue >= 0 && diffValue <= minute) { result = "Just a moment ago" } else { var datetime = new Date(); datetime.setTime(dateTimeStamp); var Nyear = datetime.getFullYear(), Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1, Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(), Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours(), Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(), Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(), result = Nmonth + "-" + Ndate } if (!result) result = 'Just a moment ago' return ((result == undefined || result == 'undefined') ? 'Just a moment ago' : result); } // 规则转码 function escapeHTML(val) { val = "" + val; return val.replace(//g, ">").replace(/"/g, '"').replace(/'/g, "‘").replace(/\(/g, "(").replace(/\</g, "<").replace(/\>/g, ">").replace(/`/g, "`").replace(/=/g, "="); } function getLength(val) { var str = new String(val); var bytesCount = 0; for (var i = 0, n = str.length; i < n; i++) { var c = str.charCodeAt(i); if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) { bytesCount += 1; } else { bytesCount += 2; } } return bytesCount; } function reBytesStr(str, len) { if ((!str && typeof(str) != 'undefined')) { return ''; } var num = 0; var str1 = str; var str = ''; for (var i = 0, lens = str1.length; i < lens; i++) { num += ((str1.charCodeAt(i) > 255) ? 2 : 1); if (num > len) { break; } else { str = str1.substring(0, i + 1); } } return str; }