Skip to content

Commit

Permalink
修复编辑器没有自动获取焦点的问题,调整自动处理open_basedir配置
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Oct 10, 2020
1 parent 17a98ee commit b8561fb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 16 deletions.
25 changes: 9 additions & 16 deletions BTPanel/static/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ var aceEditor = {
e.stopPropagation();
e.preventDefault();
});

// 禁用目录选择(文件目录)
$('.ace_catalogue').bind("selectstart",function(e){
var omitformtags = ["input", "textarea"];
Expand Down Expand Up @@ -677,7 +678,7 @@ var aceEditor = {
$(this).siblings('div').show();
$(this).parent().find('.search_input_view,.search_input_title').remove();
$(this).removeAttr('style').attr({'title':'搜索内容'}).find('.glyphicon').removeClass('glyphicon-remove').addClass('glyphicon-search').next().text("搜索");
$('.ace_catalogue_list').removeAttr('style')
$('.ace_catalogue_list').removeAttr('style');
$('.ace_dir_tools').removeAttr('style');
_this.refresh_config = {
el:$('.cd-accordion-menu')[0],
Expand Down Expand Up @@ -1416,6 +1417,7 @@ var aceEditor = {
};
var ACE = this.editor[obj.id];
ACE.ace.moveCursorTo(0, 0); //设置鼠标焦点
ACE.ace.focus();//设置焦点
ACE.ace.resize(); //设置自适应
ACE.ace.commands.addCommand({
name: '保存文件',
Expand Down Expand Up @@ -2058,11 +2060,11 @@ function ChangePath(d) {
function GetDiskList(b) {
var d = "";
var a = "";
var c = "path=" + b + "&disk=True";
var c = "path=" + b + "&disk=True&showRow=500";
$.post("/files?action=GetDir", c, function(h) {
if(h.DISK != undefined) {
for(var f = 0; f < h.DISK.length; f++) {
a += "<dd onclick=\"GetDiskList('" + h.DISK[f].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;" + h.DISK[f].path + "</dd>"
a += "<dd onclick=\"GetDiskList('" + h.DISK[f].path + "')\"><span class='glyphicon glyphicon-hdd'></span>&nbsp;<span>" + h.DISK[f].path + "</span></div></dd>"
}
$("#changecomlist").html(a)
}
Expand Down Expand Up @@ -2091,7 +2093,7 @@ function GetDiskList(b) {
e = e.substring(0, 10) + "..."
}
}
d += "<tr><td title='" + g[0] + "'><span class='glyphicon glyphicon-file'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td></td></tr>"
d += "<tr><td title='" + g[0] + "'><span class='glyphicon glyphicon-file'></span><span>" + e + "</span></td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td></td></tr>"
}
}
$(".default").hide();
Expand Down Expand Up @@ -3686,7 +3688,7 @@ var Term = {
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.localhost_login_form();
Term.close();
return;
}
Expand Down Expand Up @@ -3853,7 +3855,7 @@ var Term = {
Term.term.focus();
});
},
localhost_login_form:function(result){
localhost_login_form:function(){
var template = '<div class="localhost-form-shade"><div class="localhost-form-view bt-form-2x"><div class="localhost-form-title"><i class="localhost-form_tip"></i><span style="vertical-align: middle;">无法自动认证,请填写本地服务器的登录信息!</span></div>\
<div class="line input_group">\
<span class="tname">服务器IP</span>\
Expand Down Expand Up @@ -3936,16 +3938,7 @@ var Term = {
break;
}
});
form.ps = '本地服务器';

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);
}
}
form.ps = '本地服务器';
var loadT = bt.load('正在添加服务器信息,请稍后...');
bt.send('create_host','xterm/create_host',form,function(res){
loadT.close();
Expand Down
44 changes: 44 additions & 0 deletions class/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,50 @@ def control_init():
#update_py37()
files_set_mode()
set_pma_access()
set_open_basedir()


#设置防跨站配置 for Nginx
def set_open_basedir():
import re
open_basedir_path = '/www/server/panel/vhost/open_basedir/nginx'
if not os.path.exists(open_basedir_path):
os.makedirs(open_basedir_path,384)

site_list = public.M('sites').field('id,name,path').select()
for site_info in site_list:
config_file = '/www/server/panel/vhost/nginx/{}.conf'.format(site_info['name'])
open_basedir_file = "/".join(
(open_basedir_path,'{}.conf'.format(site_info['name']))
)
if not os.path.exists(config_file): continue
if not os.path.exists(open_basedir_file):
public.writeFile(open_basedir_file,'')
config_body = public.readFile(config_file)
if config_body.find(open_basedir_path) == -1:
config_body = config_body.replace("include enable-php","include {};\n\t\tinclude enable-php".format(open_basedir_file))
public.writeFile(config_file,config_body)

root_path = re.findall(r"root\s+(.+);",config_body)[0]
if not root_path: continue
userini_file = root_path + '/.user.ini'
if not os.path.exists(userini_file):
public.writeFile(open_basedir_file,'')
continue
userini_body = public.readFile(userini_file)
if not userini_body: continue
if userini_body.find('open_basedir') == -1:
public.writeFile(open_basedir_file,'')
continue

open_basedir_conf = re.findall("open_basedir=(.+)",userini_body)
if not open_basedir_conf: continue
open_basedir_conf = open_basedir_conf[0]
open_basedir_body = '''set $bt_safe_dir "open_basedir";
set $bt_safe_open "{}";'''.format(open_basedir_conf)
public.writeFile(open_basedir_file,open_basedir_body)
break



#设置文件权限
Expand Down

0 comments on commit b8561fb

Please sign in to comment.