elFinder 连接器.php Internet Explorer 中的 -> 路径

elFinder connector.php -> path in Internet Explorer

本文关键字:路径 中的 连接器 php Internet Explorer elFinder      更新时间:2023-09-26

我在连接器中动态设置路径.php它在所有浏览器中都正常工作,除了Internet Explorer。这是我的连接器.php代码:

function access($attr, $path, $data, $volume) {
    return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
        ? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
        :  null;                                    // else elFinder decide it itself
}

// Documentation for connector options:
// https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
$opts = array(
    'debug' => true,
    'roots' => array(
        array(
            'driver'        => 'LocalFileSystem',          
            'path'          => '../../pages/path/to/files/'.($_GET['mypath']).'/', 
            'URL'           => '../../pages/path/to/files/'.($_GET['mypath']).'/', 
            'uploadDeny'    => array('all'),               
            'uploadAllow'   => array('image', 'text/plain'),
            'uploadOrder'   => array('deny', 'allow'),      
            'accessControl' => 'access'
        )
    )
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();

基本上发生的事情是,如果您使用任何浏览器(IE除外(,则根目录将正确设置为$_GET['mypath'],但是如果您在IE中,则根目录设置为/files/(该目录仅比所需目录高一级(,因此用户可以看到他不应该访问的文件夹。

关于为什么会发生这种情况的任何想法?

附言我唯一的理论是,也许IE JavaScript引擎发送了不正确的mypath变量?

elFinder代码如下:

<script type="text/javascript" charset="utf-8">
    $().ready(function() {
        var elf = $('#elfinder').elfinder({
            // lang: 'ru',             
            url : 'libraries/elFinder/connector.php', 
            rememberLastDir : false,
            useBrowserHistory : false,
            customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
        }).elfinder('instance');            
    });
</script>

页面的实际来源如下所示:

<script type="text/javascript" charset="utf-8">
    $().ready(function() {
        var elf = $('#elfinder').elfinder({
            // lang: 'ru',             
            url : 'libraries/elFinder/connector.php', 
            rememberLastDir : false,
            useBrowserHistory : false,
            customData : {mypath : "mypath_folder"}
        }).elfinder('instance');            
    });
</script>

附言>我刚刚确认IE不会发送mypath变量。

有人有什么想法吗?

更新日期: 09/02/16

今天经过进一步调查,我发现了这个脚本的一个非常奇怪的行为:

如果是任何浏览器(IE 除外(,那么$_GET['mypath']正常工作,但在 IE 中没有设置$_GET['mypath'],但是,如果是 IE,则设置$_POST['mypath']而不是$_GET['mypath'],但是,在所有其他浏览器中没有设置$_POST['mypath']

我想避免检查浏览器是否是IE系列,然后使用$_POST,如果有任何其他浏览器,则$_GET

有人有什么建议吗?

答:

$().ready(function() {
    var elf = $('#elfinder').elfinder({
        // lang: 'ru',             
        url : 'libraries/elFinder/connector.php',
        requestType : 'post',
        rememberLastDir : false,
        useBrowserHistory : false,
        customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
    }).elfinder('instance');            
});

如果您强制requestType post,那么它将始终post在所有浏览器中,因此您不必担心检查浏览器是否发布或获取。

$().ready(function() {
    var elf = $('#elfinder').elfinder({
        // lang: 'ru',             
        url : 'libraries/elFinder/connector.php',
        requestType : 'post',
        rememberLastDir : false,
        useBrowserHistory : false,
        customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
    }).elfinder('instance');            
});

如果您强制requestType post,那么它将始终在所有浏览器中post,因此您不必担心检查浏览器是否发布或获取。