Should fix bug when exporting a LP to a zip see #4706, requires some changes in courses/.htaccess
parent
3448d50a84
commit
587634649c
@ -0,0 +1,64 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* This file is responsible for passing requested documents to the browser. |
||||
* |
||||
* @package chamilo.document |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
|
||||
session_cache_limiter('none'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
$this_section = SECTION_COURSES; |
||||
|
||||
// Protection |
||||
api_protect_course_script(); |
||||
|
||||
if (!isset($_course)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
// If LP obj exists |
||||
if (isset($_SESSION['oLP'])) { |
||||
$obj = $_SESSION['oLP']; |
||||
} else { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
//If is visible for the current user |
||||
if (!$obj->is_lp_visible_for_student($obj->get_id(), api_get_user_id())) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$doc_url = isset($_GET['url']) ? $_GET['url'] : null; |
||||
|
||||
// Change the '&' that got rewritten to '///' by mod_rewrite back to '&' |
||||
$doc_url = str_replace('///', '&', $doc_url); |
||||
// Still a space present? it must be a '+' (that got replaced by mod_rewrite) |
||||
$doc_url = str_replace(' ', '+', $doc_url); |
||||
|
||||
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url); //echo $doc_url; |
||||
|
||||
if (strpos($doc_url,'../') OR strpos($doc_url,'/..')) { |
||||
$doc_url = ''; |
||||
} |
||||
|
||||
$sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/scorm'; |
||||
|
||||
//var_dump($sys_course_path); |
||||
|
||||
if (is_dir($sys_course_path.$doc_url)) { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) { |
||||
$full_file_name = $sys_course_path.$doc_url; |
||||
// Launch event |
||||
event_download($doc_url); |
||||
|
||||
DocumentManager::file_send_for_download($full_file_name); |
||||
} |
||||
exit; |
@ -1,22 +1,26 @@ |
||||
########################################################################################### |
||||
#change this file to fit your configuration and save it as .htaccess in the courses folder# |
||||
########################################################################################### |
||||
#chamilo mod rewrite |
||||
#comment lines start with # and are not processed |
||||
# Change this file to fit your configuration and save it as .htaccess in the courses folder # |
||||
# Chamilo mod rewrite |
||||
# Comment lines start with # and are not processed |
||||
|
||||
<IfModule mod_rewrite.c> |
||||
RewriteEngine On |
||||
|
||||
#rewrite base is the dir chamilo is installed in with trailing slash |
||||
# Rewrite base is the dir chamilo is installed in with trailing slash |
||||
RewriteBase {CHAMILO_URL_APPEND_PATH}/courses/ |
||||
|
||||
#do not rewrite on the main dir |
||||
#change this path to the path of your main folder |
||||
# Do not rewrite on the main dir |
||||
# Change this path to the path of your main folder |
||||
RewriteCond %{REQUEST_URI} !^{CHAMILO_URL_APPEND_PATH}/main/ |
||||
|
||||
#replace nasty ampersands by 3 slashes, we change these back in download.php |
||||
RewriteRule ([^/]+)/document/(.*)&(.*)$ $1/document/$2///$3 [N] |
||||
#rewrite everything in the document folder of a course to the download script |
||||
|
||||
# Rewrite everything in the scorm folder of a course to the download script |
||||
RewriteRule ([^/]+)/scorm/(.*)$ {CHAMILO_URL_APPEND_PATH}/main/document/download_scorm.php?doc_url=/$2&cDir=$1 [QSA,L] |
||||
|
||||
# Rewrite everything in the document folder of a course to the download script |
||||
RewriteRule ([^/]+)/document/(.*)$ {CHAMILO_URL_APPEND_PATH}/main/document/download.php?doc_url=/$2&cDir=$1 [QSA,L] |
||||
|
||||
# Rewrite everything in the work folder |
||||
RewriteRule ([^/]+)/work/(.*)$ {CHAMILO_URL_APPEND_PATH}/main/work/download.php?file=work/$2&cDir=$1 [QSA,L] |
||||
</IfModule> |
Loading…
Reference in new issue