index.php 908 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  3. if ((!isset($_SESSION['FILEMANAGER_KEY'])) || (empty($_SESSION['FILEMANAGER_KEY']))) {
  4. header("Location: /login/");
  5. exit;
  6. }
  7. $user = $_SESSION['user'];
  8. if (($_SESSION['user'] == 'admin') && (!empty($_SESSION['look']))) {
  9. $user = $_SESSION['look'];
  10. }
  11. $path = $_REQUEST['path'];
  12. if (!empty($path)) {
  13. set_time_limit(0);
  14. if (ob_get_level()) {
  15. ob_end_clean();
  16. }
  17. header("Content-type: application/octet-stream");
  18. header("Content-Transfer-Encoding: binary");
  19. header("Content-disposition: attachment;filename=".basename($path));
  20. $output = '';
  21. exec(VESTA_CMD . "v-check-fs-permission " . $user . " " . escapeshellarg($path), $output, $return_var);
  22. if ($return_var != 0) {
  23. print 'Error while opening file'; // todo: handle this more styled
  24. exit;
  25. }
  26. readfile($path);
  27. exit;
  28. } else {
  29. die('File not found');
  30. }