Commit 14f8a638 authored by Medicean's avatar Medicean

FileManager Add File chmod(php)

parent f04c6f66
...@@ -38,7 +38,7 @@ module.exports = () => ({ ...@@ -38,7 +38,7 @@ module.exports = () => ({
upload_file: { upload_file: {
_: 'U', _: 'U',
'z1': '#{path}', 'z1': '#{path}',
'z2': '#{hex::content}' 'z2': '#{buffer::content}'
}, },
rename: { rename: {
......
...@@ -62,6 +62,13 @@ module.exports = (arg1, arg2, arg3) => ({ ...@@ -62,6 +62,13 @@ module.exports = (arg1, arg2, arg3) => ({
[arg2]: "#{base64::time}" [arg2]: "#{base64::time}"
}, },
chmod: {
_:
`$m=get_magic_quotes_gpc();$FN=base64_decode(m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]);$mode=base64_decode(m?stripslashes($_POST["${arg2}"]):$_POST["${arg2}"]);echo(chmod($FN,octdec($mode))?"1":"0");`,
[arg1]: "#{base64::path}",
[arg2]: "#{base64::mode}"
},
mkdir: { mkdir: {
_: _:
`$m=get_magic_quotes_gpc();$f=base64_decode($m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]);echo(mkdir($f)?"1":"0");`, `$m=get_magic_quotes_gpc();$f=base64_decode($m?stripslashes($_POST["${arg1}"]):$_POST["${arg1}"]);echo(mkdir($f)?"1":"0");`,
......
...@@ -219,6 +219,12 @@ module.exports = { ...@@ -219,6 +219,12 @@ module.exports = {
success: (path) => antSword.noxss(`Retime file success!\n${path}`), success: (path) => antSword.noxss(`Retime file success!\n${path}`),
error: (path, err) => antSword.noxss(`Retime file [${path}] failed!${err ? '\n' + err : ''}`) error: (path, err) => antSword.noxss(`Retime file [${path}] failed!${err ? '\n' + err : ''}`)
}, },
chmod: {
title: 'Chmod File',
check: 'Input should be octal numbers, eg: 0644',
success: (path) => antSword.noxss(`Chmod file success!\n${path}`),
error: (path, err) => antSword.noxss(`Chmod file [${path}] failed!${err ? '\n' + err : ''}`)
},
wget: { wget: {
title: 'Wget File', title: 'Wget File',
check: 'URL is not correct!', check: 'URL is not correct!',
...@@ -303,6 +309,7 @@ module.exports = { ...@@ -303,6 +309,7 @@ module.exports = {
upload: 'Upload', upload: 'Upload',
download: 'Download', download: 'Download',
modify: 'Modify the file time', modify: 'Modify the file time',
chmod: 'Chmod',
copy: { copy: {
title: 'Copy', title: 'Copy',
warning: (id) => antSword.noxss(`Already add to clipboard!\n${id}`), warning: (id) => antSword.noxss(`Already add to clipboard!\n${id}`),
......
...@@ -220,6 +220,12 @@ module.exports = { ...@@ -220,6 +220,12 @@ module.exports = {
success: (path) => antSword.noxss(`更改文件时间成功!\n${path}`), success: (path) => antSword.noxss(`更改文件时间成功!\n${path}`),
error: (path, err) => antSword.noxss(`更改文件时间 [${path}] 失败!${err ? '\n' + err : ''}`) error: (path, err) => antSword.noxss(`更改文件时间 [${path}] 失败!${err ? '\n' + err : ''}`)
}, },
chmod: {
title: '更改权限',
check: "输入应为八进制数表示的权限, eg: 0644",
success: (path) => antSword.noxss(`更改文件权限成功!\n${path}`),
error: (path, err) => antSword.noxss(`更改文件权限 [${path}] 失败!${err ? '\n' + err : ''}`)
},
wget: { wget: {
title: 'Wget下载文件', title: 'Wget下载文件',
check: 'URL地址不正确!', check: 'URL地址不正确!',
...@@ -304,6 +310,7 @@ module.exports = { ...@@ -304,6 +310,7 @@ module.exports = {
upload: '上传文件', upload: '上传文件',
download: '下载文件', download: '下载文件',
modify: '更改文件时间', modify: '更改文件时间',
chmod: '更改权限',
copy: { copy: {
title: '复制文件', title: '复制文件',
warning: (id) => antSword.noxss(`已经添加到剪贴板!\n${id}`), warning: (id) => antSword.noxss(`已经添加到剪贴板!\n${id}`),
......
...@@ -323,6 +323,9 @@ class Files { ...@@ -323,6 +323,9 @@ class Files {
// manager.retimeFile(id, this.rowsAr[id]['cells'][2].innerText); // manager.retimeFile(id, this.rowsAr[id]['cells'][2].innerText);
manager.retimeFile(id, this.getRowAttribute(_ids[0], 'data')[2]); manager.retimeFile(id, this.getRowAttribute(_ids[0], 'data')[2]);
} }, } },
{ text: LANG['grid']['contextmenu']['chmod'], icon: 'fa fa-users', disabled: !id || ids.length > 1, action: () => {
manager.chmodFile(id, this.getRowAttribute(_ids[0], 'data')[4]);
} },
{ divider: true }, { divider: true },
{ text: LANG['grid']['contextmenu']['create']['title'], icon: 'fa fa-plus-circle', subMenu: [ { text: LANG['grid']['contextmenu']['create']['title'], icon: 'fa fa-plus-circle', subMenu: [
{ text: LANG['grid']['contextmenu']['create']['folder'], icon: 'fa fa-folder-o', action: manager.createFolder.bind(manager) }, { text: LANG['grid']['contextmenu']['create']['folder'], icon: 'fa fa-folder-o', action: manager.createFolder.bind(manager) },
......
...@@ -473,6 +473,43 @@ class FileManager { ...@@ -473,6 +473,43 @@ class FileManager {
}) })
} }
// 设置文件和目录权限
chmodFile(name, oldmod) {
layer.prompt({
value: oldmod,
title: `<i class="fa fa-users"></i> ${LANG['chmod']['title']} (${antSword.noxss(name)})`,
}, (value, i, e) => {
if(!value.match(/^[0-7]{4}$/)){
toastr.error(LANG['chmod']['check'], LANG_T['error']);
return
}
this.files.cell.progressOn();
let path = this.path;
if (this.isWin) {
path = path.replace(/\//g, '\\')
}
// http request
this.core.request(
this.core.filemanager.chmod({
path: path + name,
mode: value
})
).then((res) => {
let ret = res['text'];
this.files.cell.progressOff();
if (ret === '1') {
this.files.refreshPath();
toastr.success(LANG['chmod']['success'](name), LANG_T['success']);
}else{
toastr.error(LANG['chmod']['error'](name, ret === '0' ? false : ret), LANG_T['error']);
}
}).catch((err) => {
toastr.error(LANG['chmod']['error'](name, err), LANG_T['error']);
});
layer.close(i);
});
}
// 预览文件(图片、视频) // 预览文件(图片、视频)
previewFile(name, size) { previewFile(name, size) {
let that = this; let that = this;
...@@ -490,7 +527,7 @@ class FileManager { ...@@ -490,7 +527,7 @@ class FileManager {
let down_size = 0; let down_size = 0;
this.core.download( this.core.download(
savepath savepath
,this.core.filemanager.read_file({path: remote_path}) ,this.core.filemanager.download_file({path: remote_path})
, (_size) => { , (_size) => {
down_size += _size; down_size += _size;
let down_progress = parseInt(parseFloat(down_size / size).toFixed(2) * 100); let down_progress = parseInt(parseFloat(down_size / size).toFixed(2) * 100);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment