connector.minimal.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. exit;
  3. error_reporting(0); // Set E_ALL for debuging
  4. include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
  5. include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
  6. include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
  7. include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';
  8. // Required for MySQL storage connector
  9. // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeMySQL.class.php';
  10. // Required for FTP connector support
  11. // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeFTP.class.php';
  12. /**
  13. * Simple function to demonstrate how to control file access using "accessControl" callback.
  14. * This method will disable accessing files/folders starting from '.' (dot)
  15. *
  16. * @param string $attr attribute name (read|write|locked|hidden)
  17. * @param string $path file path relative to volume root directory started with directory separator
  18. * @return bool|null
  19. **/
  20. function access($attr, $path, $data, $volume) {
  21. return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot)
  22. ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
  23. : null; // else elFinder decide it itself
  24. }
  25. // Documentation for connector options:
  26. // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
  27. $opts = array(
  28. // 'debug' => true,
  29. 'roots' => array(
  30. array(
  31. 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
  32. 'path' => '../files/', // path to files (REQUIRED)
  33. 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
  34. 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
  35. )
  36. )
  37. );
  38. // run elFinder
  39. $connector = new elFinderConnector(new elFinder($opts));
  40. $connector->run();