connector.php 1.9 KB

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