From 52723ad93381d2934132eacb7e3f56dc7c76dc78 Mon Sep 17 00:00:00 2001 From: Mannes Date: Wed, 5 Oct 2016 17:14:48 +0200 Subject: [PATCH 1/8] Check for file exists before adding to zip. Adding a non existent file to ZipArchive can lead to archive not being created --- h5p.classes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 4a3203a..d9f1af2 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1586,8 +1586,8 @@ Class H5PExport { foreach ($files as $file) { // Please note that the zip format has no concept of folders, we must // use forward slashes to separate our directories. - $zip->addFile($file->absolutePath, $file->relativePath); - $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath); + if (file_exists($file->absolutePath)) $zip->addFile($file->absolutePath, $file->relativePath); + if (file_exists($rootPrefix . $file->absolutePath)) $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath); } // Close zip and remove tmp dir From a6b01f510f74c46d288515ef158ecfce787fa170 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 22 Feb 2017 11:25:05 +0100 Subject: [PATCH 2/8] Use realpath() instead of document root = safer Document root might be rewritten or incorrect for some sites(observed on multiple WP) HFP-784 --- h5p.classes.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index b0ad889..e04a0e9 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1589,15 +1589,11 @@ Class H5PExport { $zip = new ZipArchive(); $zip->open($tmpFile, ZipArchive::CREATE | ZipArchive::OVERWRITE); - // Some system needs the root prefix for ZipArchive's addFile() - $rootPrefix = (empty($_SERVER['DOCUMENT_ROOT']) ? '' : $_SERVER['DOCUMENT_ROOT'] . '/'); - // Add all the files from the tmp dir. foreach ($files as $file) { // Please note that the zip format has no concept of folders, we must // use forward slashes to separate our directories. - $zip->addFile($file->absolutePath, $file->relativePath); - $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath); + $zip->addFile(realpath($file->absolutePath), $file->relativePath); } // Close zip and remove tmp dir From bfda796ab7605889ea87b64f082233a97a52968c Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Thu, 30 Mar 2017 13:55:44 +0200 Subject: [PATCH 3/8] Allow processing after export is generated --- h5p.classes.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index e04a0e9..2b95829 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -557,7 +557,7 @@ interface H5PFrameworkInterface { /** * Will trigger after the export file is created. */ - public function afterExportCreated(); + public function afterExportCreated($content, $filename); /** * Check if user has permissions to an action @@ -1600,9 +1600,10 @@ Class H5PExport { $zip->close(); H5PCore::deleteFileTree($tmpPath); + $filename = $content['slug'] . '-' . $content['id'] . '.h5p'; try { // Save export - $this->h5pC->fs->saveExport($tmpFile, $content['slug'] . '-' . $content['id'] . '.h5p'); + $this->h5pC->fs->saveExport($tmpFile, $filename); } catch (Exception $e) { $this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage())); @@ -1610,7 +1611,7 @@ Class H5PExport { } unlink($tmpFile); - $this->h5pF->afterExportCreated(); + $this->h5pF->afterExportCreated($content, $filename); return true; } From d81fa06499bb259985a35d3e18f9efd9573c8aa6 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 11 Apr 2017 09:35:17 +0200 Subject: [PATCH 4/8] Check correct variable JI-114 --- h5p.classes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 19488c8..f4b4bef 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2476,7 +2476,7 @@ class H5PCore { ); } - if ($this->h5pF->getOption('h5p_send_usage_statistics', TRUE)) { + if ($this->h5pF->getOption('send_usage_statistics', TRUE)) { $siteData = array_merge( $registrationData, array( @@ -2856,7 +2856,7 @@ class H5PCore { $endpoint = H5PHubEndpoints::CONTENT_TYPES; $data = $interface->fetchExternalData("{$protocol}://{$endpoint}", $postData); - if (! $this->h5pF->getOption('h5p_hub_is_enabled', TRUE)) { + if (! $this->h5pF->getOption('hub_is_enabled', TRUE)) { return TRUE; } From 2ff14ecd371649f9d19335ab52f465fcf5cdc68c Mon Sep 17 00:00:00 2001 From: thomasmars Date: Tue, 11 Apr 2017 13:02:44 +0200 Subject: [PATCH 5/8] Remove key message when registering with Hub until it is back. JI-115 --- h5p.classes.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index f4b4bef..f3b9970 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2471,9 +2471,10 @@ class H5PCore { $this->h5pF->setInfoMessage( $this->h5pF->t('Your site was successfully registered with the H5P Hub.') ); - $this->h5pF->setInfoMessage( - $this->h5pF->t('You have been provided a unique key that identifies you with the Hub when receiving new updates. The key is available for viewing in the "H5P Settings" page.') - ); + // TODO: Uncomment when key is once again available in H5P Settings +// $this->h5pF->setInfoMessage( +// $this->h5pF->t('You have been provided a unique key that identifies you with the Hub when receiving new updates. The key is available for viewing in the "H5P Settings" page.') +// ); } if ($this->h5pF->getOption('send_usage_statistics', TRUE)) { From 727e88908a7503860d9bd833672c490eae1deb24 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Tue, 11 Apr 2017 14:51:27 +0200 Subject: [PATCH 6/8] Made statistics being sent on updateContentTypeCache [HFP-931] --- h5p.classes.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index f3b9970..1fe5140 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2836,19 +2836,9 @@ class H5PCore { public function updateContentTypeCache($postData = NULL) { $interface = $this->h5pF; - // Set uuid - if (!$postData || !isset($postData['uuid'])) { - $site_uuid = $this->h5pF->getOption('site_uuid', ''); - - // Register site with site uuid if we don't already have it - // and try to update content type cache again when this is done - if (empty($site_uuid)) { - return $this->fetchLibrariesMetadata(); - } - - $postData = array( - 'uuid' => $site_uuid - ); + // Make sure data is sent! + if (!isset($postData) || !isset($postData['uuid'])) { + return $this->fetchLibrariesMetadata(); } $postData['current_cache'] = $this->h5pF->getOption('content_type_cache_updated_at', 0); From d50d98297b7dcef2d375ef475870027900c91e8c Mon Sep 17 00:00:00 2001 From: thomasmars Date: Tue, 11 Apr 2017 19:34:58 +0200 Subject: [PATCH 7/8] Set action frame button sizes in pixels to be IE11 compat Frame is always set in pixels anyway, so should not be a problem HFP-939 --- styles/h5p.css | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/styles/h5p.css b/styles/h5p.css index 9876d3a..760c916 100755 --- a/styles/h5p.css +++ b/styles/h5p.css @@ -215,11 +215,10 @@ div.h5p-fullscreen { } .h5p-actions > .h5p-button:before { font-family: 'H5P'; - font-size: 1em; + font-size: 20px; + line-height: 20px; + vertical-align: top; padding-right: 0; - font-size: 1.7em; - line-height: 1.125em; - vertical-align: middle; } .h5p-actions > .h5p-button.h5p-export:before { content: "\e893"; From bd851f292984cff338a1d2e411de8271c0fed74d Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 18 Apr 2017 14:54:58 +0200 Subject: [PATCH 8/8] Remove http_response_code() Not supported prior to PHP 5.4 HFP-959 --- h5p.classes.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 1fe5140..44f0f1b 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2777,10 +2777,6 @@ class H5PCore { * @param null|int $status_code Http response code */ private static function printJson($data, $status_code = NULL) { - if ($status_code !== NULL) { - http_response_code($status_code); - } - header('Cache-Control: no-cache'); header('Content-type: application/json; charset=utf-8'); print json_encode($data);