Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Validate/File')
-rw-r--r--libs/Zend/Validate/File/Count.php28
-rw-r--r--libs/Zend/Validate/File/Crc32.php12
-rw-r--r--libs/Zend/Validate/File/ExcludeExtension.php10
-rw-r--r--libs/Zend/Validate/File/ExcludeMimeType.php6
-rw-r--r--libs/Zend/Validate/File/Exists.php8
-rw-r--r--libs/Zend/Validate/File/Extension.php12
-rw-r--r--libs/Zend/Validate/File/FilesSize.php25
-rw-r--r--libs/Zend/Validate/File/Hash.php14
-rw-r--r--libs/Zend/Validate/File/ImageSize.php10
-rw-r--r--libs/Zend/Validate/File/IsCompressed.php99
-rw-r--r--libs/Zend/Validate/File/IsImage.php107
-rw-r--r--libs/Zend/Validate/File/Md5.php14
-rw-r--r--libs/Zend/Validate/File/MimeType.php43
-rw-r--r--libs/Zend/Validate/File/NotExists.php8
-rw-r--r--libs/Zend/Validate/File/Sha1.php12
-rw-r--r--libs/Zend/Validate/File/Size.php13
-rw-r--r--libs/Zend/Validate/File/Upload.php26
-rw-r--r--libs/Zend/Validate/File/WordCount.php8
18 files changed, 279 insertions, 176 deletions
diff --git a/libs/Zend/Validate/File/Count.php b/libs/Zend/Validate/File/Count.php
index f2dfac7413..e7519b0d63 100644
--- a/libs/Zend/Validate/File/Count.php
+++ b/libs/Zend/Validate/File/Count.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Count.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Count.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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_MUCH = 'fileCountTooMuch';
- const TOO_LESS = 'fileCountTooLess';
+ const TOO_MANY = 'fileCountTooMany';
+ const TOO_FEW = 'fileCountTooFew';
/**#@-*/
/**
* @var array Error message templates
*/
protected $_messageTemplates = array(
- 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"
+ 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",
);
/**
@@ -115,8 +115,6 @@ class Zend_Validate_File_Count 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 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);
}
@@ -243,14 +241,22 @@ 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'];
+ }
+
$this->addFile($value);
$this->_count = count($this->_files);
if (($this->_max !== null) && ($this->_count > $this->_max)) {
- return $this->_throw($file, self::TOO_MUCH);
+ return $this->_throw($file, self::TOO_MANY);
}
if (($this->_min !== null) && ($this->_count < $this->_min)) {
- return $this->_throw($file, self::TOO_LESS);
+ return $this->_throw($file, self::TOO_FEW);
}
return true;
diff --git a/libs/Zend/Validate/File/Crc32.php b/libs/Zend/Validate/File/Crc32.php
index fd46d81b6b..e7c06d6035 100644
--- a/libs/Zend/Validate/File/Crc32.php
+++ b/libs/Zend/Validate/File/Crc32.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Crc32.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Crc32.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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",
);
/**
diff --git a/libs/Zend/Validate/File/ExcludeExtension.php b/libs/Zend/Validate/File/ExcludeExtension.php
index 74264de98c..b31e372747 100644
--- a/libs/Zend/Validate/File/ExcludeExtension.php
+++ b/libs/Zend/Validate/File/ExcludeExtension.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: ExcludeExtension.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: ExcludeExtension.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Extension.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' has a false extension",
- self::NOT_FOUND => "The file '%value%' was not found"
+ self::FALSE_EXTENSION => "File '%value%' has a false extension",
+ self::NOT_FOUND => "File '%value%' could not be found",
);
/**
diff --git a/libs/Zend/Validate/File/ExcludeMimeType.php b/libs/Zend/Validate/File/ExcludeMimeType.php
index 4984b79cfb..22f74fba8b 100644
--- a/libs/Zend/Validate/File/ExcludeMimeType.php
+++ b/libs/Zend/Validate/File/ExcludeMimeType.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: ExcludeMimeType.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: ExcludeMimeType.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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
diff --git a/libs/Zend/Validate/File/Exists.php b/libs/Zend/Validate/File/Exists.php
index 835b4c2c70..86a21780fb 100644
--- a/libs/Zend/Validate/File/Exists.php
+++ b/libs/Zend/Validate/File/Exists.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Exists.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Exists.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' does not exist"
+ self::DOES_NOT_EXIST => "File '%value%' does not exist",
);
/**
diff --git a/libs/Zend/Validate/File/Extension.php b/libs/Zend/Validate/File/Extension.php
index 58ab0b21af..021b5e03bb 100644
--- a/libs/Zend/Validate/File/Extension.php
+++ b/libs/Zend/Validate/File/Extension.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Extension.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Extension.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' has a false extension",
- self::NOT_FOUND => "The file '%value%' was not found"
+ self::FALSE_EXTENSION => "File '%value%' has a false extension",
+ self::NOT_FOUND => "File '%value%' could not be found",
);
/**
@@ -81,8 +81,6 @@ 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);
}
diff --git a/libs/Zend/Validate/File/FilesSize.php b/libs/Zend/Validate/File/FilesSize.php
index 167304b771..05c660b81b 100644
--- a/libs/Zend/Validate/File/FilesSize.php
+++ b/libs/Zend/Validate/File/FilesSize.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: FilesSize.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: FilesSize.php 20455 2010-01-20 22:54:18Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Size.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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",
);
/**
@@ -81,9 +81,6 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size
}
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);
@@ -131,12 +128,14 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size
// limited to 2GB files
$size += @filesize($files);
- $this->_setSize($size);
+ $this->_size = $size;
if (($max !== null) && ($max < $size)) {
if ($this->useByteString()) {
- $this->setMax($this->_toByteString($max));
+ $this->_max = $this->_toByteString($max);
+ $this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_BIG);
- $this->setMax($max);
+ $this->_max = $max;
+ $this->_size = $size;
} else {
$this->_throw($file, self::TOO_BIG);
}
@@ -146,9 +145,11 @@ 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->setMin($this->_toByteString($min));
+ $this->_min = $this->_toByteString($min);
+ $this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_SMALL);
- $this->setMin($min);
+ $this->_min = $min;
+ $this->_size = $size;
} else {
$this->_throw($file, self::TOO_SMALL);
}
diff --git a/libs/Zend/Validate/File/Hash.php b/libs/Zend/Validate/File/Hash.php
index d2e8c2c645..2b20cac699 100644
--- a/libs/Zend/Validate/File/Hash.php
+++ b/libs/Zend/Validate/File/Hash.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Hash.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Hash.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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"
);
/**
@@ -75,8 +75,6 @@ class Zend_Validate_File_Hash 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 constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
$options['algorithm'] = func_get_arg(1);
}
diff --git a/libs/Zend/Validate/File/ImageSize.php b/libs/Zend/Validate/File/ImageSize.php
index c01ec97341..0d8a4fa74e 100644
--- a/libs/Zend/Validate/File/ImageSize.php
+++ b/libs/Zend/Validate/File/ImageSize.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: ImageSize.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: ImageSize.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The image '%value%' can not be read"
+ self::NOT_READABLE => "File '%value%' can not be read",
);
/**
@@ -127,8 +127,6 @@ 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);
}
diff --git a/libs/Zend/Validate/File/IsCompressed.php b/libs/Zend/Validate/File/IsCompressed.php
index 3254d57341..d2b8a25430 100644
--- a/libs/Zend/Validate/File/IsCompressed.php
+++ b/libs/Zend/Validate/File/IsCompressed.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: IsCompressed.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: IsCompressed.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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",
);
/**
@@ -60,27 +60,74 @@ 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'
- );
}
- $this->setMimeType($mimetype);
+ $temp = array();
+ $default = 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'
+ );
+
+ 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;
}
}
diff --git a/libs/Zend/Validate/File/IsImage.php b/libs/Zend/Validate/File/IsImage.php
index 3904af1f90..77756277f0 100644
--- a/libs/Zend/Validate/File/IsImage.php
+++ b/libs/Zend/Validate/File/IsImage.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: IsImage.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: IsImage.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/MimeType.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ self::FALSE_TYPE => "File '%value%' is no image, '%type%' detected",
+ self::NOT_DETECTED => "The mimetype of file '%value%' could not been detected",
+ self::NOT_READABLE => "File '%value%' can not be read",
);
/**
@@ -60,31 +60,78 @@ 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'
- );
}
- $this->setMimeType($mimetype);
+ $temp = array();
+ $default = 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'
+ );
+
+ 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;
}
}
diff --git a/libs/Zend/Validate/File/Md5.php b/libs/Zend/Validate/File/Md5.php
index cfbd83fb53..80fed0bd26 100644
--- a/libs/Zend/Validate/File/Md5.php
+++ b/libs/Zend/Validate/File/Md5.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Md5.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: Md5.php 20442 2010-01-20 15:15:40Z matthew $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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",
);
/**
@@ -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 (Depreciated) Algorithm to use, fixed to md5
+ * @param string $algorithm (Deprecated) Algorithm to use, fixed to md5
* @return Zend_Validate_File_Hash Provides a fluent interface
*/
public function addHash($options)
diff --git a/libs/Zend/Validate/File/MimeType.php b/libs/Zend/Validate/File/MimeType.php
index 2bf372c4fc..a4b4ec58aa 100644
--- a/libs/Zend/Validate/File/MimeType.php
+++ b/libs/Zend/Validate/File/MimeType.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: MimeType.php 18513 2009-10-12 16:17:35Z matthew $
+ * @version $Id: MimeType.php 20505 2010-01-21 21:40:23Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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",
);
/**
@@ -123,10 +123,12 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
if (isset($mimetype['magicfile'])) {
$this->setMagicFile($mimetype['magicfile']);
+ unset($mimetype['magicfile']);
}
if (isset($mimetype['headerCheck'])) {
- $this->enableHeaderCheck(true);
+ $this->enableHeaderCheck($mimetype['headerCheck']);
+ unset($mimetype['headerCheck']);
}
$this->setMimeType($mimetype);
@@ -139,14 +141,20 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
*/
public function getMagicFile()
{
- if (null === $this->_magicfile && empty($_ENV['MAGIC'])) {
- foreach ($this->_magicFiles as $file) {
- if (file_exists($file)) {
- $this->setMagicFile($file);
- break;
+ if (null === $this->_magicfile) {
+ if (!empty($_ENV['MAGIC'])) {
+ $this->setMagicFile($_ENV['MAGIC']);
+ } elseif (!(@ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1)) {
+ foreach ($this->_magicFiles as $file) {
+ // supressing errors which are thrown due to openbase_dir restrictions
+ if (@file_exists($file)) {
+ $this->setMagicFile($file);
+ break;
+ }
}
}
}
+
return $this->_magicfile;
}
@@ -306,12 +314,13 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract
unset($mime);
}
- if (empty($this->_type)) {
- if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) {
+ if (empty($this->_type) &&
+ (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) {
$this->_type = mime_content_type($value);
- } elseif ($this->_headerCheck) {
- $this->_type = $file['type'];
- }
+ }
+
+ if (empty($this->_type) && $this->_headerCheck) {
+ $this->_type = $file['type'];
}
if (empty($this->_type)) {
diff --git a/libs/Zend/Validate/File/NotExists.php b/libs/Zend/Validate/File/NotExists.php
index 0cc3c87ac9..87ebb827b4 100644
--- a/libs/Zend/Validate/File/NotExists.php
+++ b/libs/Zend/Validate/File/NotExists.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: NotExists.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: NotExists.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Exists.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' does exist"
+ self::DOES_EXIST => "File '%value%' exists",
);
/**
diff --git a/libs/Zend/Validate/File/Sha1.php b/libs/Zend/Validate/File/Sha1.php
index 9dd4418d71..2157bfb26c 100644
--- a/libs/Zend/Validate/File/Sha1.php
+++ b/libs/Zend/Validate/File/Sha1.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Sha1.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: Sha1.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Hash.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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"
+ 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",
);
/**
diff --git a/libs/Zend/Validate/File/Size.php b/libs/Zend/Validate/File/Size.php
index 4c41178966..bfd02aa80b 100644
--- a/libs/Zend/Validate/File/Size.php
+++ b/libs/Zend/Validate/File/Size.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Size.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Size.php 20455 2010-01-20 22:54:18Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' could not be found"
+ self::NOT_FOUND => "File '%value%' could not be found",
);
/**
@@ -112,8 +112,6 @@ class Zend_Validate_File_Size 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 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);
@@ -282,7 +280,8 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract
}
// limited to 4GB files
- $size = sprintf("%u", @filesize($value));
+ $size = sprintf("%u", @filesize($value));
+ $this->_size = $size;
// 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 fd1bdfe754..85f408c735 100644
--- a/libs/Zend/Validate/File/Upload.php
+++ b/libs/Zend/Validate/File/Upload.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Upload.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: Upload.php 20431 2010-01-19 21:36:05Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/Abstract.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "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%'"
+ 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%'"
);
/**
diff --git a/libs/Zend/Validate/File/WordCount.php b/libs/Zend/Validate/File/WordCount.php
index b5249532d3..9936cb662f 100644
--- a/libs/Zend/Validate/File/WordCount.php
+++ b/libs/Zend/Validate/File/WordCount.php
@@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: WordCount.php 16971 2009-07-22 18:05:45Z mikaelkael $
+ * @version $Id: WordCount.php 20358 2010-01-17 19:03:49Z thomas $
*/
/**
@@ -29,7 +29,7 @@ require_once 'Zend/Validate/File/Count.php';
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 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 => "The file '%value%' could not be found"
+ self::NOT_FOUND => "File '%value%' could not be found",
);
/**