灰儿 发表于 2022-9-13 15:07:45

Veno-File-Manager (VFM4)云盘让游客可显示根目录下文件方法

Veno-File-Manager (VFM4)云盘让游客和用户可显示根目录下文件方法

1.修改前端显示UI代码,让游客和登录用户能列表显示根目录(starting_dir)中的文件
打开根目录 vfm-admin/template/list-files.php 文件,把条件判断语句改为如下格式:if ($gateKeeper->isAccessAllowed()){
if( $location->editAllowed() || $location->readAllowed()) {
    if ($gateKeeper->isAllowed('view_enable')) {
    列表显示文件代码 }
显示上传文件功能区块代码 }
}加是一条 $cleangetDir === $cleanstartdir(当前目录是否等于开始目录) 条件判定语句,修改后代码如下:
$getDir = $location->getDir(true, false, false, 0, false);
$cleangetDir = rtrim(ltrim($getDir, './'), '/');
$startdir = './'.$setUp->getConfig('starting_dir');
$cleanstartdir = rtrim(ltrim($startdir, './'), '/');

if ($gateKeeper->isAccessAllowed()){
if( $location->editAllowed() || $location->readAllowed() || $cleangetDir === $cleanstartdir) {
    if ($gateKeeper->isAllowed('view_enable'))
{
    列表显示文件代码 }
显示上传文件功能区块代码 }
}
2.修改ajax请求代码,使游客和登录用户能获取到根目录(starting_dir)中的文件
打开根目录/vfm-admin/ajax/get-files.php文件,查找如下代码:
if ($gateKeeper->isAccessAllowed() && $location->editAllowed('../../') && $gateKeeper->isAllowed('view_enable'))
{
$fullpath = $location->getFullPath();
...
}加是一条 $cleanlocdir === $cleanstartdir(当前目录是否等于开始目录) 条件判定语句,修改后代码如下:$cleanlocdir = rtrim(ltrim($locdir, './'), '/');
$startdir = './'.$setUp->getConfig('starting_dir');
$cleanstartdir = rtrim(ltrim($startdir, './'), '/');

if ($cleanlocdir === $cleanstartdir || $gateKeeper->isAccessAllowed() && $location->readAllowed('../../')|| $location->editAllowed('../../')&& $gateKeeper->isAllowed('view_enable'))
{
$fullpath = $location->getFullPath();
...
}
相关文件:
根目录/vfm-admin/template/list-files.php前端显示文件UI代码
根目录/vfm-admin/ajax/get-files.php   获取文件

页: [1]
查看完整版本: Veno-File-Manager (VFM4)云盘让游客可显示根目录下文件方法