Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/8.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/8.0
  • Loading branch information
metaventis-build committed Sep 22, 2023
2 parents 343fbed + e924454 commit 76ce5b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion service/src/main/php/src/tools/h5p/H5P.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function showEditor($content, Response $response) {
$integration = array();
$integration['baseUrl'] = WWWURL;
//$integration['url'] = '/eduConnector/src/tools/h5p';
$integration['url'] = '/eduConnector/src/tools/h5p/cache';
$integration['url'] = WWWURL . '/src/tools/h5p/cache';
$integration['siteUrl'] = WWWURL;
$integration['postUserStatistics'] = '';
$integration['ajax'] = array();
Expand Down
2 changes: 1 addition & 1 deletion service/src/main/php/src/tools/h5p/cache/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Options FollowSymLinks
RewriteEngine On

RewriteRule ^.* ../redirect.php?ID=%{REQUEST_URI}&%{QUERY_STRING}
RewriteRule (^.*) ../redirect.php?ID=%{THE_REQUEST} [PT,B,QSA]
10 changes: 8 additions & 2 deletions service/src/main/php/src/tools/h5p/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@

$connector_name = basename(WWWURL);
$base = DATA.'/h5p';
$src_file = str_replace('/'.$connector_name.'/src/tools/h5p/cache', $base, $_REQUEST['ID']);
$src_file = str_replace('/src/tools/h5p/cache', $base, $_REQUEST['ID']);

$wholeRequest = $_REQUEST['ID'];
$requestUri = explode(' ', $wholeRequest)[1];
$oldPath = explode('?', $requestUri)[0];

$src_file = str_replace('/'.$connector_name.'/src/tools/h5p/cache', $base, $oldPath);
$src_file = str_replace('/src/tools/h5p/cache', $base, $oldPath);

$realPath = realpath($src_file);
if($realPath === false || strpos($realPath, $base) !== 0) {
http_response_code(404);
return;
}

ini_set('memory_limit', '2048M');
$filesize = filesize($src_file);

$mimetype = mime_content_type($src_file);
Expand Down

0 comments on commit 76ce5b9

Please sign in to comment.