<?php
include("../../../conf/preferences.php");
session_name(SYS_APP_SESSNAME);
session_start();
include("../../../conf/langs/".$langs[$_SESSION['userlang']][0]."/MAIN.php");
include("../../../conf/connections.php");
include("../../../phplib/auth.php");
require_once("../../../phplib/utils.php");
require_once("../../../phplib/phpmailer/class.phpmailer.php");
require_once("../../../core/plugins.php");

error_reporting(0); 

include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';


/**
 * Simple function to demonstrate how to control file access using "accessControl" callback.
 * This method will disable accessing files/folders starting from  '.' (dot)
 *
 * @param  string  $attr  attribute name (read|write|locked|hidden)
 * @param  string  $path  file path relative to volume root directory started with directory separator
 * @return bool|null
 **/
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
}

if($_GET['rootfolder']!=''){
	$temp=trim($_GET['rootfolder'],"/");
	$rf1=$temp."/";
	$rf2=$temp."/";
}
$opts = array(
	// 'debug' => true,
	'roots' => array(
		array(
			'driver'        => 'LocalFileSystem',   // driver for accessing file system (REQUIRED)
			'path'          => '../../../../'.$rf1,         // path to files (REQUIRED)
			'URL'			=> BASE_PATH.$rf2,
			'accessControl' => 'access',			// disable and hide dot starting files (OPTIONAL)
			'mimeDetect' => 'internal'
		)
	)
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
