Skip to content

Commit

Permalink
Replace http with https see BT#10217
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Sep 15, 2015
1 parent 350a119 commit 4e0fb4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 2 additions & 4 deletions main/document/download_scorm.php
Expand Up @@ -5,9 +5,6 @@
*
* @package chamilo.document
*/
/**
* Code
*/

session_cache_limiter('none');

Expand Down Expand Up @@ -59,6 +56,7 @@
// Launch event
Event::event_download($doc_url);

DocumentManager::file_send_for_download($full_file_name);
$fixLinks = api_get_configuration_value('lp_replace_http_to_https');
DocumentManager::file_send_for_download($full_file_name, false, '', $fixLinks);
}
exit;
22 changes: 19 additions & 3 deletions main/inc/lib/document.lib.php
Expand Up @@ -310,11 +310,16 @@ public static function file_visible_to_user($this_course, $doc_url)
* @param string $full_file_name
* @param boolean $forced
* @param string $name
* @param string $fixLinksHttpToHttps change file content from http to https
*
* @return false if file doesn't exist, true if stream succeeded
*/
public static function file_send_for_download($full_file_name, $forced = false, $name = '')
{
public static function file_send_for_download(
$full_file_name,
$forced = false,
$name = '',
$fixLinksHttpToHttps = false
) {
session_write_close(); //we do not need write access to session anymore
if (!is_file($full_file_name)) {
return false;
Expand Down Expand Up @@ -396,7 +401,18 @@ public static function file_send_for_download($full_file_name, $forced = false,
} else {
header('Content-Disposition: inline; filename= ' . $filename);
}
readfile($full_file_name);

if ($fixLinksHttpToHttps) {
$content = file_get_contents($full_file_name);
$content = str_replace(
array('http%3A%2F%2F', 'http://'),
array('https%3A%2F%2F', 'https://'),
$content
);
echo $content;
} else {
readfile($full_file_name);
}

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions main/install/configuration.dist.php
Expand Up @@ -217,3 +217,5 @@
];*/
// Boost option to ignore encoding check for learning paths
//$_configuration['lp_fixed_encoding'] = 'false';
// Fix urls changing http with https in scorm packages.
//$_configuration['lp_replace_http_to_https'] = false;

0 comments on commit 4e0fb4a

Please sign in to comment.