download_my_files.php 673 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once __DIR__.'/../inc/global.inc.php';
  4. $userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
  5. $file = isset($_GET['file']) ? $_GET['file'] : '';
  6. if (empty($userId) || empty($file)) {
  7. exit;
  8. }
  9. $dir = UserManager::getUserPathById($userId, 'system');
  10. if (empty($dir)) {
  11. exit;
  12. }
  13. $file = $dir.'/my_files/'.$file;
  14. $config = api_get_configuration_value('block_my_files_access');
  15. if ($config) {
  16. api_block_anonymous_users();
  17. }
  18. if (Security::check_abs_path($file, $dir.'my_files/')) {
  19. $result = DocumentManager::file_send_for_download($file);
  20. if ($result === false) {
  21. exit;
  22. }
  23. }