download.lib.php 1.3 KB

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