configuration.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. $dist_config = require __DIR__.'/configuration_sample.php';
  3. $dist_config['public_path'] = '/fm/';
  4. $dist_config['frontend_config']['app_name'] = 'File Manager - Hestia Control Panel';
  5. $dist_config['frontend_config']['logo'] = '../images/logo.svg';
  6. $dist_config['frontend_config']['editable'] = ['.txt', '.css', '.js', '.ts', '.html', '.php', '.py',
  7. '.yml', '.xml', '.md', '.log', '.csv', '.conf', '.config', '.ini', '.scss', '.sh', '.env', '.example', '.htaccess'];
  8. $dist_config['frontend_config']['guest_redirection'] = '/login/' ;
  9. $dist_config['frontend_config']['upload_max_size'] = 1024 * 1024 * 1024;
  10. $dist_config['services']['Filegator\Services\Storage\Filesystem']['config']['adapter'] = function () {
  11. if (isset($_SESSION['user'])) {
  12. $v_user = $_SESSION['user'];
  13. }
  14. if (isset($_SESSION['look']) && $_SESSION['look'] != 'admin' && $v_user === 'admin') {
  15. $v_user = $_SESSION['look'];
  16. }
  17. # Create filemanager sftp key if missing and trash it after 30 min
  18. if (! file_exists('/home/'.basename($v_user).'/.ssh/hst-filemanager-key')) {
  19. exec ("sudo /usr/local/hestia/bin/v-add-user-sftp-key " . escapeshellarg(basename($v_user)) . " 30", $output, $return_var);
  20. }
  21. if ( !isset($_SESSION['SFTP_PORT']) ) {
  22. if( preg_match('/^\s*Port\s+(\d+)$/im', file_get_contents('/etc/ssh/sshd_config'), $matches) ) {
  23. $_SESSION['SFTP_PORT'] = $matches[1] ?? 22;
  24. } else {
  25. $_SESSION['SFTP_PORT'] = 22;
  26. }
  27. }
  28. return new \League\Flysystem\Sftp\SftpAdapter([
  29. 'host' => '127.0.0.1',
  30. 'port' => intval($_SESSION['SFTP_PORT']),
  31. 'username' => basename($v_user),
  32. 'privateKey' => '/home/'.basename($v_user).'/.ssh/hst-filemanager-key',
  33. 'root' => '/',
  34. 'timeout' => 10,
  35. ]);
  36. };
  37. $dist_config['services']['Filegator\Services\Auth\AuthInterface'] = [
  38. 'handler' => '\Filegator\Services\Auth\Adapters\HestiaAuth',
  39. 'config' => [
  40. 'permissions' => ['read', 'write', 'upload', 'download', 'batchdownload', 'zip'],
  41. 'private_repos' => false,
  42. ],
  43. ];
  44. $dist_config['services']['Filegator\Services\View\ViewInterface']['config'] = [
  45. 'add_to_head' => '',
  46. 'add_to_body' => '
  47. <script>
  48. var checkVueLoaded = setInterval(function() {
  49. if (document.getElementsByClassName("navbar-item").length) {
  50. clearInterval(checkVueLoaded);
  51. var navProfile = document.getElementsByClassName("navbar-item profile")[0]; navProfile.replaceWith(navProfile.cloneNode(true))
  52. document.getElementsByClassName("navbar-item logout")[0].text="Exit to Control Panel \u00BB";
  53. }
  54. }, 200);
  55. </script>',
  56. ];
  57. return $dist_config;