source: trunk/lib/Validator.inc.php @ 575

Last change on this file since 575 was 575, checked in by anonymous, 7 years ago

Changed LOG_ levels.

File size: 23.7 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2012 Strangecode, LLC
6 *
7 * This file is part of The Strangecode Codebase.
8 *
9 * The Strangecode Codebase is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * The Strangecode Codebase is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/**
24 * Validator.inc.php
25 *
26 * The Validator class provides a methods for validating input against different criteria.
27 * All functions return true if the input passes the test.
28 *
29 * @author    Quinn Comendant <quinn@strangecode.com>
30 * @version   1.0
31 */
32
33class Validator
34{
35
36    // Known credit card types.
37    const CC_TYPE_VISA = 1;
38    const CC_TYPE_MASTERCARD = 2;
39    const CC_TYPE_AMEX = 3;
40    const CC_TYPE_DISCOVER = 4;
41    const CC_TYPE_DINERS = 5;
42    const CC_TYPE_JCB = 6;
43
44    // Validator::validateEmail() return types.
45    const EMAIL_SUCCESS = 0;
46    const EMAIL_REGEX_FAIL = 1;
47    const EMAIL_LENGTH_FAIL = 2;
48    const EMAIL_MX_FAIL = 3;
49
50    // Validator::validatePhone() return types.
51    const PHONE_SUCCESS = 0;
52    const PHONE_REGEX_FAIL = 1;
53    const PHONE_LENGTH_FAIL = 2;
54
55    /**
56    * Check if a value is not empty (the opposite of isEmpty()).
57    *
58    * @param  string $val The input data to validate.
59    * @param  const  $type  A LOG_* constant (see App->logMsg())
60    * @param  string $file  Filename to log (usually __FILE__)
61    * @param  int    $line  Line number to log (usually __LINE__)
62    * @return bool   true if form is not empty, false otherwise.
63    */
64    static public function notEmpty($val, $type=LOG_DEBUG, $file=null, $line=null)
65    {
66        $app =& App::getInstance();
67        if (is_array($val)) {
68            if (!empty($val)) {
69                return true;
70            } else {
71                $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
72                return false;
73            }
74        } else {
75            if ('' != trim((string)$val)) {
76                return true;
77            } else {
78                $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
79                return false;
80            }
81        }
82    }
83
84    /*
85    * We were using the isEmpty method *wrong* for years and should have been using notEmpty becuase it is more grammatically correct.
86    * Because the only use is to ensure a value is not empty, we're simply going to alias this method to notEmpty().
87    *
88    * @param  string $val   The input data to validate.
89    * @param  const  $type  A LOG_* constant (see App->logMsg())
90    * @param  string $file  Filename to log (usually __FILE__)
91    * @param  int    $line  Line number to log (usually __LINE__)
92    * @return bool   true if form is empty, false otherwise.
93    */
94    static public function isEmpty($val, $type=LOG_DEBUG, $file=null, $line=null)
95    {
96        return !self::notEmpty($val, $type, $file, $line);
97    }
98
99    /**
100    * Check whether input is a string.
101    *
102    * @param  string $val The input data to validate.
103    * @param  const  $type  A LOG_* constant (see App->logMsg())
104    * @param  string $file  Filename to log (usually __FILE__)
105    * @param  int    $line  Line number to log (usually __LINE__)
106    * @return bool   true if form is a string, false otherwise.
107    */
108    static public function isString($val, $type=LOG_DEBUG, $file=null, $line=null)
109    {
110        $app =& App::getInstance();
111        if ('' == trim((string)$val) || is_string($val)) {
112            return true;
113        } else {
114            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
115            return false;
116        }
117    }
118
119    /**
120    * Check whether input is a number. Allows negative numbers.
121    *
122    * @param  string $val The input data to validate.
123    * @param  const  $type  A LOG_* constant (see App->logMsg())
124    * @param  string $file  Filename to log (usually __FILE__)
125    * @param  int    $line  Line number to log (usually __LINE__)
126    * @return bool   True if no errors found, false otherwise.
127    */
128    static public function isNumber($val, $type=LOG_DEBUG, $file=null, $line=null)
129    {
130        $app =& App::getInstance();
131        if ('' == trim((string)$val) || is_numeric($val)) {
132            return true;
133        } else {
134            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
135            return false;
136        }
137    }
138
139    /**
140    * addError if input is NOT an integer. Don't just use is_int() because the
141    * data coming from the user is *really* a string.
142    *
143    * @param  string $val The input data to validate.
144    * @param  const  $type  A LOG_* constant (see App->logMsg())
145    * @param  string $file  Filename to log (usually __FILE__)
146    * @param  int    $line  Line number to log (usually __LINE__)
147    * @return bool   true if value is an integer
148    */
149    static public function isInteger($val, $negative_ok=false, $type=LOG_DEBUG, $file=null, $line=null)
150    {
151        $app =& App::getInstance();
152        $pattern = $negative_ok ? '/^-?[[:digit:]]+$/' : '/^[[:digit:]]+$/';
153        if ('' == trim((string)$val) || (is_numeric($val) && preg_match($pattern, $val))) {
154            return true;
155        } else {
156            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
157            return false;
158        }
159    }
160
161    /**
162    * Check whether input is a float. Don't just use is_float() because the
163    * data coming from the user is *really* a string. Integers will also
164    * pass this test.
165    *
166    * @param  string $val The input data to validate.
167    * @param  bool $negative_ok  If the value can be unsigned.
168    * @param  const  $type  A LOG_* constant (see App->logMsg())
169    * @param  string $file  Filename to log (usually __FILE__)
170    * @param  int    $line  Line number to log (usually __LINE__)
171    * @return bool   true if value is a float
172    */
173    static public function isFloat($val, $negative_ok=false, $type=LOG_DEBUG, $file=null, $line=null)
174    {
175        $app =& App::getInstance();
176        $pattern = $negative_ok ? '/^-?[[:digit:]]*(?:\.?[[:digit:]]+)$/' : '/^[[:digit:]]*(?:\.?[[:digit:]]+)$/';
177        if ('' == trim((string)$val) || (is_numeric($val) && preg_match($pattern, $val))) {
178            return true;
179        } else {
180            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
181            return false;
182        }
183    }
184
185    /**
186    * Check whether input is a Decimal or Fixed type. Check values to be stored in mysql decimal, numeric, num, or fixed types.
187    * Note: some integers and floats will also pass this test.
188    * https://dev.mysql.com/doc/refman/5.5/en/fixed-point-types.html
189    *
190    * @param  string $val The input data to validate.
191    * @param  bool $negative_ok  If the value can be unsigned.
192    * @param  int  $max    Total max number of digits (for mysql max is 65).
193    * @param  int  $dec    Total max number of digits after the decimal place (for mysql max is 30).
194    * @param  const  $type  A LOG_* constant (see App->logMsg())
195    * @param  string $file  Filename to log (usually __FILE__)
196    * @param  int    $line  Line number to log (usually __LINE__)
197    * @return bool   true if value is a float
198    */
199    static public function isDecimal($val, $max=10, $dec=2, $negative_ok=false, $type=LOG_DEBUG, $file=null, $line=null)
200    {
201        $app =& App::getInstance();
202        if ('' == trim((string)$val)) {
203            return true;
204        }
205        if (!$negative_ok && is_numeric($val) && $val < 0) {
206            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
207            return false;
208        }
209        // Get the length of the part after any decimal point, or zero.
210        $num_parts = explode('.', $val);
211        $dec_count = sizeof($num_parts) <= 1 ? 0 : mb_strlen(end($num_parts));
212        // Must be numeric, total digits <= $max, dec digits <= $dec.
213        if (is_numeric($val) && mb_strlen(str_replace(['-', '.'], '', $val)) <= $max && $dec_count <= $dec) {
214            return true;
215        } else {
216            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
217            return false;
218        }
219    }
220
221    /**
222    * Check whether input is an array.
223    *
224    * @param  string $val The input data to validate.
225    * @param  const  $type  A LOG_* constant (see App->logMsg())
226    * @param  string $file  Filename to log (usually __FILE__)
227    * @param  int    $line  Line number to log (usually __LINE__)
228    * @return bool   true if value is a float
229    */
230    static public function isArray($val, $type=LOG_DEBUG, $file=null, $line=null)
231    {
232        $app =& App::getInstance();
233        if ((is_string($val) && '' == trim((string)$val)) || is_array($val)) {
234            return true;
235        } else {
236            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
237            return false;
238        }
239    }
240
241    /**
242    * Check whether input matches the specified perl regular expression
243    * pattern.
244    *
245    * @param  string $val The input data to validate.
246    * @param  int    $regex            PREG that the string must match
247    * @param  bool   $valid_on_match   Set to true to be valid if match, or false to be valid if the match fails.
248    * @param  const  $type  A LOG_* constant (see App->logMsg())
249    * @param  string $file  Filename to log (usually __FILE__)
250    * @param  int    $line  Line number to log (usually __LINE__)
251    * @return bool   true if value passes regex test
252    */
253    static public function checkRegex($val, $regex, $valid_on_match=true, $type=LOG_DEBUG, $file=null, $line=null)
254    {
255        $app =& App::getInstance();
256        if ($valid_on_match ? preg_match($regex, $val) : !preg_match($regex, $val)) {
257            return true;
258        } else {
259            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
260            return false;
261        }
262    }
263
264    /**
265    * Tests if the string length is between specified values. Whitespace excluded for min.
266    *
267    * @param  string $val The input data to validate.
268    * @param  int    $min       minimum length of string, inclusive
269    * @param  int    $max       maximum length of string, inclusive
270    * @param  const  $type  A LOG_* constant (see App->logMsg())
271    * @param  string $file  Filename to log (usually __FILE__)
272    * @param  int    $line  Line number to log (usually __LINE__)
273    * @return bool   true if string length is within given boundaries
274    */
275    static public function stringLength($val, $min, $max, $type=LOG_DEBUG, $file=null, $line=null)
276    {
277        $app =& App::getInstance();
278        if (mb_strlen((string)$val) >= $min && mb_strlen((string)$val) <= $max) {
279            return true;
280        } else {
281            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
282            return false;
283        }
284    }
285
286    /**
287    * Check whether input is within a valid numeric range.
288    *
289    * @param  string $val The input data to validate.
290    * @param  int    $min       minimum value of number, inclusive
291    * @param  int    $max       maximum value of number, inclusive
292    * @param  const  $type  A LOG_* constant (see App->logMsg())
293    * @param  string $file  Filename to log (usually __FILE__)
294    * @param  int    $line  Line number to log (usually __LINE__)
295    * @return bool   True if no errors found, false otherwise.
296    */
297    static public function numericRange($val, $min, $max, $type=LOG_DEBUG, $file=null, $line=null)
298    {
299        $app =& App::getInstance();
300        if ('' == trim((string)$val) || (is_numeric($val) && $val >= $min && $val <= $max)) {
301            return true;
302        } else {
303            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
304            return false;
305        }
306    }
307
308    /**
309    * Validates an email address based on the recommendations in RFC 3696.
310    * Is more loose than restrictive, to allow the many valid variants of
311    * email addresses while catching the most common mistakes.
312    * http://www.faqs.org/rfcs/rfc822.html
313    * http://www.faqs.org/rfcs/rfc2822.html
314    * http://www.faqs.org/rfcs/rfc3696.html
315    * http://www.faqs.org/rfcs/rfc1035.html
316    *
317    * @access  public
318    * @param   string   $val    The input data to validate..
319    * @param   bool     $strict Run strict tests (check if the domain exists and has an MX record assigned)
320    * @param   const    $type  A LOG_* constant (see App->logMsg())
321    * @param   string   $file  Filename to log (usually __FILE__)
322    * @param   int      $line  Line number to log (usually __LINE__)
323    * @return  const           One of the constant values: Validate::EMAIL_SUCCESS|Validate::EMAIL_REGEX_FAIL|Validate::EMAIL_LENGTH_FAIL|Validate::EMAIL_MX_FAIL
324    * @author  Quinn Comendant <quinn@strangecode.com>
325    */
326    static public function validateEmail($val, $strict=false, $type=LOG_DEBUG, $file=null, $line=null)
327    {
328        $app =& App::getInstance();
329        require_once 'codebase/lib/Email.inc.php';
330        $e = new Email();
331
332        // Test email address format.
333        if (!preg_match($e->getParam('regex'), $val, $e_parts)) {
334            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
335            return self::EMAIL_REGEX_FAIL;
336        }
337
338        // We have a match! Here are the captured subpatterns, on which further tests are run.
339        // The part before the @.
340        $local = $e_parts[2];
341
342        // The part after the @.
343        // If domain is an IP [XXX.XXX.XXX.XXX] strip off the brackets.
344        $domain = $e_parts[3]{0} == '[' ? mb_substr($e_parts[3], 1, -1) : $e_parts[3];
345
346        // Test length.
347        if (mb_strlen($local) > 64 || mb_strlen($domain) > 191) {
348            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
349            return self::EMAIL_LENGTH_FAIL;
350        }
351
352        if ($strict) {
353            // Strict tests.
354            if (ip2long($domain) === false && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
355                // Check domain exists: It's a domain if ip2long fails; checkdnsrr ensures a MX record exists; gethostbyname() ensures the domain exists.
356                $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
357                return self::EMAIL_MX_FAIL;
358            }
359        }
360
361        return self::EMAIL_SUCCESS;
362    }
363
364    /**
365    * Check whether input is a valid phone number. Notice: it is now set
366    * to allow characters like - or () or + so people can type in a phone
367    * number that looks like: +1 (530) 555-1212
368    *
369    * @param  string  $form_name the name of the incoming form variable
370    *
371    * @param  const  $type  A LOG_* constant (see App->logMsg())
372    * @param  string $file  Filename to log (usually __FILE__)
373    * @param  int    $line  Line number to log (usually __LINE__)
374    * @return bool    true if no errors found, false otherwise
375    */
376    static public function validatePhone($val, $type=LOG_DEBUG, $file=null, $line=null)
377    {
378        $app =& App::getInstance();
379        if (!self::checkRegex($val, '/^[0-9 +().-]*$/', true, $type, $file, $line)) {
380            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
381            return self::PHONE_REGEX_FAIL;
382        }
383        if (!self::stringLength($val, 0, 25, $type, $file, $line)) {
384            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
385            return self::PHONE_LENGTH_FAIL;
386        }
387        return self::PHONE_SUCCESS;
388    }
389
390    /**
391    * Verifies that date can be processed by the strtotime function.
392    * Empty strings are considered valid. Other values are tested on their return value from strtotime(). Null values will fail.
393    *
394    * @param  string  $val The input data to validate.
395    * @param  const  $type  A LOG_* constant (see App->logMsg())
396    * @param  string $file  Filename to log (usually __FILE__)
397    * @param  int    $line  Line number to log (usually __LINE__)
398    * @return bool    True if no errors found, false otherwise.
399    */
400    static public function validateStrDate($val, $type=LOG_DEBUG, $file=null, $line=null)
401    {
402        $app =& App::getInstance();
403        if (is_string($val) && '' === trim($val)) {
404            // Don't be too bothered about empty strings.
405            return true;
406        }
407
408        $timestamp = strtotime($val);
409        if (!$timestamp || $timestamp < 1) {
410            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
411            return false;
412        } else {
413            return true;
414        }
415    }
416
417    /*
418    * Checks if value is a "zero" SQL DATE, DATETIME, or TIMESTAMP value (or simply empty).
419    *
420    * @access   public
421    * @param    string  $val    String to check.
422    * @param  const  $type  A LOG_* constant (see App->logMsg())
423    * @param  string $file  Filename to log (usually __FILE__)
424    * @param  int    $line  Line number to log (usually __LINE__)
425    * @return   bool            True if value is an empty date.
426    * @author   Quinn Comendant <quinn@strangecode.com>
427    * @version  1.0
428    * @since    19 May 2015 09:57:27
429    */
430    static public function isEmptyDate($val, $type=LOG_DEBUG, $file=null, $line=null)
431    {
432        $app =& App::getInstance();
433        if (empty($val) || '0000-00-00 00:00:00' == $val || '0000-00-00' == $val || '00:00:00' == $val) {
434            return true;
435        }
436        $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
437        return false;
438    }
439
440    /**
441    * Verifies credit card number using the Luhn (mod 10) algorithm.
442    * http://en.wikipedia.org/wiki/Luhn_algorithm
443    *
444    * @param  string  $val   The input data to validate..
445    * @param  string  $cc_num      Card number to verify.
446    * @param  string  $cc_type     Optional, card type to do specific checks.
447    * @param  const  $type  A LOG_* constant (see App->logMsg())
448    * @param  string $file  Filename to log (usually __FILE__)
449    * @param  int    $line  Line number to log (usually __LINE__)
450    * @return bool    True if no errors found, false otherwise.
451    */
452    static public function validateCCNumber($val, $cc_type=null, $type=LOG_DEBUG, $file=null, $line=null)
453    {
454        $app =& App::getInstance();
455        // Get rid of any non-digits
456        $cc_num = preg_replace('/[^\d]/', '', $val);
457
458        // Perform card-specific checks, if applicable
459        switch ($cc_type) {
460        case self::CC_TYPE_VISA :
461            $regex = '/^4\d{15}$|^4\d{12}$/';
462            break;
463        case self::CC_TYPE_MASTERCARD :
464            $regex = '/^5[1-5]\d{14}$/';
465            break;
466        case self::CC_TYPE_AMEX :
467            $regex = '/^3[47]\d{13}$/';
468            break;
469        case self::CC_TYPE_DISCOVER :
470            $regex = '/^6011\d{12}$/';
471            break;
472        case self::CC_TYPE_DINERS :
473            $regex = '/^30[0-5]\d{11}$|^3[68]\d{12}$/';
474            break;
475        case self::CC_TYPE_JCB :
476            $regex = '/^3\d{15}$|^2131|1800\d{11}$/';
477            break;
478        default :
479            $regex = '/\d{13,}/';
480            break;
481        }
482
483        if ('' != $regex && !preg_match($regex, $cc_num)) {
484            // Invalid format.
485            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
486            return false;
487        }
488
489        // The Luhn formula works right to left, so reverse the number.
490        $cc_num = strrev($cc_num);
491
492        $luhn_total = 0;
493
494        $num = mb_strlen($cc_num);
495        for ($i=0; $i<$num; $i++) {
496            // Get each digit.
497            $digit = mb_substr($cc_num, $i, 1);
498
499            //  If it's an odd digit, double it.
500            if ($i / 2 != floor($i / 2)) {
501                $digit *= 2;
502            }
503
504            //  If the result is two digits, add them.
505            if (mb_strlen($digit) == 2) {
506                $digit = mb_substr($digit, 0, 1) + mb_substr($digit, 1, 1);
507            }
508
509            //  Add the current digit to the $luhn_total.
510            $luhn_total += $digit;
511        }
512
513        // If the Total is evenly divisible by 10, it's cool!
514        if ($luhn_total % 10 == 0) {
515            return true;
516        } else {
517            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
518            return false;
519        }
520    }
521
522    /**
523    * Check whether a file was selected for uploading. If file is missing, it's an error.
524    *
525    * @param  string $form_name The input data to validate.
526    * @param  const  $type  A LOG_* constant (see App->logMsg())
527    * @param  string $file  Filename to log (usually __FILE__)
528    * @param  int    $line  Line number to log (usually __LINE__)
529    * @return bool   True if no errors found, false otherwise.
530    */
531    static public function fileUploaded($form_name, $type=LOG_DEBUG, $file=null, $line=null)
532    {
533        $app =& App::getInstance();
534        if (!isset($_FILES[$form_name]['name']) || empty($_FILES[$form_name]['name'])) {
535            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, 'no _FILES'), $type, $file, $line);
536            return false;
537        }
538
539        if (is_array($_FILES[$form_name]['name'])) {
540            foreach($_FILES[$form_name]['name'] as $f) {
541                if ('' == $f) {
542                    $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($_FILES)), $type, $file, $line);
543                    return false;
544                }
545            }
546        } else {
547            if ('' == $_FILES[$form_name]['name']) {
548                $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($_FILES)), $type, $file, $line);
549                return false;
550            }
551        }
552
553        return true;
554    }
555
556    /*
557    * Check if the amount of content sent by the browser exceeds the upload_max_filesize value configured in php.ini.
558    * http://stackoverflow.com/a/24202363
559    *
560    * @access   public
561    * @param    string $form_name The input data to validate.
562    * @param  const  $type  A LOG_* constant (see App->logMsg())
563    * @param  string $file  Filename to log (usually __FILE__)
564    * @param  int    $line  Line number to log (usually __LINE__)
565    * @return   bool   True if no errors found, false otherwise.
566    * @author   Quinn Comendant <quinn@strangecode.com>
567    * @version  1.0
568    * @since    20 Aug 2014 14:44:23
569    */
570    static public function fileUploadSize($form_name, $type=LOG_DEBUG, $file=null, $line=null)
571    {
572        $app =& App::getInstance();
573        $upload_max_filesize = phpIniGetBytes('upload_max_filesize');
574        if (isset($_SERVER['CONTENT_LENGTH']) && 0 != $upload_max_filesize && $_SERVER['CONTENT_LENGTH'] > $upload_max_filesize) {
575            $app->logMsg(sprintf('%s (line %s) failed: %s', __METHOD__, __LINE__, getDump($val)), $type, $file, $line);
576            return false;
577        }
578        return true;
579    }
580
581} // THE END
582
Note: See TracBrowser for help on using the repository browser.