Skip to content

Commit

Permalink
6.9.33
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Aug 30, 2019
1 parent d72d20c commit f1b5935
Show file tree
Hide file tree
Showing 13 changed files with 780 additions and 26 deletions.
16 changes: 15 additions & 1 deletion BTPanel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def send_authenticated():
def home():
comReturn = comm.local()
if comReturn: return comReturn
args = get_input()
licenes = 'data/licenes.pl'
if 'license' in args:
public.writeFile(licenes,'True')

data = {}
data[public.to_string([112, 100])] = get_pd()
data['siteCount'] = public.M('sites').count()
Expand All @@ -134,6 +139,7 @@ def home():
data['lan'] = public.GetLan('index')
data['724'] = public.format_date("%m%d") == '0724'
public.auto_backup_panel()
if not os.path.exists(licenes): return render_template( 'license.html')
return render_template( 'index.html',data = data)

@app.route('/close',methods=method_get)
Expand Down Expand Up @@ -216,7 +222,15 @@ def site(pdata = None):
import panelSite
siteObject = panelSite.panelSite()

defs = ('GetRedirectFile','SaveRedirectFile','DeleteRedirect','GetRedirectList','CreateRedirect','ModifyRedirect','GetSiteLogs','GetSiteDomains','GetSecurity','SetSecurity','ProxyCache','CloseToHttps','HttpToHttps','SetEdate','SetRewriteTel','GetCheckSafe','CheckSafe','GetDefaultSite','SetDefaultSite','CloseTomcat','SetTomcat','apacheAddPort','AddSite','GetPHPVersion','SetPHPVersion','DeleteSite','AddDomain','DelDomain','GetDirBinding','AddDirBinding','GetDirRewrite','DelDirBinding','get_site_types','add_site_type','remove_site_type','modify_site_type_name','set_site_type','UpdateRulelist','SetSiteRunPath','GetSiteRunPath','SetPath','SetIndex','GetIndex','GetDirUserINI','SetDirUserINI','GetRewriteList','SetSSL','SetSSLConf','CreateLet','CloseSSLConf','GetSSL','SiteStart','SiteStop','Set301Status','Get301Status','CloseLimitNet','SetLimitNet','GetLimitNet','RemoveProxy','GetProxyList','GetProxyDetals','CreateProxy','ModifyProxy','GetProxyFile','SaveProxyFile','ToBackup','DelBackup','GetSitePHPVersion','logsOpen','GetLogsStatus','CloseHasPwd','SetHasPwd','GetHasPwd','GetDnsApi','SetDnsApi')
defs = ('GetRedirectFile','SaveRedirectFile','DeleteRedirect','GetRedirectList','CreateRedirect','ModifyRedirect','set_dir_auth','delete_dir_auth','get_dir_auth','modify_dir_auth_pass',
'GetSiteLogs','GetSiteDomains','GetSecurity','SetSecurity','ProxyCache','CloseToHttps','HttpToHttps','SetEdate',
'SetRewriteTel','GetCheckSafe','CheckSafe','GetDefaultSite','SetDefaultSite','CloseTomcat','SetTomcat','apacheAddPort',
'AddSite','GetPHPVersion','SetPHPVersion','DeleteSite','AddDomain','DelDomain','GetDirBinding','AddDirBinding','GetDirRewrite',
'DelDirBinding','get_site_types','add_site_type','remove_site_type','modify_site_type_name','set_site_type','UpdateRulelist',
'SetSiteRunPath','GetSiteRunPath','SetPath','SetIndex','GetIndex','GetDirUserINI','SetDirUserINI','GetRewriteList','SetSSL',
'SetSSLConf','CreateLet','CloseSSLConf','GetSSL','SiteStart','SiteStop','Set301Status','Get301Status','CloseLimitNet','SetLimitNet',
'GetLimitNet','RemoveProxy','GetProxyList','GetProxyDetals','CreateProxy','ModifyProxy','GetProxyFile','SaveProxyFile','ToBackup',
'DelBackup','GetSitePHPVersion','logsOpen','GetLogsStatus','CloseHasPwd','SetHasPwd','GetHasPwd','GetDnsApi','SetDnsApi')
return publicObject(siteObject,defs,None,pdata);

@app.route('/ftp',methods=method_all)
Expand Down
34 changes: 24 additions & 10 deletions BTPanel/static/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ var aceEditor = {
$('.menu-themes ul').html(_html);
$('.menu-themes ul li').click(function(){
var _theme = $(this).attr('data-value');
$(this).addClass('active').append(_icon).siblings().removeClass('active').find('.icon').remove();
$(this).addClass('active').append(_icon).siblings().removeClass('active').find('.icon').remove();
var _fontSize = JSON.parse(getCookie('aceEditor')).fontSize.match(/([0-9]*)px/)[1],
_data = JSON.stringify({"fontSize": _fontSize +"px","theme":_theme});
for(var item in _this.editor){
Expand Down Expand Up @@ -872,13 +872,27 @@ function openEditorView(type,path){
$('#ace_conter').addClass(_rdata.theme);
set_edit_file();
});
}else{
var aceConfig = JSON.parse(getCookie('aceEditor'));
aceEditor.fontSize = aceConfig.fontSize;
aceEditor.editorTheme = aceConfig.theme;
$('.ace_editors').css('fontSize',aceConfig.fontSize);
$('#ace_conter').addClass(aceConfig.theme);
set_edit_file();
} else {
var aceConfig = JSON.parse(getCookie('aceEditor'));
if (aceConfig.theme === undefined) {
aceEditor.getEditorConfig(function (res) {
var _rdata = (typeof res == "string") ? JSON.parse(res) : res;
if (typeof res != "string") res = JSON.stringify(res);
setCookie('aceEditor', res);
var aceConfig = JSON.parse(getCookie('aceEditor'));
aceEditor.fontSize = aceConfig.fontSize;
aceEditor.editorTheme = aceConfig.theme;
$('.ace_editors').css('fontSize', aceConfig.fontSize);
$('#ace_conter').addClass(aceConfig.theme);
set_edit_file();
});
} else {
aceEditor.fontSize = aceConfig.fontSize;
aceEditor.editorTheme = aceConfig.theme;
$('.ace_editors').css('fontSize', aceConfig.fontSize);
$('#ace_conter').addClass(aceConfig.theme);
set_edit_file();
}
}
},
cancel:function(){
Expand Down Expand Up @@ -2630,13 +2644,13 @@ function web_shell() {
}, 500);
}
});

/*
if (socket) {
socket.emit('connect_event', '');
interval = setInterval(function () {
socket.emit('connect_event', '');
}, 1000);
}
}*/

term.on('data', function (data) {
pdata_socket['data'] = data;
Expand Down
32 changes: 31 additions & 1 deletion BTPanel/static/js/public_backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4865,7 +4865,37 @@ bt.site = {
bt.send('SetDefaultSite','site/SetDefaultSite',{name:name},function(rdata){
loading.close();
if(callback) callback(rdata);
})
})
},
get_dir_auth:function(id,callback){
var loading = bt.load();
bt.send('get_dir_auth','site/get_dir_auth',{id:id},function(rdata){
loading.close();
if(callback) callback(rdata);
})
},
create_dir_guard:function(data,callback){
var loading = bt.load();
bt.send('set_dir_auth','site/set_dir_auth',{id:data.id,name:data.name,site_dir:data.site_dir,username:data.username,password:data.password},function(rdata){
loading.close();
if(callback) callback(rdata);
})
},
edit_dir_account:function(data,callback){
var loading = bt.load();
bt.send('modify_dir_auth_pass','site/modify_dir_auth_pass',{id:data.id,name:data.name,username:data.username,password:data.password},function(rdata){
loading.close();
if(callback) callback(rdata);
})
},
delete_dir_guard:function(id,data,callback){
var loading = bt.load();
bt.show_confirm('删除['+ data +']',"你确定要删除目录保护吗",function(){
bt.send('delete_dir_auth','site/delete_dir_auth',{id:id,name:data},function(rdata){
loading.close();
if(callback) callback(rdata);
})
})
}
}

Expand Down
120 changes: 119 additions & 1 deletion BTPanel/static/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,50 @@ var site = {
})
})
},
set_dirguard: function(web){
String.prototype.myReplace = function (f, e) {//吧f替换成e
var reg = new RegExp(f, "g"); //创建正则RegExp对象
return this.replace(reg, e);
}
bt.site.get_dir_auth(web.id,function(res) {
var datas = {
items: [{ name: 'add_dir_guard',text:'添加目录保护',type: 'button',callback: function(data){site.edit.template_Dir(web.id,true)}}]
}
var form_line = bt.render_form_line(datas);
$('#webedit-con').append(form_line.html);
bt.render_clicks(form_line.clicks);
$('#webedit-con').addClass('divtable').append('<table id="dir_guard" class="table table-hover"></table>');
setTimeout(function() {
var data = [];
var _tab = bt.render({
table: '#dir_guard',
columns: [
{
field: 'name', title: '名称', template: function(item) {
return '<span style="width:60px;" title="'+ item.name +'">'+ item.name +'</span>'
}
},
{
field: 'site_dir', title: '保护的目录', template: function(item) {
return '<span style="width:60px;" title="'+ item.site_dir +'">'+ item.site_dir +'</span>'
}
},
{
field: 'dname', title: '操作', align: 'right', templet: function (item) {
var dirName = item.name
item = JSON.stringify(item).myReplace('"', '\'');
var conter = '<a class="btlink" onclick="site.edit.template_Dir(\'' + web.id + '\',false,' + item + ')" href="javascript:;">编辑</a> ' +
'| <a class="btlink" onclick="bt.site.delete_dir_guard(\'' + web.id + '\',\'' + dirName + '\',function(rdata){if(rdata.status)site.reload()})" href="javascript:;">删除</a>';
return conter
}
}
],
data:res[web.name] || []
})

})
});
},
limit_network: function (web) {
bt.site.get_limitnet(web.id, function (rdata) {
var limits = [
Expand Down Expand Up @@ -1938,6 +1982,79 @@ var site = {
}, 100);
});

},
template_Dir: function(id,type,obj){
if(type){
obj = {"name":"","sitedir": "", "username":"","password":""};
}else{
obj = {"name":obj.name,"sitedir": obj.site_dir, "username":"","password":""};
}
var form_directory = bt.open({
type: 1,
skin: 'demo-class',
area: '550px',
title: type ? '添加目录保护' : '修改目录目录',
closeBtn: 2,
shift: 5,
shadeClose: false,
content: "<form id='form_dir' class='divtable pd15' style='padding: 40px 0 90px 60px'>" +
"<div class='line'>" +
"<span class='tname'>名称</span>" +
"<div class='info-r ml0'><input name='dir_name' class='bt-input-text mr10' type='text' style='width:270px' value='" + obj.name + "'>" +
"</div></div>" +
"<div class='line'>" +
"<span class='tname'>保护的目录</span>" +
"<div class='info-r ml0'><input name='dir_sitedir' placeholder='输入需要保护的目录,如:/text/' class='bt-input-text mr10' type='text' style='width:270px' value='" + obj.sitedir + "'>" +
"</div></div>" +
"<div class='line'>" +
"<span class='tname'>用户名</span>" +
"<div class='info-r ml0'><input name='dir_username' AUTOCOMPLETE='off' class='bt-input-text mr10' type='text' style='width:270px' value='" + obj.username + "'>" +
"</div></div>" +
"<div class='line'>" +
"<span class='tname'>密码</span>" +
"<div class='info-r ml0'><input name='dir_password' AUTOCOMPLETE='off' class='bt-input-text mr10' type='password' style='width:270px' value='" + obj.password + "'>" +
"</div></div>"+
"<ul class='help-info-text c7 plr20'>"+
"<li>目录设置保护后,访问时需要输入账号密码才能访问</li>"+
"<li>例如我设置了保护目录 /test/ ,那我访问 http://aaa.com/test/ 是就要输入账号密码才能访问</li>"+
"</ul>"+
"<div class='bt-form-submit-btn'><button type='button' class='btn btn-sm btn-danger btn-colse-guard'>关闭</button><button type='button' class='btn btn-sm btn-success btn-submit-guard'>" + (type ? '提交' : '保存') + "</button></div></form>"
});
$('.btn-colse-guard').click(function () {
form_directory.close();
});
$('.btn-submit-guard').click(function() {
var guardData = {};
guardData['id'] = id;
guardData['name'] = $('input[name="dir_name"]').val();
guardData['site_dir'] = $('input[name="dir_sitedir"]').val();
guardData['username'] = $('input[name="dir_username"]').val();
guardData['password'] = $('input[name="dir_password"]').val();
if(type){
bt.site.create_dir_guard(guardData, function (rdata) {
if (rdata.status) {
form_directory.close();
site.reload()
}
bt.msg(rdata);
});
}else{
bt.site.edit_dir_account(guardData, function (rdata) {
if (rdata.status) {
form_directory.close();
site.reload()
}
bt.msg(rdata);
});
}
});
setTimeout(function(){
if(!type){
$('input[name="dir_name"]').attr('disabled', 'disabled');
$('input[name="dir_sitedir"]').attr('disabled', 'disabled');
}
},500)

},
set_301_old:function(web){
bt.site.get_domains(web.id,function(rdata){
Expand Down Expand Up @@ -2532,7 +2649,7 @@ var site = {
var item = $(obj).parents('tr').data('item');
bt.open({
type: 1,
area: ['700px', '650px'],
area: ['700px', '690px'],
title: lan.site.website_change + '[' + item.name + '] -- ' + lan.site.addtime + '[' + item.addtime + ']',
closeBtn: 2,
shift: 0,
Expand All @@ -2543,6 +2660,7 @@ var site = {
{ title: '域名管理', callback: site.edit.set_domains },
{ title: '子目录绑定', callback: site.edit.set_dirbind },
{ title: '网站目录', callback: site.edit.set_dirpath },
{ title: '目录保护', callback: site.edit.set_dirguard },
{ title: '流量限制', callback: site.edit.limit_network },
{ title: '伪静态', callback: site.edit.get_rewrite_list },
{ title: '默认文档', callback: site.edit.set_default_index },
Expand Down
Loading

0 comments on commit f1b5935

Please sign in to comment.