PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / libs / Zend / Validate / File / FilesSize.php
matomo / app / libs / Zend / Validate / File Last commit date
Count.php 6 years ago Crc32.php 6 years ago ExcludeExtension.php 6 years ago ExcludeMimeType.php 6 years ago Exists.php 6 years ago Extension.php 6 years ago FilesSize.php 6 years ago Hash.php 6 years ago ImageSize.php 6 years ago IsCompressed.php 6 years ago IsImage.php 6 years ago Md5.php 6 years ago MimeType.php 6 years ago NotExists.php 6 years ago Sha1.php 6 years ago Size.php 6 years ago Upload.php 6 years ago WordCount.php 6 years ago
FilesSize.php
165 lines
1 <?php
2 /**
3 * Zend Framework
4 *
5 * LICENSE
6 *
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category Zend
16 * @package Zend_Validate
17 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 * @version $Id: FilesSize.php 23775 2011-03-01 17:25:24Z ralph $
20 */
21
22 /**
23 * @see Zend_Validate_File_Size
24 */
25 // require_once 'Zend/Validate/File/Size.php';
26
27 /**
28 * Validator for the size of all files which will be validated in sum
29 *
30 * @category Zend
31 * @package Zend_Validate
32 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
34 */
35 class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size
36 {
37 /**
38 * @const string Error constants
39 */
40 const TOO_BIG = 'fileFilesSizeTooBig';
41 const TOO_SMALL = 'fileFilesSizeTooSmall';
42 const NOT_READABLE = 'fileFilesSizeNotReadable';
43
44 /**
45 * @var array Error message templates
46 */
47 protected $_messageTemplates = array(
48 self::TOO_BIG => "All files in sum should have a maximum size of '%max%' but '%size%' were detected",
49 self::TOO_SMALL => "All files in sum should have a minimum size of '%min%' but '%size%' were detected",
50 self::NOT_READABLE => "One or more files can not be read",
51 );
52
53 /**
54 * Internal file array
55 *
56 * @var array
57 */
58 protected $_files;
59
60 /**
61 * Sets validator options
62 *
63 * Min limits the used diskspace for all files, when used with max=null it is the maximum filesize
64 * It also accepts an array with the keys 'min' and 'max'
65 *
66 * @param integer|array|Zend_Config $options Options for this validator
67 * @return void
68 */
69 public function __construct($options)
70 {
71 $this->_files = array();
72 $this->_setSize(0);
73
74 if ($options instanceof Zend_Config) {
75 $options = $options->toArray();
76 } elseif (is_scalar($options)) {
77 $options = array('max' => $options);
78 } elseif (!is_array($options)) {
79 // require_once 'Zend/Validate/Exception.php';
80 throw new Zend_Validate_Exception('Invalid options to validator provided');
81 }
82
83 if (1 < func_num_args()) {
84 $argv = func_get_args();
85 array_shift($argv);
86 $options['max'] = array_shift($argv);
87 if (!empty($argv)) {
88 $options['bytestring'] = array_shift($argv);
89 }
90 }
91
92 parent::__construct($options);
93 }
94
95 /**
96 * Defined by Zend_Validate_Interface
97 *
98 * Returns true if and only if the disk usage of all files is at least min and
99 * not bigger than max (when max is not null).
100 *
101 * @param string|array $value Real file to check for size
102 * @param array $file File data from Zend_File_Transfer
103 * @return boolean
104 */
105 public function isValid($value, $file = null)
106 {
107 // require_once 'Zend/Loader.php';
108 if (is_string($value)) {
109 $value = array($value);
110 }
111
112 $min = $this->getMin(true);
113 $max = $this->getMax(true);
114 $size = $this->_getSize();
115 foreach ($value as $files) {
116 // Is file readable ?
117 if (!Zend_Loader::isReadable($files)) {
118 $this->_throw($file, self::NOT_READABLE);
119 continue;
120 }
121
122 if (!isset($this->_files[$files])) {
123 $this->_files[$files] = $files;
124 } else {
125 // file already counted... do not count twice
126 continue;
127 }
128
129 // limited to 2GB files
130 $size += @filesize($files);
131 $this->_size = $size;
132 if (($max !== null) && ($max < $size)) {
133 if ($this->useByteString()) {
134 $this->_max = $this->_toByteString($max);
135 $this->_size = $this->_toByteString($size);
136 $this->_throw($file, self::TOO_BIG);
137 $this->_max = $max;
138 $this->_size = $size;
139 } else {
140 $this->_throw($file, self::TOO_BIG);
141 }
142 }
143 }
144
145 // Check that aggregate files are >= minimum size
146 if (($min !== null) && ($size < $min)) {
147 if ($this->useByteString()) {
148 $this->_min = $this->_toByteString($min);
149 $this->_size = $this->_toByteString($size);
150 $this->_throw($file, self::TOO_SMALL);
151 $this->_min = $min;
152 $this->_size = $size;
153 } else {
154 $this->_throw($file, self::TOO_SMALL);
155 }
156 }
157
158 if (count($this->_messages) > 0) {
159 return false;
160 }
161
162 return true;
163 }
164 }
165