From e324e298b9d41b8baa7e387004e8447a9ca9b64f Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 22 Apr 2016 11:35:23 +0200 Subject: [PATCH 1/2] Added function for reading file contents h5p/h5p-moodle-plugin#47 HFJ-1844 --- h5p-default-storage.class.php | 10 ++++++++++ h5p-file-storage.interface.php | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 27b250b..fbbe583 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -244,6 +244,16 @@ class H5PDefaultStorage implements \H5PFileStorage { } } + /** + * Read file content of given file and then return it. + * + * @param string $file_path + * @return string + */ + public function getContent($file_path) { + return file_get_contents($this->path . $file_path); + } + /** * Recursive function for copying directories. * diff --git a/h5p-file-storage.interface.php b/h5p-file-storage.interface.php index dfaa67a..b75625e 100644 --- a/h5p-file-storage.interface.php +++ b/h5p-file-storage.interface.php @@ -117,4 +117,12 @@ interface H5PFileStorage { * The hash keys of removed files */ public function deleteCachedAssets($keys); + + /** + * Read file content of given file and then return it. + * + * @param string $file_path + * @return string contents + */ + public function getContent($file_path); } From 76e813a32e8dfb35312dc1a88c5c613d1aca5611 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Sat, 23 Apr 2016 23:40:46 -0400 Subject: [PATCH 2/2] Update h5p.classes.php Prevents H5P From breaking console PHP commands --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index f9655a3..93c4213 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2470,7 +2470,7 @@ class H5PCore { // Determine remote/visitor origin if ($type === 'network' || ($type === 'local' && !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) { - if (filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { + if (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { // Internet $this->h5pF->setOption('site_type', 'internet'); }