From 484b1d09adf46f94fb409bf125ceb156be267e31 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Fri, 6 Jan 2012 01:07:16 +0100 Subject: package viewer and upload implemented. --- r7r_repo/pluginpackage.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'r7r_repo/pluginpackage.php') diff --git a/r7r_repo/pluginpackage.php b/r7r_repo/pluginpackage.php index d8ce170..cf667cc 100644 --- a/r7r_repo/pluginpackage.php +++ b/r7r_repo/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-70-g09d2