From fbc25b825c26eea168d24c5ec6df971eba650d70 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 6 Jan 2012 00:49:42 +0100 Subject: Fixed bugs in pluginpackage.php. --- ratatoeskr/sys/pluginpackage.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'ratatoeskr') diff --git a/ratatoeskr/sys/pluginpackage.php b/ratatoeskr/sys/pluginpackage.php index d8ce170..cf667cc 100644 --- a/ratatoeskr/sys/pluginpackage.php +++ b/ratatoeskr/sys/pluginpackage.php @@ -61,6 +61,23 @@ function array2dir($a, $dir) } } +function validate_url ($u) { return preg_match("/^http[s]{0,1}:\\/\\/.*$/", $u) != 0; } +function validate_arraydir($a) +{ + if(!is_array($a)) + return False; + foreach($a as $k=>$v) + { + if(!is_string($k)) + return False; + if(is_array($v) and (!validate_arraydir($v))) + return False; + elseif(!is_string($v)) + return False; + } + return True; +} + /* * Class: InvalidPackage * An Exception that 's function can throw, if the package is invalid. @@ -122,23 +139,6 @@ class PluginPackage */ public function validate() { - function validate_url ($u) { return preg_match("/^http[s]{0,1}:\\/\\/.*$/", $u) != 0; } - function validate_arraydir($a) - { - if(!is_array($a)) - return False; - foreach($a as $k=>$v) - { - if(!is_string($k)) - return False; - if(is_array($v) and (!validate_arraydir($v))) - return False; - elseif(!is_string($v)) - return False; - } - return True; - } - if(!is_string($this->code)) throw new InvalidPackage("Invalid code value."); if(!is_string($this->classname)) @@ -156,9 +156,9 @@ class PluginPackage if(!is_string($this->short_description)) throw new InvalidPackage("Invalid short_description value."); - if(($this->updatepath !== NULL) and (!validate_url($this->updatepath))) - throw new InvalidPackage("Invalid updatepath value. Must be an URL."); - if(($this->web !== NULL) and (!validate_url($this->web))) + if((!empty($this->updatepath)) and (!validate_url($this->updatepath))) + throw new InvalidPackage("Invalid updatepath value. Must be an URL. " .$this->updatepath); + if((!empty($this->web)) and (!validate_url($this->web))) throw new InvalidPackage("Invalid web value. Must be an URL."); if(($this->license !== NULL) and (!is_string($this->license))) throw new InvalidPackage("Invalid license value."); -- cgit v1.2.3-54-g00ecf