Changeset 1815
- Timestamp:
- 01/25/08 16:22:37 (6 months ago)
- Files:
-
- trunk/system/i18n/en_US/validation.php (modified) (1 diff)
- trunk/system/libraries/Validation.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/system/i18n/en_US/validation.php
r1672 r1815 27 27 'invalid_type' => 'The %s file is not an allowed file type.', 28 28 'max_size' => 'The %s file you uploaded was too large. The maximum size allowed is %s.', 29 'max_width' => 'The %s file has a maximum allowed width of %s is %spx.', 30 'max_height' => 'The %s file has a maximum allowed image height of %s is %spx.', 29 'max_width' => 'The %s file you uploaded was too big. The maximum allowed width is %spx.', 30 'max_height' => 'The %s file you uploaded was too big, The maximum allowed height is %spx.', 31 'min_width' => 'The %s file you uploaded was too big. The minimum allowed width is %spx.', 32 'min_height' => 'The %s file you uploaded was too big, The minimum allowed height is %spx.', 31 33 32 34 // Field types trunk/system/libraries/Validation.php
r1812 r1815 453 453 454 454 // Maximum sizes of various attributes 455 $ maxsize= array455 $fileinfo = array 456 456 ( 457 457 'file' => FALSE, 458 458 'human' => FALSE, 459 ' width' => FALSE,460 ' height' => FALSE459 'max_width' => FALSE, 460 'max_height' => FALSE 461 461 ); 462 462 … … 505 505 foreach($params as $param) 506 506 { 507 if (preg_match('/[0-9]+x[0-9]+/', $param)) 508 { 509 // Maximum image size, eg: 200x100 510 list($maxsize['width'], $maxsize['height']) = explode('x', $param); 507 if (preg_match('/[0-9]+x[0-9]+(-[0-9]+x[0-9]+)?/', $param)) 508 { 509 // Image size, eg: 200x100 , 20x10-200x100 510 $param = (strpos($param, '-') === False) ? $param.'-'.$param : $param; 511 512 list($min, $max) = explode('-', $param); 513 514 list($fileinfo['max_width'], $fileinfo['max_height']) = explode('x', $max); 515 list($fileinfo['min_width'], $fileinfo['min_height']) = explode('x', $min); 511 516 } 512 517 elseif (preg_match('/[0-9]+[BKMG]/i', $param)) 513 518 { 514 519 // Maximum file size, eg: 1M 515 $ maxsize['human'] = strtoupper($param);520 $fileinfo['human'] = strtoupper($param); 516 521 517 522 switch(strtoupper(substr($param, -1))) … … 523 528 } 524 529 525 $ maxsize['file'] = $param;530 $fileinfo['file'] = $param; 526 531 } 527 532 else … … 560 565 // Upload to large, based on php.ini settings 561 566 case UPLOAD_ERR_INI_SIZE: 562 if ($ maxsize['human'] == FALSE)563 { 564 $ maxsize['human'] = ini_get('upload_max_filesize');565 } 566 $this->add_error('max_size', $this->current_field, $ maxsize['human']);567 if ($fileinfo['human'] == FALSE) 568 { 569 $fileinfo['human'] = ini_get('upload_max_filesize'); 570 } 571 $this->add_error('max_size', $this->current_field, $fileinfo['human']); 567 572 return FALSE; 568 573 break; … … 595 600 return FALSE; 596 601 597 if ($ maxsize['file'] AND $data['size'] > $maxsize['file'])598 { 599 $this->add_error('max_size', $this->current_field, $ maxsize['human']);602 if ($fileinfo['file'] AND $data['size'] > $fileinfo['file']) 603 { 604 $this->add_error('max_size', $this->current_field, $fileinfo['human']); 600 605 return FALSE; 601 606 } … … 611 616 612 617 // Validate height and width 613 if ($ maxsize['width'] AND $mime[0] > $maxsize['width'])614 { 615 $this->add_error('max_width', $this->current_field, $ maxsize['width']);618 if ($fileinfo['max_width'] AND $mime[0] > $fileinfo['max_width']) 619 { 620 $this->add_error('max_width', $this->current_field, $fileinfo['max_width']); 616 621 return FALSE; 617 622 } 618 elseif ($maxsize['height'] AND $mime[1] > $maxsize['height']) 619 { 620 $this->add_error('max_height', $this->current_field, $maxsize['height']); 623 elseif ($fileinfo['min_width'] AND $mime[0] < $fileinfo['min_width']) 624 { 625 $this->add_error('min_width', $this->current_field, $fileinfo['min_width']); 626 return FALSE; 627 } 628 elseif ($fileinfo['max_height'] AND $mime[1] > $fileinfo['max_height']) 629 { 630 $this->add_error('max_height', $this->current_field, $fileinfo['max_height']); 631 return FALSE; 632 } 633 elseif ($fileinfo['min_height'] AND $mime[1] < $fileinfo['min_height']) 634 { 635 $this->add_error('min_height', $this->current_field, $fileinfo['min_height']); 621 636 return FALSE; 622 637 }
