Skip to content

Commit

Permalink
优化运行目录设置功能
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Jul 3, 2019
1 parent 0387bd8 commit fb7a77a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
11 changes: 10 additions & 1 deletion BTPanel/static/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,21 +782,28 @@ var site = {
bt.site.get_dir_userini(web.id, path, function (rdata) {
loading.close();
var dirs = [];
for (var n = 0; n < rdata.runPath.dirs.length; n++) dirs.push({ title: rdata.runPath.dirs[n], value: rdata.runPath.dirs[n] });
var is_n = false;
for (var n = 0; n < rdata.runPath.dirs.length; n++) {
dirs.push({ title: rdata.runPath.dirs[n], value: rdata.runPath.dirs[n] });
if (rdata.runPath.runPath === rdata.runPath.dirs[n]) is_n = true;
}
if (!is_n) dirs.push({ title: rdata.runPath.runPath, value: rdata.runPath.runPath });
var datas = [
{
title: '', items: [
{
name: 'userini', type: 'checkbox', text: '防跨站攻击(open_basedir)', value: rdata.userini, callback: function (sdata) {
bt.site.set_dir_userini(path, function (ret) {
if (ret.status) site.reload(2)
layer.msg(ret.msg, { icon: ret.status ? 1 : 2 });
})
}
},
{
name: 'logs', type: 'checkbox', text: '写访问日志', value: rdata.logs, callback: function (sdata) {
bt.site.set_logs_status(web.id, function (ret) {
if (ret.status) site.reload(2)
layer.msg(ret.msg, { icon: ret.status ? 1 : 2 });
})
}
}
Expand All @@ -809,6 +816,7 @@ var site = {
name: 'btn_site_path', type: 'button', text: '保存', callback: function (pdata) {
bt.site.set_site_path(web.id, pdata.path, function (ret) {
if (ret.status) site.reload(2)
layer.msg(ret.msg, { icon: ret.status ? 1 : 2 });
})
}
}
Expand All @@ -821,6 +829,7 @@ var site = {
name: 'btn_run_path', type: 'button', text: '保存', callback: function (pdata) {
bt.site.set_site_runpath(web.id, pdata.dirName, function (ret) {
if (ret.status) site.reload(2)
layer.msg(ret.msg, { icon: ret.status ? 1 : 2 });
})
}
}
Expand Down
24 changes: 12 additions & 12 deletions class/panelSite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2277,20 +2277,20 @@ def GetDirUserINI(self,get):
#清除多余user.ini
def DelUserInI(self,path,up = 0):
useriniPath = path + '/.user.ini'
public.ExecShell('chattr -i ' + useriniPath);
public.ExecShell('rm -f ' + useriniPath);
if os.path.exists(useriniPath):
public.ExecShell('chattr -i ' + useriniPath);
os.remove(useriniPath)

for p1 in os.listdir(path):
try:
npath = path + '/' + p1;
if os.path.isdir(npath):
if up < 2: self.DelUserInI(npath, up + 1);
else:
continue;
useriniPath = npath + '/.user.ini';
if not os.path.exists(useriniPath): continue;
npath = path + '/' + p1;
if not os.path.isdir(npath): continue
useriniPath = npath + '/.user.ini';
if os.path.exists(useriniPath):
public.ExecShell('chattr -i ' + useriniPath);
public.ExecShell('rm -f ' + useriniPath);
except: continue;
os.remove(useriniPath)

if up < 3: self.DelUserInI(npath, up + 1);

return True;


Expand Down

0 comments on commit fb7a77a

Please sign in to comment.