download.lib.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Course info library
  5. * @package chamilo.course_info
  6. */
  7. /**
  8. * Code
  9. */
  10. // TODO: Where this file is used? Is it needed at all?
  11. //require '../inc/global.inc.php';
  12. function create_backup_is_admin($_cid) {
  13. if (isset($_GET['session']) && $_GET['session']) {
  14. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  15. $_cid = true;
  16. $is_courseAdmin = true;
  17. } else {
  18. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  19. }
  20. $archive_file = $_GET['archive'];
  21. $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
  22. list($extension) = FileManager::getextension($archive_file);
  23. if (empty($extension) || !file_exists($archive_path.$archive_file)) {
  24. return false;
  25. }
  26. $extension = strtolower($extension);
  27. $content_type = '';
  28. if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
  29. $content_type = 'application/force-download';
  30. // TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed.
  31. //} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
  32. } elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
  33. //
  34. $content_type = 'application/force-download';
  35. }
  36. if (empty($content_type)) {
  37. return false;
  38. }
  39. return true;
  40. }
  41. return true; // TODO: Why is this line here?