1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- session_cache_limiter('public');
- require_once '../inc/global.inc.php';
- $this_section = SECTION_COURSES;
- require_once api_get_path(LIBRARY_PATH).'document.lib.php';
- header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
- header('Cache-Control: public');
- header('Pragma: no-cache');
- api_protect_course_script(true);
- $doc_url = $_GET['file'];
- $doc_url = str_replace('///', '&', $doc_url);
- $doc_url = str_replace(' ', '+', $doc_url);
- $doc_url = str_replace('/..', '', $doc_url);
- if (!isset($_course)) {
- api_not_allowed(true);
- }
- $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$doc_url;
- $tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
- event_download($doc_url);
- $doc_url = Database::escape_string($doc_url);
- $sql = 'SELECT title FROM '.$tbl_student_publication.'WHERE url LIKE BINARY "'.$doc_url.'"';
- $result = Database::query($sql);
- if (Database::num_rows($result) > 0) {
- $row = Database::fetch_array($result);
- $title = str_replace(' ', '_', $row['title']);
- if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')) {
- DocumentManager::file_send_for_download($full_file_name, true, $title);
- }
- }
- exit;
|