diff options
Diffstat (limited to 'libs/Zend/Validate/File')
-rw-r--r-- | libs/Zend/Validate/File/Count.php | 45 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Crc32.php | 18 | ||||
-rw-r--r-- | libs/Zend/Validate/File/ExcludeExtension.php | 14 | ||||
-rw-r--r-- | libs/Zend/Validate/File/ExcludeMimeType.php | 12 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Exists.php | 14 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Extension.php | 16 | ||||
-rw-r--r-- | libs/Zend/Validate/File/FilesSize.php | 31 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Hash.php | 24 | ||||
-rw-r--r-- | libs/Zend/Validate/File/ImageSize.php | 24 | ||||
-rw-r--r-- | libs/Zend/Validate/File/IsCompressed.php | 117 | ||||
-rw-r--r-- | libs/Zend/Validate/File/IsImage.php | 145 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Md5.php | 20 | ||||
-rw-r--r-- | libs/Zend/Validate/File/MimeType.php | 102 | ||||
-rw-r--r-- | libs/Zend/Validate/File/NotExists.php | 10 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Sha1.php | 18 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Size.php | 27 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Upload.php | 30 | ||||
-rw-r--r-- | libs/Zend/Validate/File/WordCount.php | 12 |
18 files changed, 244 insertions, 435 deletions
diff --git a/libs/Zend/Validate/File/Count.php b/libs/Zend/Validate/File/Count.php index a4bff7ee8c..f2dfac7413 100644 --- a/libs/Zend/Validate/File/Count.php +++ b/libs/Zend/Validate/File/Count.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Count.php 21326 2010-03-04 20:32:39Z thomas $ + * @version $Id: Count.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for counting all given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Count extends Zend_Validate_Abstract @@ -37,16 +37,16 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract /**#@+ * @const string Error constants */ - const TOO_MANY = 'fileCountTooMany'; - const TOO_FEW = 'fileCountTooFew'; + const TOO_MUCH = 'fileCountTooMuch'; + const TOO_LESS = 'fileCountTooLess'; /**#@-*/ /** * @var array Error message templates */ protected $_messageTemplates = array( - self::TOO_MANY => "Too many files, maximum '%max%' are allowed but '%count%' are given", - self::TOO_FEW => "Too few files, minimum '%min%' are expected but '%count%' are given", + self::TOO_MUCH => "Too much files, maximum '%max%' are allowed but '%count%' are given", + self::TOO_LESS => "Too less files, minimum '%min%' are expected but '%count%' are given" ); /** @@ -110,11 +110,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } elseif (is_string($options) || is_numeric($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE); $options['min'] = func_get_arg(0); $options['max'] = func_get_arg(1); } @@ -152,13 +154,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } if (!is_string($min) and !is_numeric($min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $min; if (($this->_max !== null) && ($min > $this->_max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >" . " {$this->_max}"); } @@ -191,13 +193,13 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } if (!is_string($max) and !is_numeric($max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $max; if (($this->_min !== null) && ($max < $this->_min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but " . "$max < {$this->_min}"); } @@ -241,25 +243,14 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract */ public function isValid($value, $file = null) { - if (($file !== null) && !array_key_exists('destination', $file)) { - $file['destination'] = dirname($value); - } - - if (($file !== null) && array_key_exists('tmp_name', $file)) { - $value = $file['destination'] . DIRECTORY_SEPARATOR . $file['name']; - } - - if (($file === null) || !empty($file['tmp_name'])) { - $this->addFile($value); - } - + $this->addFile($value); $this->_count = count($this->_files); if (($this->_max !== null) && ($this->_count > $this->_max)) { - return $this->_throw($file, self::TOO_MANY); + return $this->_throw($file, self::TOO_MUCH); } if (($this->_min !== null) && ($this->_count < $this->_min)) { - return $this->_throw($file, self::TOO_FEW); + return $this->_throw($file, self::TOO_LESS); } return true; diff --git a/libs/Zend/Validate/File/Crc32.php b/libs/Zend/Validate/File/Crc32.php index 31b420585e..fd46d81b6b 100644 --- a/libs/Zend/Validate/File/Crc32.php +++ b/libs/Zend/Validate/File/Crc32.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Crc32.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Crc32.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the crc32 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given crc32 hashes", - self::NOT_DETECTED => "A crc32 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given crc32 hashes", + self::NOT_DETECTED => "There was no crc32 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -70,7 +70,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -157,7 +157,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ExcludeExtension.php b/libs/Zend/Validate/File/ExcludeExtension.php index 94fb27bb6d..74264de98c 100644 --- a/libs/Zend/Validate/File/ExcludeExtension.php +++ b/libs/Zend/Validate/File/ExcludeExtension.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExcludeExtension.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: ExcludeExtension.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/File/Extension.php'; +require_once 'Zend/Validate/File/Extension.php'; /** * Validator for the excluding file extensions * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension @@ -44,8 +44,8 @@ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_EXTENSION => "File '%value%' has a false extension", - self::NOT_FOUND => "File '%value%' could not be found", + self::FALSE_EXTENSION => "The file '%value%' has a false extension", + self::NOT_FOUND => "The file '%value%' was not found" ); /** @@ -61,7 +61,7 @@ class Zend_Validate_File_ExcludeExtension extends Zend_Validate_File_Extension public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ExcludeMimeType.php b/libs/Zend/Validate/File/ExcludeMimeType.php index 436caa1f02..4984b79cfb 100644 --- a/libs/Zend/Validate/File/ExcludeMimeType.php +++ b/libs/Zend/Validate/File/ExcludeMimeType.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExcludeMimeType.php 21936 2010-04-18 16:23:34Z thomas $ + * @version $Id: ExcludeMimeType.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator for the mime type of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType @@ -59,7 +59,7 @@ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType } // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } @@ -73,7 +73,7 @@ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType $mime = new finfo($const); } - if (!empty($mime)) { + if ($mime !== false) { $this->_type = $mime->file($value); } unset($mime); diff --git a/libs/Zend/Validate/File/Exists.php b/libs/Zend/Validate/File/Exists.php index 6ecd11f1f0..835b4c2c70 100644 --- a/libs/Zend/Validate/File/Exists.php +++ b/libs/Zend/Validate/File/Exists.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exists.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Exists.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Exists extends Zend_Validate_Abstract @@ -43,7 +43,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_EXIST => "File '%value%' does not exist", + self::DOES_NOT_EXIST => "The file '%value%' does not exist" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract } else if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } @@ -122,7 +122,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } diff --git a/libs/Zend/Validate/File/Extension.php b/libs/Zend/Validate/File/Extension.php index 8d903e4093..58ab0b21af 100644 --- a/libs/Zend/Validate/File/Extension.php +++ b/libs/Zend/Validate/File/Extension.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Extension.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Extension.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the file extension of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Extension extends Zend_Validate_Abstract @@ -44,8 +44,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_EXTENSION => "File '%value%' has a false extension", - self::NOT_FOUND => "File '%value%' could not be found", + self::FALSE_EXTENSION => "The file '%value%' has a false extension", + self::NOT_FOUND => "The file '%value%' was not found" ); /** @@ -81,6 +81,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE); $case = func_get_arg(1); $this->setCase($case); } @@ -187,7 +189,7 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/FilesSize.php b/libs/Zend/Validate/File/FilesSize.php index ca20ad50af..167304b771 100644 --- a/libs/Zend/Validate/File/FilesSize.php +++ b/libs/Zend/Validate/File/FilesSize.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilesSize.php 20455 2010-01-20 22:54:18Z thomas $ + * @version $Id: FilesSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_Size */ -// require_once 'Zend/Validate/File/Size.php'; +require_once 'Zend/Validate/File/Size.php'; /** * Validator for the size of all files which will be validated in sum * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size @@ -47,7 +47,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size protected $_messageTemplates = array( self::TOO_BIG => "All files in sum should have a maximum size of '%max%' but '%size%' were detected", self::TOO_SMALL => "All files in sum should have a minimum size of '%min%' but '%size%' were detected", - self::NOT_READABLE => "One or more files can not be read", + self::NOT_READABLE => "One or more files can not be read" ); /** @@ -76,11 +76,14 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size } elseif (is_scalar($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); + $argv = func_get_args(); array_shift($argv); $options['max'] = array_shift($argv); @@ -104,7 +107,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size */ public function isValid($value, $file = null) { - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (is_string($value)) { $value = array($value); } @@ -128,14 +131,12 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size // limited to 2GB files $size += @filesize($files); - $this->_size = $size; + $this->_setSize($size); if (($max !== null) && ($max < $size)) { if ($this->useByteString()) { - $this->_max = $this->_toByteString($max); - $this->_size = $this->_toByteString($size); + $this->setMax($this->_toByteString($max)); $this->_throw($file, self::TOO_BIG); - $this->_max = $max; - $this->_size = $size; + $this->setMax($max); } else { $this->_throw($file, self::TOO_BIG); } @@ -145,11 +146,9 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size // Check that aggregate files are >= minimum size if (($min !== null) && ($size < $min)) { if ($this->useByteString()) { - $this->_min = $this->_toByteString($min); - $this->_size = $this->_toByteString($size); + $this->setMin($this->_toByteString($min)); $this->_throw($file, self::TOO_SMALL); - $this->_min = $min; - $this->_size = $size; + $this->setMin($min); } else { $this->_throw($file, self::TOO_SMALL); } diff --git a/libs/Zend/Validate/File/Hash.php b/libs/Zend/Validate/File/Hash.php index 6ade30cf41..d2e8c2c645 100644 --- a/libs/Zend/Validate/File/Hash.php +++ b/libs/Zend/Validate/File/Hash.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hash.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Hash.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Hash extends Zend_Validate_Abstract @@ -45,9 +45,9 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given hashes", - self::NOT_DETECTED => "A hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found" + self::DOES_NOT_MATCH => "The file '%value%' does not match the given hashes", + self::NOT_DETECTED => "There was no hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -70,11 +70,13 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $options['algorithm'] = func_get_arg(1); } @@ -116,7 +118,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract if (is_string($options)) { $options = array($options); } else if (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("False parameter given"); } @@ -129,7 +131,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract } if (!in_array($algorithm, $known)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Unknown algorithm '{$algorithm}'"); } @@ -152,7 +154,7 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/ImageSize.php b/libs/Zend/Validate/File/ImageSize.php index 54c1457500..c01ec97341 100644 --- a/libs/Zend/Validate/File/ImageSize.php +++ b/libs/Zend/Validate/File/ImageSize.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ImageSize.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: ImageSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the image size of a image file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract @@ -53,7 +53,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract self::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected", self::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected", self::NOT_DETECTED => "The size of image '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::NOT_READABLE => "The image '%value%' can not be read" ); /** @@ -127,6 +127,8 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); if (!is_array($options)) { $options = array('minwidth' => $options); } @@ -140,7 +142,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract } } } else if (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } @@ -205,7 +207,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract { if (isset($options['minwidth'])) { if (($this->_maxwidth !== null) and ($options['minwidth'] > $this->_maxwidth)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum image width must be less than or equal to the " . " maximum image width, but {$options['minwidth']} > {$this->_maxwidth}"); } @@ -213,7 +215,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if (isset($options['maxheight'])) { if (($this->_maxheight !== null) and ($options['minheight'] > $this->_maxheight)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum image height must be less than or equal to the " . " maximum image height, but {$options['minheight']} > {$this->_maxheight}"); } @@ -242,7 +244,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract { if (isset($options['maxwidth'])) { if (($this->_minwidth !== null) and ($options['maxwidth'] < $this->_minwidth)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum image width must be greater than or equal to the " . "minimum image width, but {$options['maxwidth']} < {$this->_minwidth}"); } @@ -250,7 +252,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract if (isset($options['maxheight'])) { if (($this->_minheight !== null) and ($options['maxheight'] < $this->_minheight)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum image height must be greater than or equal to the " . "minimum image height, but {$options['maxheight']} < {$this->_minwidth}"); } @@ -308,7 +310,7 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } diff --git a/libs/Zend/Validate/File/IsCompressed.php b/libs/Zend/Validate/File/IsCompressed.php index dc0d99abb5..3254d57341 100644 --- a/libs/Zend/Validate/File/IsCompressed.php +++ b/libs/Zend/Validate/File/IsCompressed.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsCompressed.php 21138 2010-02-22 22:37:11Z thomas $ + * @version $Id: IsCompressed.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType @@ -45,9 +45,9 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' is not compressed, '%type%' detected", - self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' is not compressed, '%type%' detected", + self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -60,90 +60,27 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType { if ($mimetype instanceof Zend_Config) { $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { + $mimetype = array( + 'application/x-tar', + 'application/x-cpio', + 'application/x-debian-package', + 'application/x-archive', + 'application/x-arc', + 'application/x-arj', + 'application/x-lharc', + 'application/x-lha', + 'application/x-rar', + 'application/zip', + 'application/zoo', + 'application/x-eet', + 'application/x-java-pack200', + 'application/x-compress', + 'application/x-gzip', + 'application/x-bzip2' + ); } - $temp = array(); - // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen - $default = array( - 'application/arj', - 'application/gnutar', - 'application/lha', - 'application/lzx', - 'application/vnd.ms-cab-compressed', - 'application/x-ace-compressed', - 'application/x-arc', - 'application/x-archive', - 'application/x-arj', - 'application/x-bzip', - 'application/x-bzip2', - 'application/x-cab-compressed', - 'application/x-compress', - 'application/x-compressed', - 'application/x-cpio', - 'application/x-debian-package', - 'application/x-eet', - 'application/x-gzip', - 'application/x-java-pack200', - 'application/x-lha', - 'application/x-lharc', - 'application/x-lzh', - 'application/x-lzma', - 'application/x-lzx', - 'application/x-rar', - 'application/x-sit', - 'application/x-stuffit', - 'application/x-tar', - 'application/zip', - 'application/zoo', - 'multipart/x-gzip', - ); - - if (is_array($mimetype)) { - $temp = $mimetype; - if (array_key_exists('magicfile', $temp)) { - unset($temp['magicfile']); - } - - if (array_key_exists('headerCheck', $temp)) { - unset($temp['headerCheck']); - } - - if (empty($temp)) { - $mimetype += $default; - } - } - - if (empty($mimetype)) { - $mimetype = $default; - } - - parent::__construct($mimetype); - } - - /** - * Throws an error of the given type - * Duplicates parent method due to OOP Problem with late static binding in PHP 5.2 - * - * @param string $file - * @param string $errorType - * @return false - */ - protected function _throw($file, $errorType) - { - $this->_value = $file['name']; - switch($errorType) { - case Zend_Validate_File_MimeType::FALSE_TYPE : - $errorType = self::FALSE_TYPE; - break; - case Zend_Validate_File_MimeType::NOT_DETECTED : - $errorType = self::NOT_DETECTED; - break; - case Zend_Validate_File_MimeType::NOT_READABLE : - $errorType = self::NOT_READABLE; - break; - } - - $this->_error($errorType); - return false; + $this->setMimeType($mimetype); } } diff --git a/libs/Zend/Validate/File/IsImage.php b/libs/Zend/Validate/File/IsImage.php index d602ebe763..3904af1f90 100644 --- a/libs/Zend/Validate/File/IsImage.php +++ b/libs/Zend/Validate/File/IsImage.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsImage.php 21138 2010-02-22 22:37:11Z thomas $ + * @version $Id: IsImage.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_File_MimeType */ -// require_once 'Zend/Validate/File/MimeType.php'; +require_once 'Zend/Validate/File/MimeType.php'; /** * Validator which checks if the file already exists in the directory * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType @@ -45,9 +45,9 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' is no image, '%type%' detected", - self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' is no image, '%type%' detected", + self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -60,114 +60,31 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType { if ($mimetype instanceof Zend_Config) { $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { + $mimetype = array( + 'image/x-quicktime', + 'image/jp2', + 'image/x-xpmi', + 'image/x-portable-bitmap', + 'image/x-portable-greymap', + 'image/x-portable-pixmap', + 'image/x-niff', + 'image/tiff', + 'image/png', + 'image/x-unknown', + 'image/gif', + 'image/x-ms-bmp', + 'application/dicom', + 'image/vnd.adobe.photoshop', + 'image/vnd.djvu', + 'image/x-cpi', + 'image/jpeg', + 'image/x-ico', + 'image/x-coreldraw', + 'image/svg+xml' + ); } - $temp = array(); - // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen - // http://www.iana.org/assignments/media-types/image/ - $default = array( - 'application/cdf', - 'application/dicom', - 'application/fractals', - 'application/postscript', - 'application/vnd.hp-hpgl', - 'application/vnd.oasis.opendocument.graphics', - 'application/x-cdf', - 'application/x-cmu-raster', - 'application/x-ima', - 'application/x-inventor', - 'application/x-koan', - 'application/x-portable-anymap', - 'application/x-world-x-3dmf', - 'image/bmp', - 'image/c', - 'image/cgm', - 'image/fif', - 'image/gif', - 'image/jpeg', - 'image/jpm', - 'image/jpx', - 'image/jp2', - 'image/naplps', - 'image/pjpeg', - 'image/png', - 'image/svg', - 'image/svg+xml', - 'image/tiff', - 'image/vnd.adobe.photoshop', - 'image/vnd.djvu', - 'image/vnd.fpx', - 'image/vnd.net-fpx', - 'image/x-cmu-raster', - 'image/x-cmx', - 'image/x-coreldraw', - 'image/x-cpi', - 'image/x-emf', - 'image/x-ico', - 'image/x-icon', - 'image/x-jg', - 'image/x-ms-bmp', - 'image/x-niff', - 'image/x-pict', - 'image/x-pcx', - 'image/x-portable-anymap', - 'image/x-portable-bitmap', - 'image/x-portable-greymap', - 'image/x-portable-pixmap', - 'image/x-quicktime', - 'image/x-rgb', - 'image/x-tiff', - 'image/x-unknown', - 'image/x-windows-bmp', - 'image/x-xpmi', - ); - - if (is_array($mimetype)) { - $temp = $mimetype; - if (array_key_exists('magicfile', $temp)) { - unset($temp['magicfile']); - } - - if (array_key_exists('headerCheck', $temp)) { - unset($temp['headerCheck']); - } - - if (empty($temp)) { - $mimetype += $default; - } - } - - if (empty($mimetype)) { - $mimetype = $default; - } - - parent::__construct($mimetype); - } - - /** - * Throws an error of the given type - * Duplicates parent method due to OOP Problem with late static binding in PHP 5.2 - * - * @param string $file - * @param string $errorType - * @return false - */ - protected function _throw($file, $errorType) - { - $this->_value = $file['name']; - switch($errorType) { - case Zend_Validate_File_MimeType::FALSE_TYPE : - $errorType = self::FALSE_TYPE; - break; - case Zend_Validate_File_MimeType::NOT_DETECTED : - $errorType = self::NOT_DETECTED; - break; - case Zend_Validate_File_MimeType::NOT_READABLE : - $errorType = self::NOT_READABLE; - break; - } - - $this->_error($errorType); - return false; + $this->setMimeType($mimetype); } } diff --git a/libs/Zend/Validate/File/Md5.php b/libs/Zend/Validate/File/Md5.php index e76df71917..cfbd83fb53 100644 --- a/libs/Zend/Validate/File/Md5.php +++ b/libs/Zend/Validate/File/Md5.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Md5.php 20442 2010-01-20 15:15:40Z matthew $ + * @version $Id: Md5.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the md5 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given md5 hashes", - self::NOT_DETECTED => "A md5 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given md5 hashes", + self::NOT_DETECTED => "There was no md5 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -123,7 +123,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash * Adds the md5 hash for one or multiple files * * @param string|array $options - * @param string $algorithm (Deprecated) Algorithm to use, fixed to md5 + * @param string $algorithm (Depreciated) Algorithm to use, fixed to md5 * @return Zend_Validate_File_Hash Provides a fluent interface */ public function addHash($options) @@ -161,7 +161,7 @@ class Zend_Validate_File_Md5 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/MimeType.php b/libs/Zend/Validate/File/MimeType.php index a31a7d35a3..2bf372c4fc 100644 --- a/libs/Zend/Validate/File/MimeType.php +++ b/libs/Zend/Validate/File/MimeType.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MimeType.php 21936 2010-04-18 16:23:34Z thomas $ + * @version $Id: MimeType.php 18513 2009-10-12 16:17:35Z matthew $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the mime type of a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract @@ -46,9 +46,9 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'", - self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected", - self::NOT_READABLE => "File '%value%' can not be read", + self::FALSE_TYPE => "The file '%value%' has a false mimetype of '%type%'", + self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected", + self::NOT_READABLE => "The file '%value%' can not be read" ); /** @@ -80,13 +80,6 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract protected $_magicfile; /** - * Finfo object to use - * - * @var resource - */ - protected $_finfo; - - /** * If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations * @var array */ @@ -124,18 +117,16 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract } elseif (is_string($mimetype)) { $mimetype = explode(',', $mimetype); } elseif (!is_array($mimetype)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Invalid options to validator provided"); } if (isset($mimetype['magicfile'])) { $this->setMagicFile($mimetype['magicfile']); - unset($mimetype['magicfile']); } if (isset($mimetype['headerCheck'])) { - $this->enableHeaderCheck($mimetype['headerCheck']); - unset($mimetype['headerCheck']); + $this->enableHeaderCheck(true); } $this->setMimeType($mimetype); @@ -148,62 +139,33 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract */ public function getMagicFile() { - if (null === $this->_magicfile) { - if (!empty($_ENV['MAGIC'])) { - $this->setMagicFile($_ENV['MAGIC']); - } elseif (!(@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1)) { - // require_once 'Zend/Validate/Exception.php'; - foreach ($this->_magicFiles as $file) { - // supressing errors which are thrown due to openbase_dir restrictions - try { - $this->setMagicFile($file); - if ($this->_magicfile !== null) { - break; - } - } catch (Zend_Validate_Exception $e) { - // Intentionally, catch and fall through - } + if (null === $this->_magicfile && empty($_ENV['MAGIC'])) { + foreach ($this->_magicFiles as $file) { + if (file_exists($file)) { + $this->setMagicFile($file); + break; } } - - if ($this->_magicfile === null) { - $this->_magicfile = false; - } } - return $this->_magicfile; } /** * Sets the magicfile to use * if null, the MAGIC constant from php is used - * if the MAGIC file is errorous, no file will be set * * @param string $file - * @throws Zend_Validate_Exception When finfo can not read the magicfile * @return Zend_Validate_File_MimeType Provides fluid interface */ public function setMagicFile($file) { if (empty($file)) { $this->_magicfile = null; - } else if (!(class_exists('finfo', false))) { - $this->_magicfile = null; - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Magicfile can not be set. There is no finfo extension installed'); } else if (!is_readable($file)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('The given magicfile can not be read'); } else { - $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - $this->_finfo = @finfo_open($const, $file); - if (empty($this->_finfo)) { - $this->_finfo = null; - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('The given magicfile is not accepted by finfo'); - } else { - $this->_magicfile = $file; - } + $this->_magicfile = (string) $file; } return $this; @@ -275,7 +237,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract if (is_string($mimetype)) { $mimetype = explode(',', $mimetype); } elseif (!is_array($mimetype)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Invalid options to validator provided"); } @@ -324,7 +286,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract } // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } @@ -332,27 +294,24 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - if (!empty($mimefile) && empty($this->_finfo)) { - $this->_finfo = @finfo_open($const, $mimefile); - } - - if (empty($this->_finfo)) { - $this->_finfo = @finfo_open($const); + if (!empty($mimefile)) { + $mime = new finfo($const, $mimefile); + } else { + $mime = new finfo($const); } - $this->_type = null; - if (!empty($this->_finfo)) { - $this->_type = finfo_file($this->_finfo, $value); + if ($mime !== false) { + $this->_type = $mime->file($value); } + unset($mime); } - if (empty($this->_type) && - (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { + if (empty($this->_type)) { + if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { $this->_type = mime_content_type($value); - } - - if (empty($this->_type) && $this->_headerCheck) { - $this->_type = $file['type']; + } elseif ($this->_headerCheck) { + $this->_type = $file['type']; + } } if (empty($this->_type)) { @@ -366,7 +325,6 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract $types = explode('/', $this->_type); $types = array_merge($types, explode('-', $this->_type)); - $types = array_merge($types, explode(';', $this->_type)); foreach($mimetype as $mime) { if (in_array($mime, $types)) { return true; diff --git a/libs/Zend/Validate/File/NotExists.php b/libs/Zend/Validate/File/NotExists.php index a5afe94686..0cc3c87ac9 100644 --- a/libs/Zend/Validate/File/NotExists.php +++ b/libs/Zend/Validate/File/NotExists.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NotExists.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: NotExists.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Exists */ -// require_once 'Zend/Validate/File/Exists.php'; +require_once 'Zend/Validate/File/Exists.php'; /** * Validator which checks if the destination file does not exist * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists @@ -43,7 +43,7 @@ class Zend_Validate_File_NotExists extends Zend_Validate_File_Exists * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_EXIST => "File '%value%' exists", + self::DOES_EXIST => "The file '%value%' does exist" ); /** diff --git a/libs/Zend/Validate/File/Sha1.php b/libs/Zend/Validate/File/Sha1.php index 1b5f8ee622..9dd4418d71 100644 --- a/libs/Zend/Validate/File/Sha1.php +++ b/libs/Zend/Validate/File/Sha1.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Sha1.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: Sha1.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Hash */ -// require_once 'Zend/Validate/File/Hash.php'; +require_once 'Zend/Validate/File/Hash.php'; /** * Validator for the sha1 hash of given files * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash @@ -45,9 +45,9 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash * @var array Error message templates */ protected $_messageTemplates = array( - self::DOES_NOT_MATCH => "File '%value%' does not match the given sha1 hashes", - self::NOT_DETECTED => "A sha1 hash could not be evaluated for the given file", - self::NOT_FOUND => "File '%value%' could not be found", + self::DOES_NOT_MATCH => "The file '%value%' does not match the given sha1 hashes", + self::NOT_DETECTED => "There was no sha1 hash detected for the given file", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -72,7 +72,7 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash } elseif (is_scalar($options)) { $options = array('hash1' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Invalid options to validator provided'); } @@ -159,7 +159,7 @@ class Zend_Validate_File_Sha1 extends Zend_Validate_File_Hash public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } diff --git a/libs/Zend/Validate/File/Size.php b/libs/Zend/Validate/File/Size.php index a3431cfae1..4c41178966 100644 --- a/libs/Zend/Validate/File/Size.php +++ b/libs/Zend/Validate/File/Size.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Size.php 20455 2010-01-20 22:54:18Z thomas $ + * @version $Id: Size.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the maximum size of a file up to a max of 2GB * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Size extends Zend_Validate_Abstract @@ -48,7 +48,7 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract protected $_messageTemplates = array( self::TOO_BIG => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected", self::TOO_SMALL => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected", - self::NOT_FOUND => "File '%value%' could not be found", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -107,11 +107,13 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract } elseif (is_string($options) || is_numeric($options)) { $options = array('max' => $options); } elseif (!is_array($options)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } if (1 < func_num_args()) { +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $argv = func_get_args(); array_shift($argv); $options['max'] = array_shift($argv); @@ -181,14 +183,14 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function setMin($min) { if (!is_string($min) and !is_numeric($min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $this->_fromByteString($min); $max = $this->getMax(true); if (($max !== null) && ($min > $max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum filesize, but $min >" . " $max"); } @@ -223,14 +225,14 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function setMax($max) { if (!is_string($max) && !is_numeric($max)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $max = (integer) $this->_fromByteString($max); $min = $this->getMin(true); if (($min !== null) && ($max < $min)) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum filesize, but " . "$max < $min"); } @@ -274,14 +276,13 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } // limited to 4GB files - $size = sprintf("%u", @filesize($value)); - $this->_size = $size; + $size = sprintf("%u", @filesize($value)); // Check to see if it's smaller than min size $min = $this->getMin(true); diff --git a/libs/Zend/Validate/File/Upload.php b/libs/Zend/Validate/File/Upload.php index 9a12f301d1..fd1bdfe754 100644 --- a/libs/Zend/Validate/File/Upload.php +++ b/libs/Zend/Validate/File/Upload.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Upload.php 20431 2010-01-19 21:36:05Z thomas $ + * @version $Id: Upload.php 18148 2009-09-16 19:27:43Z thomas $ */ /** * @see Zend_Validate_Abstract */ -// require_once 'Zend/Validate/Abstract.php'; +require_once 'Zend/Validate/Abstract.php'; /** * Validator for the maximum size of a file up to a max of 2GB * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_Upload extends Zend_Validate_Abstract @@ -53,16 +53,16 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract * @var array Error message templates */ protected $_messageTemplates = array( - self::INI_SIZE => "File '%value%' exceeds the defined ini size", - self::FORM_SIZE => "File '%value%' exceeds the defined form size", - self::PARTIAL => "File '%value%' was only partially uploaded", - self::NO_FILE => "File '%value%' was not uploaded", - self::NO_TMP_DIR => "No temporary directory was found for file '%value%'", - self::CANT_WRITE => "File '%value%' can't be written", - self::EXTENSION => "A PHP extension returned an error while uploading the file '%value%'", - self::ATTACK => "File '%value%' was illegally uploaded. This could be a possible attack", - self::FILE_NOT_FOUND => "File '%value%' was not found", - self::UNKNOWN => "Unknown error while uploading file '%value%'" + self::INI_SIZE => "The file '%value%' exceeds the defined ini size", + self::FORM_SIZE => "The file '%value%' exceeds the defined form size", + self::PARTIAL => "The file '%value%' was only partially uploaded", + self::NO_FILE => "The file '%value%' was not uploaded", + self::NO_TMP_DIR => "No temporary directory was found for the file '%value%'", + self::CANT_WRITE => "The file '%value%' can't be written", + self::EXTENSION => "The extension returned an error while uploading the file '%value%'", + self::ATTACK => "The file '%value%' was illegal uploaded, possible attack", + self::FILE_NOT_FOUND => "The file '%value%' was not found", + self::UNKNOWN => "Unknown error while uploading the file '%value%'" ); /** @@ -112,7 +112,7 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract } if (count($return) === 0) { - // require_once 'Zend/Validate/Exception.php'; + require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The file '$file' was not found"); } diff --git a/libs/Zend/Validate/File/WordCount.php b/libs/Zend/Validate/File/WordCount.php index e69bf1db79..b5249532d3 100644 --- a/libs/Zend/Validate/File/WordCount.php +++ b/libs/Zend/Validate/File/WordCount.php @@ -14,22 +14,22 @@ * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: WordCount.php 20358 2010-01-17 19:03:49Z thomas $ + * @version $Id: WordCount.php 16971 2009-07-22 18:05:45Z mikaelkael $ */ /** * @see Zend_Validate_File_Count */ -// require_once 'Zend/Validate/File/Count.php'; +require_once 'Zend/Validate/File/Count.php'; /** * Validator for counting all words in a file * * @category Zend * @package Zend_Validate - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count @@ -48,7 +48,7 @@ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count protected $_messageTemplates = array( self::TOO_MUCH => "Too much words, maximum '%max%' are allowed but '%count%' were counted", self::TOO_LESS => "Too less words, minimum '%min%' are expected but '%count%' were counted", - self::NOT_FOUND => "File '%value%' could not be found", + self::NOT_FOUND => "The file '%value%' could not be found" ); /** @@ -64,7 +64,7 @@ class Zend_Validate_File_WordCount extends Zend_Validate_File_Count public function isValid($value, $file = null) { // Is file readable ? - // require_once 'Zend/Loader.php'; + require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } |