download.lib.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. //require '../inc/global.inc.php';
  3. function create_backup_is_admin($_cid) {
  4. $this_section = SECTION_COURSES;
  5. if(isset($_GET['session']) && $_GET['session'] == true )
  6. {
  7. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  8. $_cid = true;
  9. $is_courseAdmin = true;
  10. }
  11. else
  12. {
  13. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  14. }
  15. $archive_file = $_GET['archive'];
  16. $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
  17. list($extension) = getextension($archive_file);
  18. if (empty($extension) || !file_exists($archive_path.$archive_file))
  19. {
  20. return false;
  21. }
  22. $content_type = '';
  23. if (in_array(strtolower($extension), array('xml','csv')) && (api_is_platform_admin(true) || api_is_drh())) {
  24. $content_type = 'application/force-download';
  25. } elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
  26. $content_type = 'application/force-download';
  27. }
  28. if (empty($content_type)) {
  29. return false ;
  30. }
  31. return true;
  32. }
  33. return true;
  34. ?>