当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate_Hostname类代码示例

本文整理汇总了PHP中Zend_Validate_Hostname的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Hostname类的具体用法?PHP Zend_Validate_Hostname怎么用?PHP Zend_Validate_Hostname使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Validate_Hostname类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValid

    /**
     * Defined by Zend_Validate_Interface
     *
     * Returns true if and only if the $value is a valid url that starts with http(s)://
     * and the hostname is a valid TLD
     *
     * @param  string $value
     * @throws Zend_Validate_Exception if a fatal error occurs for validation process
     * @return boolean
     */
    public function isValid($value)
    {
        if (!is_string($value)) {
            $this->_error(self::INVALID_URL);
             return false;
        }
		
        $this->_setValue($value);
        //get a Zend_Uri_Http object for our URL, this will only accept http(s) schemes
        try {
            $uriHttp = Zend_Uri_Http::fromString($value);
        } catch (Zend_Uri_Exception $e) {
            $this->_error(self::INVALID_URL);
            return false;
        }
        
        //if we have a valid URI then we check the hostname for valid TLDs, and not local urls
        $hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS); //do not allow local hostnames, this is the default

        if (!$hostnameValidator->isValid($uriHttp->getHost())) {
            $this->_error(self::INVALID_URL);
            return false;
        }
        return true;
    }
开发者ID:rondobley,项目名称:Zend-Framework-Validate-URL,代码行数:35,代码来源:IsUrl.php

示例2: validateInstance

function validateInstance($instance)
{
    if ($instance == 'www' || $instance == 'www.' || $instance == 'dev') {
        $ret = false;
        echo json_encode(array('exists' => $ret));
        die;
    }
    // Check that the selected instance name is a valid standard host name
    $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
    if (!$validate->isValid($instance)) {
        $ret = false;
        echo json_encode(array('exists' => $ret));
        die;
    }
    $cupid = new Cupid();
    $cupid->init();
    $exists = $cupid->instanceExists($instance);
    if (!$exists) {
        $ret = true;
        echo json_encode(array('exists' => $ret));
    } else {
        $ret = false;
        echo json_encode(array('exists' => $ret));
    }
    $cupid->disconnect();
}
开发者ID:highfidelity,项目名称:love,代码行数:26,代码来源:validate.php

示例3: validate

 public function validate(array $attributes)
 {
     if (empty($attributes[$this->_attributeName])) {
         return true;
     }
     $attributeValues = $attributes[$this->_attributeName];
     switch ($this->_options) {
         case 'URN':
             $urnValidator = new EngineBlock_Validator_Urn();
             foreach ($attributeValues as $attributeValue) {
                 if (!$urnValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URN, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'HostName':
             $hostnameValidator = new Zend_Validate_Hostname();
             foreach ($attributeValues as $attributeValue) {
                 if (!$hostnameValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_HOSTNAME, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URL':
             foreach ($attributeValues as $attributeValue) {
                 if (!Zend_Uri::check($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'URI':
             $uriValidator = new EngineBlock_Validator_Uri();
             foreach ($attributeValues as $attributeValue) {
                 if (!$uriValidator->validate($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_URI, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         case 'EmailAddress':
             $emailValidator = new Zend_Validate_EmailAddress();
             foreach ($attributeValues as $attributeValue) {
                 if (!$emailValidator->isValid($attributeValue)) {
                     $this->_messages[] = array(self::ERROR_ATTRIBUTE_VALIDATOR_EMAIL, $this->_attributeName, $this->_options, $attributeValue);
                     return false;
                 }
             }
             break;
         default:
             throw new EngineBlock_Exception("Unknown validate option '{$this->_options}' for attribute validation");
     }
     return true;
 }
开发者ID:WebSpider,项目名称:OpenConext-engineblock,代码行数:56,代码来源:Type.php

示例4: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(Zend_Validate_Hostname::ALLOW_IP, true, array('1.2.3.4', '10.0.0.1', '255.255.255.255')), array(Zend_Validate_Hostname::ALLOW_IP, false, array('0.0.0.0', '0.0.0.256')), array(Zend_Validate_Hostname::ALLOW_DNS, true, array('example.com', 'example.museum')), array(Zend_Validate_Hostname::ALLOW_DNS, false, array('localhost', 'localhost.localdomain', '1.2.3.4')), array(Zend_Validate_Hostname::ALLOW_LOCAL, true, array('localhost', 'localhost.localdomain', 'example.com')), array(Zend_Validate_Hostname::ALLOW_ALL, true, array('localhost', 'example.com', '1.2.3.4')));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_Hostname($element[0]);
         foreach ($element[2] as $input) {
             $this->assertEquals($element[1], $validator->isValid($input));
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:15,代码来源:HostnameTest.php

示例5: setHost

 /**
  * Set the Hostname / IP to connect to.
  * @param	string			$host	Hostname / IP of the Database.
  * @return	Couchdb_Config	$this	This main class for method chaining.
  * @throws	Couchdb_Exception_Parameter
  */
 public function setHost($host)
 {
     $ip = new Zend_Validate_Ip();
     $name = new Zend_Validate_Hostname();
     if ($ip->isValid($host) xor $name->isValid($host)) {
         throw new Couchdb_Exception_Parameter("Wrong Parameters, host must either be a valid hostname or an IP");
     }
     $this->_host = $host;
     return $this;
 }
开发者ID:Hadean,项目名称:Couchdb,代码行数:16,代码来源:Config.php

示例6: _factory

 protected function _factory($type, $userId, $userIp, $cache = true, $preview = null, $portals = null, $channels = null, $seriesId = null, $offset = 0, $limit = null, Zend_Date $start = null, Zend_Date $finish = null, $showId = null, $exclude = null, $searchTerm = null, $searchFilter = null, $transcript = null)
 {
     $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, true, false);
     $userIp = $validator->isValid($userIp) ? $userIp : null;
     unset($validator);
     $start = $start ? strval($start) : null;
     $finish = $finish ? strval($finish) : null;
     $stmt = Zend_Registry::get('dbh')->proc('page_content_load');
     $stmt->bindParam(':preview', $preview, PDO::PARAM_INT);
     $stmt->bindParam(':portals', $portals, PDO::PARAM_INT);
     $stmt->bindParam(':channels', $channels, PDO::PARAM_INT);
     /*
     $stmt->bindParam(':series', $seriesId, PDO::PARAM_INT);
     $stmt->bindParam(':exclude', $exclude, PDO::PARAM_INT);
     $stmt->bindParam(':show', $showId, PDO::PARAM_STR);
     $stmt->bindParam(':start', $start, PDO::PARAM_STR);
     $stmt->bindParam(':finish', $finish, PDO::PARAM_STR);		
     $stmt->bindParam(':search', $searchTerm, PDO::PARAM_STR);
     $stmt->bindParam(':filter', $searchFilter, PDO::PARAM_STR);
     $stmt->bindParam(':user', $user->id, PDO::PARAM_INT);
     $stmt->bindParam(':ip', $userIp, PDO::PARAM_STR);
     $stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
     $stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
     $stmt->bindParam(':type', $type, PDO::PARAM_STR);
     */
     $results = array();
     try {
         $stmt->execute();
         $pageContent = array();
         $rowCount = 0;
         do {
             $results[] = $stmt->fetchAll(Zend_Db::FETCH_OBJ);
         } while ($stmt->nextRowset());
         $stmt->closeCursor();
     } catch (Zend_Db_Statement_Exception $e) {
         if ('HYC00' == $stmt->errorCode()) {
             $results[] = $stmt->fetchAll(Zend_Db::FETCH_OBJ);
         }
     }
     foreach ($results as $rowset) {
         foreach ($rowset as $row) {
             if (isset($row->found_rows)) {
                 $rowCount = $row->found_rows;
                 continue;
             } else {
                 $pageContent[] = Showcase_Content::factory($row, $cache);
             }
         }
     }
     $binds = array($user->id, $userIp, $offset, $limit, $type, $portals, $channels, $seriesId, $exclude, $showId, $start, $finish, $searchTerm, $searchFilter, $preview);
     //print_r($binds);
     //print_r($results);
     //echo "CALL page_content_load(".implode($binds,',').")";
     return array('contents' => $showId ? $pageContent[0] : $pageContent, 'rows' => !$rowCount ? count($pageContent) : $rowCount);
 }
开发者ID:roycocup,项目名称:Tests,代码行数:55,代码来源:ContentLoader.php

示例7: save

 public function save()
 {
     $value = $this->getValue();
     if (strlen($value) == 0) {
         Mage::throwException(Mage::helper("mailup")->__("Please fill the admin console URL"));
     }
     $validator = new Zend_Validate_Hostname();
     if (!$validator->isValid($value)) {
         Mage::throwException(Mage::helper("mailup")->__("Admin console URL is not in the right format"));
     }
     return parent::save();
 }
开发者ID:hanicker,项目名称:mailup-magento,代码行数:12,代码来源:Consoleurlvalidator.php

示例8: init

 /**
  * (non-PHPdoc)
  * @see library/Zend/Form/Zend_Form_Element#init()
  */
 public function init()
 {
     parent::init();
     /**
      * @todo Change this wired error messages to something more user friendly, or even use simple email regex matching validator
      */
     $validatorHostname = new Zend_Validate_Hostname();
     $validatorHostname->setMessages(array(Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed", Zend_Validate_Hostname::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list", Zend_Validate_Hostname::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position", Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'", Zend_Validate_Hostname::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part", Zend_Validate_Hostname::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname", Zend_Validate_Hostname::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name", Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed"));
     $validatorEmail = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS, false, $validatorHostname);
     $validatorEmail->setMessages(array(Zend_Validate_EmailAddress::INVALID => "'%value%' is not a valid email address", Zend_Validate_EmailAddress::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'", Zend_Validate_EmailAddress::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'", Zend_Validate_EmailAddress::DOT_ATOM => "'%localPart%' not matched against dot-atom format", Zend_Validate_EmailAddress::QUOTED_STRING => "'%localPart%' not matched against quoted-string format", Zend_Validate_EmailAddress::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'"));
     $this->addValidator($validatorEmail);
 }
开发者ID:xinghao,项目名称:shs,代码行数:16,代码来源:Email.php

示例9: isValid

 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return boolean
  * @throws \Zend_Valid_Exception If validation of $value is impossible
  */
 public function isValid($value, $context = array())
 {
     $this->_setValue($value);
     if ($value) {
         try {
             $uri = \Zend_Uri::factory($value);
             // Check the host against the allowed values; delegated to \Zend_Filter.
             $validate = new \Zend_Validate_Hostname(\Zend_Validate_Hostname::ALLOW_DNS | \Zend_Validate_Hostname::ALLOW_IP | \Zend_Validate_Hostname::ALLOW_LOCAL);
             if (!$validate->isValid($uri->getHost())) {
                 foreach ($validate->getMessages() as $key => $msg) {
                     $this->_error($key);
                 }
                 return false;
             }
             if (function_exists('curl_init')) {
                 $ch = curl_init($value);
                 if (false === $ch) {
                     $this->_error(self::ERROR_URL_NOT_VALID);
                     return false;
                 }
                 // Authentication
                 // if ($usr) {
                 // curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                 // curl_setopt($ch, CURLOPT_USERPWD, $usr.':'.$pwd);
                 // }
                 // curl_setopt($ch, CURLOPT_FILETIME, true);
                 curl_setopt($ch, CURLOPT_NOBODY, true);
                 /**
                  * @todo Unknown CA's should probably be imported...
                  */
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 $valid = curl_exec($ch);
                 if (!$valid) {
                     $this->_error(self::ERROR_SITE_NOT_FOUND);
                 }
                 // $return = curl_getinfo($ch, CURLINFO_FILETIME);
                 // \MUtil_Echo::r('Date at server: '.date('r', $return));
                 curl_close($ch);
                 return $valid;
             } else {
                 return true;
             }
         } catch (\Exception $e) {
             $this->_error(self::ERROR_URL_NOT_VALID);
             $this->setMessage($e->getMessage(), self::ERROR_URL_NOT_VALID);
             return false;
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:60,代码来源:Url.php

示例10: isValid

 /**
  * Valid?
  * @param $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     $uri = Zend_Uri::factory($value);
     $uriSchema = $uri->getScheme();
     try {
         $uri->valid();
     } catch (Exception $e) {
         $this->_error(self::INVALID);
         return false;
     }
     $validatorHostname = new Zend_Validate_Hostname(array('allow' => Zend_Validate_Hostname::ALLOW_DNS, 'idn' => true, 'tld' => false));
     $protocol = !empty($uriSchema) ? $uriSchema . '://' : '';
     $urlHostname = str_replace($protocol, "", $value);
     if (!$validatorHostname->isValid($urlHostname)) {
         $this->_error(self::INVALID_HOSTNAME);
         return false;
     }
     return true;
 }
开发者ID:abtris,项目名称:zfcore,代码行数:26,代码来源:Url.php

示例11: isValid

 /**
  * Returns true if the value is a valid url that starts with http(s)://
  * and the hostname is a valid TLD.
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     // Invalid if not string.
     if (!is_string($value)) {
         $this->_error(self::INVALID_URL);
         return false;
     }
     $this->_setValue($value);
     try {
         // Try to parse a URL.
         $uriHttp = Zend_Uri_Http::fromString($value);
     } catch (Zend_Uri_Exception $e) {
         // Invalid if not URL.
         $this->_error(self::INVALID_URL);
         return false;
     }
     $hostnameValidator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_LOCAL);
     // Allow local URLs.
     if (!$hostnameValidator->isValid($uriHttp->getHost())) {
         $this->_error(self::INVALID_URL);
         return false;
     }
     return true;
 }
开发者ID:KelvinSmithLibrary,项目名称:playhouse,代码行数:31,代码来源:isUrl.php

示例12: testSupportsIpv6AddressesWhichContainHexDigitF

 /**
  * @group ZF-11334
  * @see http://www.ietf.org/rfc/rfc2732.txt
  */
 public function testSupportsIpv6AddressesWhichContainHexDigitF()
 {
     $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
     $this->assertTrue($validator->isValid('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210'));
     $this->assertTrue($validator->isValid('1080:0:0:0:8:800:200C:417A'));
     $this->assertTrue($validator->isValid('3ffe:2a00:100:7031::1'));
     $this->assertTrue($validator->isValid('1080::8:800:200C:417A'));
     $this->assertTrue($validator->isValid('::192.9.5.5'));
     $this->assertTrue($validator->isValid('::FFFF:129.144.52.38'));
     $this->assertTrue($validator->isValid('2010:836B:4179::836B:4179'));
 }
开发者ID:omusico,项目名称:logica,代码行数:15,代码来源:HostnameTest.php

示例13: validateHost

 /**
  * Returns true if and only if the host string passes validation. If no host is passed,
  * then the host contained in the instance variable is used.
  *
  * @param  string $host The HTTP host
  * @return boolean
  * @uses   Zend_Filter
  */
 public function validateHost($host = null)
 {
     if ($host === null) {
         $host = $this->_host;
     }
     // If the host is empty, then it is considered invalid
     if (strlen($host) === 0) {
         return false;
     }
     // Check the host against the allowed values; delegated to Zend_Filter.
     $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
     return $validate->isValid($host);
 }
开发者ID:rakesh-sankar,项目名称:PHP-Framework-Benchmark,代码行数:21,代码来源:Http.php

示例14: _validateInputRule

 /**
  * Validate value by attribute input validation rule
  *
  * @param string $value
  * @return array|true
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _validateInputRule($value)
 {
     // skip validate empty value
     if (empty($value)) {
         return true;
     }
     $label = $this->getAttribute()->getStoreLabel();
     $validateRules = $this->getAttribute()->getValidationRules();
     $inputValidation = ArrayObjectSearch::getArrayElementByName($validateRules, 'input_validation');
     if (!is_null($inputValidation)) {
         switch ($inputValidation) {
             case 'alphanumeric':
                 $validator = new \Zend_Validate_Alnum(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alnum::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic or non-numeric characters.', $label), \Zend_Validate_Alnum::NOT_ALNUM);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alnum::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'numeric':
                 $validator = new \Zend_Validate_Digits();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Digits::INVALID);
                 $validator->setMessage(__('"%1" contains non-numeric characters.', $label), \Zend_Validate_Digits::NOT_DIGITS);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Digits::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'alpha':
                 $validator = new \Zend_Validate_Alpha(true);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Alpha::INVALID);
                 $validator->setMessage(__('"%1" contains non-alphabetic characters.', $label), \Zend_Validate_Alpha::NOT_ALPHA);
                 $validator->setMessage(__('"%1" is an empty string.', $label), \Zend_Validate_Alpha::STRING_EMPTY);
                 if (!$validator->isValid($value)) {
                     return $validator->getMessages();
                 }
                 break;
             case 'email':
                 /**
                 __("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded")
                 __("Invalid type given. String expected")
                 __("'%value%' appears to be a DNS hostname but contains a dash in an invalid position")
                 __("'%value%' does not match the expected structure for a DNS hostname")
                 __("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'")
                 __("'%value%' does not appear to be a valid local network name")
                 __("'%value%' does not appear to be a valid URI hostname")
                 __("'%value%' appears to be an IP address, but IP addresses are not allowed")
                 __("'%value%' appears to be a local network name but local network names are not allowed")
                 __("'%value%' appears to be a DNS hostname but cannot extract TLD part")
                 __("'%value%' appears to be a DNS hostname but cannot match TLD against known list")
                 */
                 $validator = new \Zend_Validate_EmailAddress();
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_FORMAT);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_HOSTNAME);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid hostname.', $label), \Zend_Validate_EmailAddress::INVALID_MX_RECORD);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::DOT_ATOM);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::QUOTED_STRING);
                 $validator->setMessage(__('"%1" is not a valid email address.', $label), \Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
                 $validator->setMessage(__('"%1" uses too many characters.', $label), \Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
                 $validator->setMessage(__("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), \Zend_Validate_Hostname::UNKNOWN_TLD);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but we cannot match it against the hostname schema for TLD '%tld%'."), \Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
                 $validator->setMessage(__("'%value%' looks like a DNS hostname but cannot extract TLD part."), \Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
                 $validator->setMessage(__("'%value%' does not look like a valid local network name."), \Zend_Validate_Hostname::INVALID_LOCAL_NAME);
                 $validator->setMessage(__("'%value%' looks like a local network name, which is not an acceptable format."), \Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
                 $validator->setMessage(__("'%value%' appears to be a DNS hostname, but the given punycode notation cannot be decoded."), \Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
                 break;
             case 'url':
                 $parsedUrl = parse_url($value);
                 if ($parsedUrl === false || empty($parsedUrl['scheme']) || empty($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 $validator = new \Zend_Validate_Hostname();
                 if (!$validator->isValid($parsedUrl['host'])) {
                     return [__('"%1" is not a valid URL.', $label)];
                 }
                 break;
             case 'date':
                 $validator = new \Zend_Validate_Date(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
                 $validator->setMessage(__('"%1" invalid type entered.', $label), \Zend_Validate_Date::INVALID);
                 $validator->setMessage(__('"%1" is not a valid date.', $label), \Zend_Validate_Date::INVALID_DATE);
                 $validator->setMessage(__('"%1" does not fit the entered date format.', $label), \Zend_Validate_Date::FALSEFORMAT);
                 if (!$validator->isValid($value)) {
                     return array_unique($validator->getMessages());
                 }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:AbstractData.php

示例15: isHostname

 /**
  * Returns TRUE if value is a valid hostname, FALSE otherwise.
  * Depending upon the value of $allow, Internet domain names, IP
  * addresses, and/or local network names are considered valid.
  * The default is HOST_ALLOW_ALL, which considers all of the
  * above to be valid.
  *
  * @deprecated since 0.8.0
  * @param      mixed   $value
  * @param      integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
  * @return     boolean
  */
 public static function isHostname($value, $allow = self::HOST_ALLOW_ALL)
 {
     require_once 'Zend/Validate/Hostname.php';
     $validator = new Zend_Validate_Hostname($allow);
     return $validator->isValid($value);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:Filter.php


注:本文中的Zend_Validate_Hostname类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。