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

时间:2016-02-08 17:09:46

标签: javascript php jquery ajax elfinder

我在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中,则根目录设置为/files/ (目录只需要一个级别的目录),因此用户可以看到他不应该访问的文件夹。

有关为何发生这种情况的任何想法?

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&gt;我刚刚确认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');            
});

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

1 个答案:

答案 0 :(得分:0)

$().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,所以您不必担心检查浏览器是否发布或获取。