connector.minimal.php-dist 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. error_reporting(0); // Set E_ALL for debuging
  3. // // To Enable(true) handling of PostScript files by ImageMagick
  4. // // It is disabled by default as a countermeasure
  5. // // of Ghostscript multiple -dSAFER sandbox bypass vulnerabilities
  6. // // see https://www.kb.cert.org/vuls/id/332928
  7. // define('ELFINDER_IMAGEMAGICK_PS', true);
  8. // ===============================================
  9. // load composer autoload before load elFinder autoload If you need composer
  10. //require './vendor/autoload.php';
  11. // elFinder autoload
  12. require './autoload.php';
  13. // ===============================================
  14. // Enable FTP connector netmount
  15. elFinder::$netDrivers['ftp'] = 'FTP';
  16. // ===============================================
  17. // // Required for Dropbox network mount
  18. // // Installation by composer
  19. // // `composer require kunalvarma05/dropbox-php-sdk`
  20. // // Enable network mount
  21. // elFinder::$netDrivers['dropbox2'] = 'Dropbox2';
  22. // // Dropbox2 Netmount driver need next two settings. You can get at https://www.dropbox.com/developers/apps
  23. // // AND reuire regist redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=dropbox2&host=1"
  24. // define('ELFINDER_DROPBOX_APPKEY', '');
  25. // define('ELFINDER_DROPBOX_APPSECRET', '');
  26. // ===============================================
  27. // // Required for Google Drive network mount
  28. // // Installation by composer
  29. // // `composer require google/apiclient:^2.0`
  30. // // Enable network mount
  31. // elFinder::$netDrivers['googledrive'] = 'GoogleDrive';
  32. // // GoogleDrive Netmount driver need next two settings. You can get at https://console.developers.google.com
  33. // // AND reuire regist redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=googledrive&host=1"
  34. // define('ELFINDER_GOOGLEDRIVE_CLIENTID', '');
  35. // define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', '');
  36. // // Required case of without composer
  37. // define('ELFINDER_GOOGLEDRIVE_GOOGLEAPICLIENT', '/path/to/google-api-php-client/vendor/autoload.php');
  38. // ===============================================
  39. // // Required for Google Drive network mount with Flysystem
  40. // // Installation by composer
  41. // // `composer require nao-pon/flysystem-google-drive:~1.1 nao-pon/elfinder-flysystem-driver-ext`
  42. // // Enable network mount
  43. // elFinder::$netDrivers['googledrive'] = 'FlysystemGoogleDriveNetmount';
  44. // // GoogleDrive Netmount driver need next two settings. You can get at https://console.developers.google.com
  45. // // AND reuire regist redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=googledrive&host=1"
  46. // define('ELFINDER_GOOGLEDRIVE_CLIENTID', '');
  47. // define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', '');
  48. // ===============================================
  49. // // Required for One Drive network mount
  50. // // * cURL PHP extension required
  51. // // * HTTP server PATH_INFO supports required
  52. // // Enable network mount
  53. // elFinder::$netDrivers['onedrive'] = 'OneDrive';
  54. // // GoogleDrive Netmount driver need next two settings. You can get at https://dev.onedrive.com
  55. // // AND reuire regist redirect url to "YOUR_CONNECTOR_URL/netmount/onedrive/1"
  56. // define('ELFINDER_ONEDRIVE_CLIENTID', '');
  57. // define('ELFINDER_ONEDRIVE_CLIENTSECRET', '');
  58. // ===============================================
  59. // // Required for Box network mount
  60. // // * cURL PHP extension required
  61. // // Enable network mount
  62. // elFinder::$netDrivers['box'] = 'Box';
  63. // // Box Netmount driver need next two settings. You can get at https://developer.box.com
  64. // // AND reuire regist redirect url to "YOUR_CONNECTOR_URL"
  65. // define('ELFINDER_BOX_CLIENTID', '');
  66. // define('ELFINDER_BOX_CLIENTSECRET', '');
  67. // ===============================================
  68. // // Zoho Office Editor APIKey
  69. // // https://www.zoho.com/docs/help/office-apis.html
  70. // define('ELFINDER_ZOHO_OFFICE_APIKEY', '');
  71. // ===============================================
  72. // // Online converter (online-convert.com) APIKey
  73. // // https://apiv2.online-convert.com/docs/getting_started/api_key.html
  74. // define('ELFINDER_ONLINE_CONVERT_APIKEY', '');
  75. // ===============================================
  76. // // Zip Archive editor
  77. // // Installation by composer
  78. // // `composer require nao-pon/elfinder-flysystem-ziparchive-netmount`
  79. // define('ELFINDER_DISABLE_ZIPEDITOR', false); // set `true` to disable zip editor
  80. // ===============================================
  81. /**
  82. * Simple function to demonstrate how to control file access using "accessControl" callback.
  83. * This method will disable accessing files/folders starting from '.' (dot)
  84. *
  85. * @param string $attr attribute name (read|write|locked|hidden)
  86. * @param string $path absolute file path
  87. * @param string $data value of volume option `accessControlData`
  88. * @param object $volume elFinder volume driver object
  89. * @param bool|null $isDir path is directory (true: directory, false: file, null: unknown)
  90. * @param string $relpath file path relative to volume root directory started with directory separator
  91. * @return bool|null
  92. **/
  93. function access($attr, $path, $data, $volume, $isDir, $relpath) {
  94. $basename = basename($path);
  95. return $basename[0] === '.' // if file/folder begins with '.' (dot)
  96. && strlen($relpath) !== 1 // but with out volume root
  97. ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
  98. : null; // else elFinder decide it itself
  99. }
  100. // Documentation for connector options:
  101. // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
  102. $opts = array(
  103. // 'debug' => true,
  104. 'roots' => array(
  105. // Items volume
  106. array(
  107. 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
  108. 'path' => '../files/', // path to files (REQUIRED)
  109. 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
  110. 'trashHash' => 't1_Lw', // elFinder's hash of trash folder
  111. 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
  112. 'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
  113. 'uploadAllow' => array('image/x-ms-bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon', 'text/plain'), // Mimetype `image` and `text/plain` allowed to upload
  114. 'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
  115. 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
  116. ),
  117. // Trash volume
  118. array(
  119. 'id' => '1',
  120. 'driver' => 'Trash',
  121. 'path' => '../files/.trash/',
  122. 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.trash/.tmb/',
  123. 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
  124. 'uploadDeny' => array('all'), // Recomend the same settings as the original volume that uses the trash
  125. 'uploadAllow' => array('image/x-ms-bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon', 'text/plain'), // Same as above
  126. 'uploadOrder' => array('deny', 'allow'), // Same as above
  127. 'accessControl' => 'access', // Same as above
  128. )
  129. )
  130. );
  131. // run elFinder
  132. $connector = new elFinderConnector(new elFinder($opts));
  133. $connector->run();