From 8cc5c63be307d5948560d24191ab0e9c45db1b77 Mon Sep 17 00:00:00 2001 From: ziegler Date: Fri, 22 Sep 2023 10:32:38 +0200 Subject: [PATCH 1/3] Fix redirect rule and logic, fix OOM error in redirect --- service/src/main/php/src/tools/h5p/H5P.php | 2 +- service/src/main/php/src/tools/h5p/cache/.htaccess | 2 +- service/src/main/php/src/tools/h5p/redirect.php | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/service/src/main/php/src/tools/h5p/H5P.php b/service/src/main/php/src/tools/h5p/H5P.php index 2d80a37..bf7143d 100644 --- a/service/src/main/php/src/tools/h5p/H5P.php +++ b/service/src/main/php/src/tools/h5p/H5P.php @@ -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'] = '/src/tools/h5p/cache'; $integration['siteUrl'] = WWWURL; $integration['postUserStatistics'] = ''; $integration['ajax'] = array(); diff --git a/service/src/main/php/src/tools/h5p/cache/.htaccess b/service/src/main/php/src/tools/h5p/cache/.htaccess index fef6ab8..84bf4d9 100644 --- a/service/src/main/php/src/tools/h5p/cache/.htaccess +++ b/service/src/main/php/src/tools/h5p/cache/.htaccess @@ -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] \ No newline at end of file diff --git a/service/src/main/php/src/tools/h5p/redirect.php b/service/src/main/php/src/tools/h5p/redirect.php index 1f33c14..674eef0 100644 --- a/service/src/main/php/src/tools/h5p/redirect.php +++ b/service/src/main/php/src/tools/h5p/redirect.php @@ -6,6 +6,14 @@ $connector_name = basename(WWWURL); $base = DATA.'/h5p'; + +$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); + $src_file = str_replace('/'.$connector_name.'/src/tools/h5p/cache', $base, $_REQUEST['ID']); $src_file = str_replace('/src/tools/h5p/cache', $base, $_REQUEST['ID']); @@ -15,6 +23,7 @@ return; } +ini_set('memory_limit', '2048M'); $filesize = filesize($src_file); $mimetype = mime_content_type($src_file); From 027a0d4ec0cb504241adda1054ba637cfee01f66 Mon Sep 17 00:00:00 2001 From: ziegler Date: Fri, 22 Sep 2023 11:15:39 +0200 Subject: [PATCH 2/3] fix url --- service/src/main/php/src/tools/h5p/H5P.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/main/php/src/tools/h5p/H5P.php b/service/src/main/php/src/tools/h5p/H5P.php index bf7143d..e51a0d2 100644 --- a/service/src/main/php/src/tools/h5p/H5P.php +++ b/service/src/main/php/src/tools/h5p/H5P.php @@ -160,7 +160,7 @@ public function showEditor($content, Response $response) { $integration = array(); $integration['baseUrl'] = WWWURL; //$integration['url'] = '/eduConnector/src/tools/h5p'; - $integration['url'] = '/src/tools/h5p/cache'; + $integration['url'] = WWWURL . '/src/tools/h5p/cache'; $integration['siteUrl'] = WWWURL; $integration['postUserStatistics'] = ''; $integration['ajax'] = array(); From e924454dbbb8f8913acba27b659c0780dc355893 Mon Sep 17 00:00:00 2001 From: ziegler Date: Fri, 22 Sep 2023 11:15:56 +0200 Subject: [PATCH 3/3] fix redirect php --- service/src/main/php/src/tools/h5p/redirect.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/service/src/main/php/src/tools/h5p/redirect.php b/service/src/main/php/src/tools/h5p/redirect.php index 674eef0..1bccb34 100644 --- a/service/src/main/php/src/tools/h5p/redirect.php +++ b/service/src/main/php/src/tools/h5p/redirect.php @@ -14,9 +14,6 @@ $src_file = str_replace('/'.$connector_name.'/src/tools/h5p/cache', $base, $oldPath); $src_file = str_replace('/src/tools/h5p/cache', $base, $oldPath); -$src_file = str_replace('/'.$connector_name.'/src/tools/h5p/cache', $base, $_REQUEST['ID']); -$src_file = str_replace('/src/tools/h5p/cache', $base, $_REQUEST['ID']); - $realPath = realpath($src_file); if($realPath === false || strpos($realPath, $base) !== 0) { http_response_code(404);