Merge remote-tracking branch 'origin/master'

h5p-prerequisites-validator
Thomas Marstrander 2016-04-25 13:17:56 +02:00
commit 05dfc9c374
3 changed files with 19 additions and 1 deletions

View File

@ -247,6 +247,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. * Recursive function for copying directories.
* *

View File

@ -117,4 +117,12 @@ interface H5PFileStorage {
* The hash keys of removed files * The hash keys of removed files
*/ */
public function deleteCachedAssets($keys); 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);
} }

View File

@ -2470,7 +2470,7 @@ class H5PCore {
// Determine remote/visitor origin // Determine remote/visitor origin
if ($type === 'network' || if ($type === 'network' ||
($type === 'local' && !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) { ($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 // Internet
$this->h5pF->setOption('site_type', 'internet'); $this->h5pF->setOption('site_type', 'internet');
} }