autoload.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. define('ELFINDER_PHP_ROOT_PATH', dirname(__FILE__));
  3. function elFinderAutoloader($name) {
  4. $map = array(
  5. 'elFinder' => 'elFinder.class.php',
  6. 'elFinderConnector' => 'elFinderConnector.class.php',
  7. 'elFinderEditor' => 'editors/editor.php',
  8. 'elFinderLibGdBmp' => 'libs/GdBmp.php',
  9. 'elFinderPlugin' => 'elFinderPlugin.php',
  10. 'elFinderPluginAutoResize' => 'plugins/AutoResize/plugin.php',
  11. 'elFinderPluginAutoRotate' => 'plugins/AutoRotate/plugin.php',
  12. 'elFinderPluginNormalizer' => 'plugins/Normalizer/plugin.php',
  13. 'elFinderPluginSanitizer' => 'plugins/Sanitizer/plugin.php',
  14. 'elFinderPluginWatermark' => 'plugins/Watermark/plugin.php',
  15. 'elFinderSession' => 'elFinderSession.php',
  16. 'elFinderSessionInterface' => 'elFinderSessionInterface.php',
  17. 'elFinderVolumeDriver' => 'elFinderVolumeDriver.class.php',
  18. 'elFinderVolumeDropbox2' => 'elFinderVolumeDropbox2.class.php',
  19. 'elFinderVolumeFTP' => 'elFinderVolumeFTP.class.php',
  20. 'elFinderVolumeFlysystemGoogleDriveCache' => 'elFinderFlysystemGoogleDriveNetmount.php',
  21. 'elFinderVolumeFlysystemGoogleDriveNetmount' => 'elFinderFlysystemGoogleDriveNetmount.php',
  22. 'elFinderVolumeGoogleDrive' => 'elFinderVolumeGoogleDrive.class.php',
  23. 'elFinderVolumeGroup' => 'elFinderVolumeGroup.class.php',
  24. 'elFinderVolumeLocalFileSystem' => 'elFinderVolumeLocalFileSystem.class.php',
  25. 'elFinderVolumeMySQL' => 'elFinderVolumeMySQL.class.php',
  26. 'elFinderVolumeTrash' => 'elFinderVolumeTrash.class.php',
  27. );
  28. if (isset($map[$name])) {
  29. return include_once(ELFINDER_PHP_ROOT_PATH . '/' . $map[$name]);
  30. }
  31. $prefix = substr($name, 0, 14);
  32. if (substr($prefix, 0, 8) === 'elFinder') {
  33. if ($prefix === 'elFinderVolume') {
  34. $file = ELFINDER_PHP_ROOT_PATH . '/' . $name . '.class.php';
  35. return (is_file($file) && include_once($file));
  36. } else if ($prefix === 'elFinderPlugin') {
  37. $file = ELFINDER_PHP_ROOT_PATH . '/plugins/' . substr($name, 14) . '/plugin.php';
  38. return (is_file($file) && include_once($file));
  39. } else if ($prefix === 'elFinderEditor') {
  40. $file = ELFINDER_PHP_ROOT_PATH . '/editors/' . substr($name, 14) . '/editor.php';
  41. return (is_file($file) && include_once($file));
  42. }
  43. }
  44. return false;
  45. }
  46. if (version_compare(PHP_VERSION, '5.3', '<')) {
  47. spl_autoload_register('elFinderAutoloader');
  48. } else {
  49. spl_autoload_register('elFinderAutoloader', true, true);
  50. }