elFinder connector.php -> Internet Explorer 中的路径

elFinder connector.php -> path in Internet Explorer

我在 connector.php 中动态设置路径,它在除 Internet Explorer 之外的所有浏览器中都能正常工作。这是我的 connector.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,则根目录将设置为 [=16] =](该目录仅比所需目录高一级),因此用户可以看到他不应访问的文件夹。

关于为什么会发生这种情况有什么想法吗?

P.S。我唯一的理论是,也许 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>

P.S.S > 我刚刚确认 IE 没有发送 mypath 变量。

有没有人有什么想法?

更新:2016 年 9 月 2 日

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

如果是任何浏览器(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');            
});

如果你强制 requestTypepost 那么它在所有浏览器中总是 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');            
});

如果你强制 requestTypepost 那么它在所有浏览器中总是 post,所以你不必担心检查浏览器是否发布或获取。