diff --git a/h5p.classes.php b/h5p.classes.php index 40e0a83..35cfdf5 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -10,6 +10,38 @@ interface h5pFramework { class h5p { public $h5pF; + + // Schemas used to validate the h5p files + private $h5pRequired = array( + 'title' => '^.{1,255}$', + 'mainVersion' => '^[0-9]{1,5}$', + 'language' => '^[a-z]{1,5}$', + 'machineName' => '^[a-z0-9\-]{1,255}$', + 'preloadedDependencies' => array( + 'machineName' => '^[a-z0-9\-]{1,255}$', + 'minimumVersion' => '^[0-9]{1,5}$', + ), + 'init' => '^[$A-Z_][0-9A-Z_\.$]{1,254}$', + 'embedTypes' => array('iframe', 'div'), + ); + + private $h5pOptional = array( + 'contentType' => '^.{1,255}$', + 'utilization' => '^.{1,}$', + 'subVersion' => '^[0-9]{1,5}$', + 'author' => '^.{1,255}$', + 'lisence' => '^(iframe|div)$', + 'dynamicDependencies' => array( + 'machineName' => '^[a-z0-9\-]{1,255}$', + 'minimumVersion' => '^[0-9]{1,5}$', + ), + 'preloadedJs' => '^(\\[a-z_\-\s0-9\.]+)+\.(?i)(js)$', + 'preloadedCss' => '^(\\[a-z_\-\s0-9\.]+)+\.(?i)(js)$', + 'w' => '^[0-9]{1,4}$', + 'h' => '^[0-9]{1,4}$', + 'metaKeywords' => '^.{1,}$', + 'metaDescription' => '^.{1,}$', + ); public function __construct($h5pFramework) { $this->h5pF = $h5pFramework; @@ -78,7 +110,8 @@ class h5p { $this->rRmdir($file_path); continue; } - + // We have decoded the json! Check for required properties + } if ($content->type != H5P_CONTENT && $content->type != H5P_LIBRARY) {