protected function _validateIPv6($value) {
        if (strlen($value) < 3) {
            return $value == '::';
        }

        if (strpos($value, '.')) {
            $lastcolon = strrpos($value, ':');
            if (!($lastcolon && $this->_validateIPv4(substr($value, $lastcolon + 1)))) {
                return false;
            }

            $value = substr($value, 0, $lastcolon) . ':0:0';
        }

        if (strpos($value, '::') === false) {
            return preg_match('/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i', $value);
        }

        $colonCount = substr_count($value, ':');
        if ($colonCount < 8) {
            return preg_match('/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i', $value);
        }

        // special case with ending or starting double colon
        if ($colonCount == 8) {
            return preg_match('/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i', $value);
        }

        return false;
    }
protected function _validateIPv6($value) {
        if (strlen($value) < 3) {
            return $value == '::';
        }

        if (strpos($value, '.')) {
            $lastcolon = strrpos($value, ':');
            if (!($lastcolon && $this->_validateIPv4(substr($value, $lastcolon + 1)))) {
                return false;
            }

            $value = substr($value, 0, $lastcolon) . ':0:0';
        }

        if (strpos($value, '::') === false) {
            return preg_match('/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i', $value);
        }

        $colonCount = substr_count($value, ':');
        if ($colonCount < 8) {
            return preg_match('/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i', $value);
        }

        // special case with ending or starting double colon
        if ($colonCount == 8) {
            return preg_match('/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i', $value);
        }

        return false;
    }
protected function _validateIPv6 ( $ value ) { if ( strlen ( $ value ) < 3 ) { return $ value == '::' ; } if ( strpos ( $ value , '.' ) ) { $ lastcolon = strrpos ( $ value , ':' ) ; if ( ! ( $ lastcolon && $ this -> _validateIPv4 ( substr ( $ value , $ lastcolon + 1 ) ) ) ) { return false ; } $ value = substr ( $ value , 0 , $ lastcolon ) . ':0:0' ; } if ( strpos ( $ value , '::' ) === false ) { return preg_match ( '/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i' , $ value ) ; } $ colonCount = substr_count ( $ value , ':' ) ; if ( $ colonCount < 8 ) { return preg_match ( '/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i' , $ value ) ; } // special case with ending or starting double colon if ( $ colonCount == 8 ) { return preg_match ( '/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i' , $ value ) ; } return false ; }
Validates an IPv6 address

@param  string $value Value to check against
@return boolean True when $value is a valid ipv6 address
False otherwise
Validates an IPv6 address