web/lib/Zend/Validate/Ip.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    12  * obtain it through the world-wide-web, please send an email
    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.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Validate
    16  * @package    Zend_Validate
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Ip.php 24593 2012-01-05 20:35:02Z matthew $
    19  * @version    $Id$
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * @see Zend_Validate_Abstract
    23  * @see Zend_Validate_Abstract
    24  */
    24  */
    25 require_once 'Zend/Validate/Abstract.php';
    25 require_once 'Zend/Validate/Abstract.php';
    26 
    26 
    27 /**
    27 /**
    28  * @category   Zend
    28  * @category   Zend
    29  * @package    Zend_Validate
    29  * @package    Zend_Validate
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  */
    32  */
    33 class Zend_Validate_Ip extends Zend_Validate_Abstract
    33 class Zend_Validate_Ip extends Zend_Validate_Abstract
    34 {
    34 {
    35     const INVALID        = 'ipInvalid';
    35     const INVALID        = 'ipInvalid';
    55 
    55 
    56     /**
    56     /**
    57      * Sets validator options
    57      * Sets validator options
    58      *
    58      *
    59      * @param array $options OPTIONAL Options to set, see the manual for all available options
    59      * @param array $options OPTIONAL Options to set, see the manual for all available options
    60      * @return void
       
    61      */
    60      */
    62     public function __construct($options = array())
    61     public function __construct($options = array())
    63     {
    62     {
    64         if ($options instanceof Zend_Config) {
    63         if ($options instanceof Zend_Config) {
    65             $options = $options->toArray();
    64             $options = $options->toArray();
    89 
    88 
    90     /**
    89     /**
    91      * Sets the options for this validator
    90      * Sets the options for this validator
    92      *
    91      *
    93      * @param array $options
    92      * @param array $options
       
    93      * @throws Zend_Validate_Exception
    94      * @return Zend_Validate_Ip
    94      * @return Zend_Validate_Ip
    95      */
    95      */
    96     public function setOptions($options)
    96     public function setOptions($options)
    97     {
    97     {
    98         if (array_key_exists('allowipv6', $options)) {
    98         if (array_key_exists('allowipv6', $options)) {
   139 
   139 
   140     /**
   140     /**
   141      * Validates an IPv4 address
   141      * Validates an IPv4 address
   142      *
   142      *
   143      * @param string $value
   143      * @param string $value
       
   144      * @return bool
   144      */
   145      */
   145     protected function _validateIPv4($value) {
   146     protected function _validateIPv4($value) {
   146         $ip2long = ip2long($value);
   147         $ip2long = ip2long($value);
   147         if($ip2long === false) {
   148         if($ip2long === false) {
   148             return false;
   149             return false;