configuration.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. 'directoryPerm' => 0755,
  36. ]);
  37. };
  38. $dist_config['services']['Filegator\Services\Auth\AuthInterface'] = [
  39. 'handler' => '\Filegator\Services\Auth\Adapters\HestiaAuth',
  40. 'config' => [
  41. 'permissions' => ['read', 'write', 'upload', 'download', 'batchdownload', 'zip'],
  42. 'private_repos' => false,
  43. ],
  44. ];
  45. $dist_config['services']['Filegator\Services\View\ViewInterface']['config'] = [
  46. 'add_to_head' => '
  47. <style>
  48. .logo {
  49. width: 46px;
  50. }
  51. </style>
  52. ',
  53. 'add_to_body' => '
  54. <script>
  55. var checkVueLoaded = setInterval(function() {
  56. if (document.getElementsByClassName("navbar-item").length) {
  57. clearInterval(checkVueLoaded);
  58. var navProfile = document.getElementsByClassName("navbar-item profile")[0]; navProfile.replaceWith(navProfile.cloneNode(true))
  59. document.getElementsByClassName("navbar-item logout")[0].text="Exit to Control Panel \u00BB";
  60. }
  61. }, 200);
  62. </script>',
  63. ];
  64. return $dist_config;