PageRenderTime 25ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/dada/installer-disabled/templates/rich_filemanager-filemanager-php.tmpl

http://github.com/justingit/dada-mail
Go Template | 119 lines | 98 code | 21 blank | 0 comment | 0 complexity | ab79a861d2aebef0c10b67cbe5e8f1cc MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. ini_set('session.save_path',realpath('<!-- tmpl_var i_rich_filemanager_session_dir -->'));
  3. /**
  4. * Entry point for PHP connector, put your customizations here.
  5. *
  6. * @license MIT License
  7. * @author Pavel Solomienko <https://github.com/servocoder/>
  8. * @copyright Authors
  9. */
  10. // only for debug
  11. // error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
  12. // ini_set('display_errors', '1');
  13. require 'vendor/autoload.php';
  14. // fix display non-latin chars correctly
  15. // https://github.com/servocoder/RichFilemanager/issues/7
  16. setlocale(LC_CTYPE, 'en_US.UTF-8');
  17. // fix for undefined timezone in php.ini
  18. // https://github.com/servocoder/RichFilemanager/issues/43
  19. if(!ini_get('date.timezone')) {
  20. date_default_timezone_set('GMT');
  21. }
  22. // This function is called for every server connection. It must return true.
  23. //
  24. // Implement this function to authenticate the user, for example to check a
  25. // password login, or restrict client IP address.
  26. //
  27. // This function only authorizes the user to connect and/or load the initial page.
  28. // Authorization for individual files or dirs is provided by the two functions below.
  29. //
  30. // NOTE: If this function returns false, the user will simply see an error. It
  31. // probably makes more sense to redirect the user to a login page instead.
  32. //
  33. // NOTE: If using session variables, the session must be started first (session_start()).
  34. function fm_authenticate()
  35. {
  36. session_start();
  37. return isset($_SESSION['rfm_authenticated']) && $_SESSION['rfm_session_id'] == $_COOKIE["dadalogin"];
  38. }
  39. // This function is called before any filesystem read operation, where
  40. // $filepath is the file or directory being read. It must return true,
  41. // otherwise the read operation will be denied.
  42. //
  43. // Implement this function to do custom individual-file permission checks, such as
  44. // user/group authorization from a database, or session variables, or any other custom logic.
  45. //
  46. // Note that this is not the only permissions check that must pass. The read operation
  47. // must also pass:
  48. // * Filesystem permissions (if any), e.g. POSIX `rwx` permissions on Linux
  49. // * The $filepath must be allowed according to config['patterns'] and config['extensions']
  50. //
  51. function fm_has_read_permission($filepath)
  52. {
  53. // Customize this code as desired.
  54. return true;
  55. }
  56. // This function is called before any filesystem write operation, where
  57. // $filepath is the file or directory being written to. It must return true,
  58. // otherwise the write operation will be denied.
  59. //
  60. // Implement this function to do custom individual-file permission checks, such as
  61. // user/group authorization from a database, or session variables, or any other custom logic.
  62. //
  63. // Note that this is not the only permissions check that must pass. The write operation
  64. // must also pass:
  65. // * Filesystem permissions (if any), e.g. POSIX `rwx` permissions on Linux
  66. // * The $filepath must be allowed according to config['patterns'] and config['extensions']
  67. // * config['read_only'] must be set to false, otherwise all writes are disabled
  68. //
  69. function fm_has_write_permission($filepath)
  70. {
  71. // Customize this code as desired.
  72. return true;
  73. }
  74. $config = [];
  75. // example to override the default config
  76. //$config = [
  77. // 'security' => [
  78. // 'readOnly' => true,
  79. // 'extensions' => [
  80. // 'policy' => 'ALLOW_LIST',
  81. // 'restrictions' => [
  82. // 'jpg',
  83. // 'jpe',
  84. // 'jpeg',
  85. // 'gif',
  86. // 'png',
  87. // ],
  88. // ],
  89. // ],
  90. //];
  91. $app = new \RFM\Application();
  92. $local = new \RFM\Repository\Local\Storage($config);
  93. // example to setup files root folder
  94. //$local->setRoot('userfiles', true);
  95. $app->setStorage($local);
  96. // set application API
  97. $app->api = new RFM\Api\LocalApi();
  98. $app->run();