File indexing completed on 2024-12-22 05:35:33

0001 <?php
0002 
0003 error_reporting(0); // Set E_ALL for debuging
0004 
0005 include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
0006 include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
0007 include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
0008 include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';
0009 // Required for MySQL storage connector
0010 // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeMySQL.class.php';
0011 // Required for FTP connector support
0012 // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeFTP.class.php';
0013 
0014 
0015 /**
0016  * Simple function to demonstrate how to control file access using "accessControl" callback.
0017  * This method will disable accessing files/folders starting from  '.' (dot)
0018  *
0019  * @param  string  $attr  attribute name (read|write|locked|hidden)
0020  * @param  string  $path  file path relative to volume root directory started with directory separator
0021  * @return bool|null
0022  **/
0023 function access($attr, $path, $data, $volume) {
0024   return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
0025     ? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
0026     :  null;                                    // else elFinder decide it itself
0027 }
0028 
0029 $opts = array(
0030   // 'debug' => true,
0031   'roots' => array(
0032     array(
0033       'driver'        => 'LocalFileSystem',   // driver for accessing file system (REQUIRED)
0034       'path'          => $_SERVER['DOCUMENT_ROOT'].'/partials',         // path to files (REQUIRED)
0035       'URL'           => 'http://'.$_SERVER['HTTP_HOST'].'/partials/', // URL to files (REQUIRED)
0036       'accessControl' => 'access'             // disable and hide dot starting files (OPTIONAL)
0037     )
0038   )
0039 );
0040 
0041 // run elFinder
0042 $connector = new elFinderConnector(new elFinder($opts));
0043 $connector->run();
0044