download_scorm.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file is responsible for passing requested documents to the browser.
  5. *
  6. * @package chamilo.document
  7. */
  8. /**
  9. * Code
  10. */
  11. session_cache_limiter('none');
  12. require_once '../inc/global.inc.php';
  13. $this_section = SECTION_COURSES;
  14. // Protection
  15. api_protect_course_script();
  16. if (!isset($_course)) {
  17. api_not_allowed(true);
  18. }
  19. // If LP obj exists
  20. if (isset($_SESSION['oLP'])) {
  21. $obj = $_SESSION['oLP'];
  22. } else {
  23. api_not_allowed();
  24. }
  25. //If is visible for the current user
  26. if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id())) {
  27. api_not_allowed();
  28. }
  29. $doc_url = isset($_GET['doc_url']) ? $_GET['doc_url'] : null;
  30. // Change the '&' that got rewritten to '///' by mod_rewrite back to '&'
  31. $doc_url = str_replace('///', '&', $doc_url);
  32. // Still a space present? it must be a '+' (that got replaced by mod_rewrite)
  33. $doc_url = str_replace(' ', '+', $doc_url);
  34. $doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url); //echo $doc_url;
  35. if (strpos($doc_url,'../') OR strpos($doc_url,'/..')) {
  36. $doc_url = '';
  37. }
  38. $sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/scorm';
  39. if (is_dir($sys_course_path.$doc_url)) {
  40. api_not_allowed();
  41. }
  42. if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
  43. $full_file_name = $sys_course_path.$doc_url;
  44. // Launch event
  45. event_download($doc_url);
  46. DocumentManager::file_send_for_download($full_file_name);
  47. }
  48. exit;