download_uploaded_files.php 969 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. session_cache_limiter('none');
  4. require_once __DIR__.'/../inc/global.inc.php';
  5. $this_section = SECTION_COURSES;
  6. // Protection
  7. api_protect_course_script();
  8. $courseCode = isset($_GET['code']) ? $_GET['code'] : '';
  9. $type = isset($_GET['type']) ? $_GET['type'] : '';
  10. $file = isset($_GET['file']) ? $_GET['file'] : '';
  11. $courseInfo = api_get_course_info($courseCode);
  12. if (empty($courseInfo)) {
  13. $courseInfo = api_get_course_info();
  14. }
  15. if (empty($courseInfo) || empty($type) || empty($file)) {
  16. api_not_allowed(true);
  17. }
  18. $toolPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/upload/'.$type.'/';
  19. if (!is_dir($toolPath)) {
  20. api_not_allowed(true);
  21. }
  22. if (Security::check_abs_path($toolPath.$file, $toolPath.'/')) {
  23. $fullFilePath = $toolPath.$file;
  24. $result = DocumentManager::file_send_for_download($fullFilePath, false, '');
  25. if ($result === false) {
  26. api_not_allowed(true);
  27. }
  28. }
  29. exit;