Public Member Functions | |
__construct ($allow=self::ALLOW_DNS, $validateIdn=true, $validateTld=true, Zend_Validate_Ip $ipValidator=null) | |
setIpValidator (Zend_Validate_Ip $ipValidator=null) | |
getAllow () | |
setAllow ($allow) | |
setValidateIdn ($allowed) | |
setValidateTld ($allowed) | |
isValid ($value) | |
Data Fields | |
const | INVALID = 'hostnameInvalid' |
const | IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed' |
const | UNKNOWN_TLD = 'hostnameUnknownTld' |
const | INVALID_DASH = 'hostnameDashCharacter' |
const | INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema' |
const | UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld' |
const | INVALID_HOSTNAME = 'hostnameInvalidHostname' |
const | INVALID_LOCAL_NAME = 'hostnameInvalidLocalName' |
const | LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed' |
const | CANNOT_DECODE_PUNYCODE = 'hostnameCannotDecodePunycode' |
const | ALLOW_DNS = 1 |
const | ALLOW_IP = 2 |
const | ALLOW_LOCAL = 4 |
const | ALLOW_ALL = 7 |
Protected Member Functions | |
decodePunycode ($encoded) | |
Protected Attributes | |
$_messageTemplates | |
$_messageVariables | |
$_allow | |
$_validTlds | |
$_tld | |
$_validIdns | |
$_idnLength |
Definition at line 47 of file Hostname.php.
__construct | ( | $ | allow = self::ALLOW_DNS , |
$ | validateIdn = true , |
||
$ | validateTld = true , |
||
Zend_Validate_Ip $ | ipValidator = null |
||
) |
Sets validator options
integer | $allow | OPTIONAL Set what types of hostname to allow (default ALLOW_DNS) |
boolean | $validateIdn | OPTIONAL Set whether IDN domains are validated (default true) |
boolean | $validateTld | OPTIONAL Set whether the TLD element of a hostname is validated (default true) |
Zend_Validate_Ip | $ipValidator | OPTIONAL |
Definition at line 333 of file Hostname.php.
decodePunycode | ( | $ | encoded ) | [protected] |
Decodes a punycode encoded string to it's original utf8 string In case of a decoding failure the original string is returned
string | $encoded | Punycode encoded string to decode |
Definition at line 589 of file Hostname.php.
getAllow | ( | ) |
isValid | ( | $ | value ) |
Defined by Zend_Validate_Interface
Returns true if and only if the $value is a valid hostname with respect to the current allow option
string | $value |
Zend_Validate_Exception | if a fatal error occurs for validation process |
Match against IDN hostnames Note: Keep label regex short to avoid issues with long patterns when matching IDN hostnames
Regex error
Implements Zend_Validate_Interface.
Definition at line 412 of file Hostname.php.
setAllow | ( | $ | allow ) |
Sets the allow option
integer | $allow |
Definition at line 373 of file Hostname.php.
setIpValidator | ( | Zend_Validate_Ip $ | ipValidator = null ) |
Zend_Validate_Ip | $ipValidator | OPTIONAL |
Definition at line 349 of file Hostname.php.
setValidateIdn | ( | $ | allowed ) |
Set whether IDN domains are validated
This only applies when DNS hostnames are validated
boolean | $allowed | Set allowed to true to validate IDNs, and false to not validate them |
Definition at line 386 of file Hostname.php.
setValidateTld | ( | $ | allowed ) |
Set whether the TLD element of a hostname is validated
This only applies when DNS hostnames are validated
boolean | $allowed | Set allowed to true to validate TLDs, and false to not validate them |
Definition at line 398 of file Hostname.php.
$_idnLength [protected] |
array( 'BIZ' => array(5 => 17, 11 => 15, 12 => 20), 'CN' => array(1 => 20), 'COM' => array(3 => 17, 5 => 20), 'HK' => array(1 => 15), 'INFO'=> array(4 => 17), 'KR' => array(1 => 17), 'NET' => array(3 => 17, 5 => 20), 'ORG' => array(6 => 17), 'TW' => array(1 => 20), 'ایران' => array(1 => 30), '中国' => array(1 => 20), '公司' => array(1 => 20), '网络' => array(1 => 20), )
Definition at line 307 of file Hostname.php.
$_messageTemplates [protected] |
array( self::INVALID => "Invalid type given, value should be a string", self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed", self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list", self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position", self::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'", self::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part", self::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname", self::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name", self::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed", self::CANNOT_DECODE_PUNYCODE => "'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded" )
Reimplemented from Zend_Validate_Abstract.
Definition at line 63 of file Hostname.php.
$_messageVariables [protected] |
array( 'tld' => '_tld' )
Reimplemented from Zend_Validate_Abstract.
Definition at line 79 of file Hostname.php.
$_validTlds [protected] |
array( 'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm', 'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tel', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw' )
Definition at line 131 of file Hostname.php.
const ALLOW_ALL = 7 |
Allows all types of hostnames
Definition at line 101 of file Hostname.php.
const ALLOW_DNS = 1 |
Allows Internet domain names (e.g., example.com)
Definition at line 86 of file Hostname.php.
const ALLOW_IP = 2 |
Allows IP addresses
Definition at line 91 of file Hostname.php.
const ALLOW_LOCAL = 4 |
Allows local network names (e.g., localhost, www.localdomain)
Definition at line 96 of file Hostname.php.