You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
15 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
8 years ago
|
|
||
8 years ago
|
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
|
||
9 years ago
|
|
||
14 years ago
|
/**
|
||
7 years ago
|
* Download script for course info.
|
||
|
*
|
||
14 years ago
|
* @package chamilo.course_info
|
||
|
*/
|
||
8 years ago
|
require_once __DIR__.'/../inc/global.inc.php';
|
||
15 years ago
|
$this_section = SECTION_COURSES;
|
||
18 years ago
|
|
||
8 years ago
|
if (isset($_GET['archive_path'])) {
|
||
7 years ago
|
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
|
||
15 years ago
|
} else {
|
||
7 years ago
|
$archive_path = CourseArchiver::getBackupDir();
|
||
15 years ago
|
}
|
||
11 years ago
|
$archive_file = isset($_GET['archive']) ? $_GET['archive'] : null;
|
||
7 years ago
|
$archive_file = str_replace(['..', '/', '\\'], '', $archive_file);
|
||
18 years ago
|
|
||
15 years ago
|
list($extension) = getextension($archive_file);
|
||
18 years ago
|
|
||
15 years ago
|
if (empty($extension) || !file_exists($archive_path.$archive_file)) {
|
||
8 years ago
|
exit;
|
||
18 years ago
|
}
|
||
|
|
||
11 years ago
|
$extension = strtolower($extension);
|
||
16 years ago
|
$content_type = '';
|
||
18 years ago
|
|
||
7 years ago
|
if (in_array($extension, ['xml', 'csv']) &&
|
||
7 years ago
|
(api_is_platform_admin(true) || api_is_drh())
|
||
|
) {
|
||
|
$content_type = 'application/force-download';
|
||
6 years ago
|
} elseif ($extension === 'zip' && $_cid && (api_is_platform_admin(true) || api_is_course_admin())) {
|
||
7 years ago
|
$content_type = 'application/force-download';
|
||
18 years ago
|
}
|
||
|
|
||
16 years ago
|
if (empty($content_type)) {
|
||
9 years ago
|
api_not_allowed(true);
|
||
18 years ago
|
}
|
||
11 years ago
|
if (Security::check_abs_path($archive_path.$archive_file, $archive_path)) {
|
||
7 years ago
|
DocumentManager::file_send_for_download(
|
||
|
$archive_path.$archive_file,
|
||
|
true,
|
||
|
$archive_file
|
||
|
);
|
||
10 years ago
|
exit;
|
||
14 years ago
|
} else {
|
||
14 years ago
|
api_not_allowed(true);
|
||
14 years ago
|
}
|