权限设置修复
This commit is contained in:
parent
11ea1e2e1f
commit
35a7c2d96f
|
|
@ -24,7 +24,7 @@ class config_api:
|
|||
# pureftp 自启动 done
|
||||
# sphinx 自启动 done
|
||||
# 修复rsync自启动问题
|
||||
__version = '0.5.6'
|
||||
__version = '0.6.0'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -70,6 +70,30 @@ class files_api:
|
|||
data = self.getAccess(filename)
|
||||
return public.getJson(data)
|
||||
|
||||
def setFileAccessApi(self):
|
||||
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True,'开发机不设置!')
|
||||
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
user = request.form.get('user', '').encode('utf-8')
|
||||
access = request.form.get('access', '755')
|
||||
sall = '-R'
|
||||
try:
|
||||
if not self.checkDir(filename):
|
||||
return public.returnJson(False, '请不要花样作死')
|
||||
|
||||
if not os.path.exists(filename):
|
||||
return public.returnJson(False,'指定文件不存在!')
|
||||
|
||||
os.system('chmod ' + sall + ' ' + access + " '" + filename + "'")
|
||||
os.system('chown ' + sall + ' ' + user + ':' + user + " '" + filename + "'")
|
||||
msg = public.getInfo('设置[{1}]权限为[{2}]所有者为[{3}]', (filename,access,user,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True,'设置成功!')
|
||||
except:
|
||||
return public.returnJson(False,'设置失败!')
|
||||
|
||||
def getDirSizeApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
tmp = self.getDirSize(path)
|
||||
|
|
|
|||
|
|
@ -1295,55 +1295,55 @@ function setChmod(action,fileName){
|
|||
var chmod = $("#access").val();
|
||||
var chown = $("#chown").val();
|
||||
var data = 'filename='+ encodeURIComponent(fileName)+'&user='+chown+'&access='+chmod;
|
||||
var loadT = layer.msg(lan.public.config,{icon:16,time:0,shade: [0.3, '#000']});
|
||||
$.post('files?action=SetFileAccess',data,function(rdata){
|
||||
var loadT = layer.msg('正在设置...',{icon:16,time:0,shade: [0.3, '#000']});
|
||||
$.post('files/set_file_access',data,function(rdata){
|
||||
layer.close(loadT);
|
||||
if(rdata.status) layer.closeAll();
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||
var path = $("#DirPathPlace input").val();
|
||||
getFiles(path)
|
||||
});
|
||||
},'json');
|
||||
return;
|
||||
}
|
||||
|
||||
var toExec = fileName == lan.files.all?'Batch(3,1)':'setChmod(1,\''+fileName+'\')';
|
||||
$.post('/files/file_access','filename='+encodeURIComponent(fileName),function(rdata){
|
||||
console.log(rdata);
|
||||
// console.log(rdata);
|
||||
layer.open({
|
||||
type:1,
|
||||
closeBtn: 2,
|
||||
title: lan.files.set_auth + '['+fileName+']',
|
||||
title: '设置权限['+fileName+']',
|
||||
area: '400px',
|
||||
shadeClose:false,
|
||||
content:'<div class="setchmod bt-form ptb15 pb70">\
|
||||
<fieldset>\
|
||||
<legend>'+lan.files.file_own+'</legend>\
|
||||
<p><input type="checkbox" id="owner_r" />'+lan.files.file_read+'</p>\
|
||||
<p><input type="checkbox" id="owner_w" />'+lan.files.file_write+'</p>\
|
||||
<p><input type="checkbox" id="owner_x" />'+lan.files.file_exec+'</p>\
|
||||
<legend>所有者</legend>\
|
||||
<p><input type="checkbox" id="owner_r" />读取</p>\
|
||||
<p><input type="checkbox" id="owner_w" />写入</p>\
|
||||
<p><input type="checkbox" id="owner_x" />执行</p>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<legend>'+lan.files.file_group+'</legend>\
|
||||
<p><input type="checkbox" id="group_r" />'+lan.files.file_read+'</p>\
|
||||
<p><input type="checkbox" id="group_w" />'+lan.files.file_write+'</p>\
|
||||
<p><input type="checkbox" id="group_x" />'+lan.files.file_exec+'</p>\
|
||||
<legend>用户组</legend>\
|
||||
<p><input type="checkbox" id="group_r" />读取</p>\
|
||||
<p><input type="checkbox" id="group_w" />写入</p>\
|
||||
<p><input type="checkbox" id="group_x" />执行</p>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<legend>'+lan.files.file_public+'</legend>\
|
||||
<p><input type="checkbox" id="public_r" />'+lan.files.file_read+'</p>\
|
||||
<p><input type="checkbox" id="public_w" />'+lan.files.file_write+'</p>\
|
||||
<p><input type="checkbox" id="public_x" />'+lan.files.file_exec+'</p>\
|
||||
<legend>公共</legend>\
|
||||
<p><input type="checkbox" id="public_r" />读取</p>\
|
||||
<p><input type="checkbox" id="public_w" />写入</p>\
|
||||
<p><input type="checkbox" id="public_x" />执行</p>\
|
||||
</fieldset>\
|
||||
<div class="setchmodnum"><input class="bt-input-text" type="text" id="access" maxlength="3" value="'+rdata.chmod+'">'+lan.files.file_menu_auth+',\
|
||||
<span>'+lan.files.file_own+'\
|
||||
<div class="setchmodnum"><input class="bt-input-text" type="text" id="access" maxlength="3" value="'+rdata.chmod+'">权限,\
|
||||
<span>所有者\
|
||||
<select id="chown" class="bt-input-text">\
|
||||
<option value="www" '+(rdata.chown=='www'?'selected="selected"':'')+'>www</option>\
|
||||
<option value="mysql" '+(rdata.chown=='mysql'?'selected="selected"':'')+'>mysql</option>\
|
||||
<option value="root" '+(rdata.chown=='root'?'selected="selected"':'')+'>root</option>\
|
||||
</select></span></div>\
|
||||
<div class="bt-form-submit-btn">\
|
||||
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>\
|
||||
<button type="button" class="btn btn-success btn-sm btn-title" onclick="'+toExec+'" >'+lan.public.ok+'</button>\
|
||||
<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">关闭</button>\
|
||||
<button type="button" class="btn btn-success btn-sm btn-title" onclick="'+toExec+'" >确定</button>\
|
||||
</div>\
|
||||
</div>'
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue