本文整理汇总了PHP中Zend_Validate_Hostname::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Hostname::getMessages方法的具体用法?PHP Zend_Validate_Hostname::getMessages怎么用?PHP Zend_Validate_Hostname::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_Hostname
的用法示例。
在下文中一共展示了Zend_Validate_Hostname::getMessages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a valid email address
* according to RFC2822
*
* @link http://www.ietf.org/rfc/rfc2822.txt RFC2822
* @link http://www.columbia.edu/kermit/ascii.html US-ASCII characters
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_messages = array();
// Split email address up
if (!preg_match('/^(.+)@([^@]+)$/', $value, $matches)) {
$this->_messages[] = "'{$value}' is not a valid email address in the basic format local-part@hostname";
return false;
}
$localPart = $matches[1];
$hostname = $matches[2];
/**
* @todo 0.9 ZF-42 implement basic MX check on hostname via dns_get_record()
*/
// Match hostname part
$hostnameResult = $this->_hostnameValidator->isValid($hostname);
if (!$hostnameResult) {
$this->_messages[] = "'{$hostname}' is not a valid hostname for email address '{$value}'";
// Get messages from hostnameValidator
foreach ($this->_hostnameValidator->getMessages() as $message) {
$this->_messages[] = $message;
}
}
// First try to match the local part on the common dot-atom format
$localResult = false;
// Dot-atom characters are: 1*atext *("." 1*atext)
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
// "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
$atext = 'a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27\\x2a\\x2b\\x2d\\x2f';
$atext .= '\\x3d\\x3f\\x5e\\x5f\\x60\\x7b\\x7c\\x7d';
if (preg_match('/^[' . $atext . ']+(\\x2e+[' . $atext . ']+)*$/', $localPart)) {
$localResult = true;
} else {
$this->_messages[] = "'{$localPart}' not matched against dot-atom format";
}
// If not matched, try quoted string format
if (!$localResult) {
// Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
// qtext: Non white space controls, and the rest of the US-ASCII characters not
// including "\" or the quote character
$noWsCtl = '\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f';
$qtext = $noWsCtl . '\\x21\\x23-\\x5b\\x5d-\\x7e';
$ws = '\\x20\\x09';
if (preg_match('/^\\x22([' . $ws . $qtext . '])*[$ws]?\\x22$/', $localPart)) {
$localResult = true;
} else {
$this->_messages[] = "'{$localPart}' not matched against quoted-string format";
}
}
if (!$localResult) {
$this->_messages[] = "'{$localPart}' is not a valid local part for email address '{$value}'";
}
// If both parts valid, return true
if ($localResult && $hostnameResult) {
return true;
} else {
return false;
}
}
示例2: 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;
}
}
}
示例3: testValidatorMessagesShouldBeTranslated
/**
* Test changed with ZF-6676, as IP check is only involved when IP patterns match
*
* @see ZF-2861
* @see ZF-6676
*/
public function testValidatorMessagesShouldBeTranslated()
{
$translations = array('hostnameInvalidLocalName' => 'this is the IP error message');
$translator = new \Zend\Translator\Translator('ArrayAdapter', $translations);
$this->_validator->setTranslator($translator);
$this->_validator->isValid('0.239,512.777');
$messages = $this->_validator->getMessages();
$found = false;
foreach ($messages as $code => $message) {
if (array_key_exists($code, $translations)) {
$found = true;
break;
}
}
$this->assertTrue($found);
$this->assertEquals($translations[$code], $message);
}
示例4: testTrailingDot
/**
* Ensure that a trailing "." in a local hostname is permitted
*
* @group ZF-6363
*/
public function testTrailingDot()
{
$valuesExpected = array(array(Zend_Validate_Hostname::ALLOW_ALL, true, array('example.', 'example.com.', '~ex%20ample.com.')), array(Zend_Validate_Hostname::ALLOW_ALL, false, array('example..')), array(Zend_Validate_Hostname::ALLOW_ALL, true, array('1.2.3.4.')), array(Zend_Validate_Hostname::ALLOW_DNS, false, array('example..', '~ex%20ample..')), array(Zend_Validate_Hostname::ALLOW_LOCAL, true, array('example.', 'example.com.')));
foreach ($valuesExpected as $element) {
$validator = new Zend_Validate_Hostname($element[0]);
foreach ($element[2] as $input) {
$this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
}
示例5: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a valid email address
* according to RFC2822
*
* @link http://www.ietf.org/rfc/rfc2822.txt RFC2822
* @link http://www.columbia.edu/kermit/ascii.html US-ASCII characters
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$valueString = (string) $value;
$this->_setValue($valueString);
// Split email address up
if (!preg_match('/^(.+)@([^@]+)$/', $valueString, $matches)) {
$this->_error(self::INVALID);
return false;
}
$this->_localPart = $matches[1];
$this->_hostname = $matches[2];
// Match hostname part
$hostnameResult = $this->hostnameValidator->setTranslator($this->getTranslator())->isValid($this->_hostname);
if (!$hostnameResult) {
$this->_error(self::INVALID_HOSTNAME);
// Get messages and errors from hostnameValidator
foreach ($this->hostnameValidator->getMessages() as $message) {
$this->_messages[] = $message;
}
foreach ($this->hostnameValidator->getErrors() as $error) {
$this->_errors[] = $error;
}
}
// MX check on hostname via dns_get_record()
if ($this->_validateMx) {
if ($this->validateMxSupported()) {
$result = dns_get_mx($this->_hostname, $mxHosts);
if (count($mxHosts) < 1) {
$hostnameResult = false;
$this->_error(self::INVALID_MX_RECORD);
}
} else {
/**
* MX checks are not supported by this system
* @see Zend_Validate_Exception
*/
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Internal error: MX checking not available on this system');
}
}
// First try to match the local part on the common dot-atom format
$localResult = false;
// Dot-atom characters are: 1*atext *("." 1*atext)
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
// "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
$atext = 'a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b\\x7c\\x7d';
if (preg_match('/^[' . $atext . ']+(\\x2e+[' . $atext . ']+)*$/', $this->_localPart)) {
$localResult = true;
} else {
// Try quoted string format
// Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
// qtext: Non white space controls, and the rest of the US-ASCII characters not
// including "\" or the quote character
$noWsCtl = '\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f';
$qtext = $noWsCtl . '\\x21\\x23-\\x5b\\x5d-\\x7e';
$ws = '\\x20\\x09';
if (preg_match('/^\\x22([' . $ws . $qtext . '])*[$ws]?\\x22$/', $this->_localPart)) {
$localResult = true;
} else {
$this->_error(self::DOT_ATOM);
$this->_error(self::QUOTED_STRING);
$this->_error(self::INVALID_LOCAL_PART);
}
}
// If both parts valid, return true
if ($localResult && $hostnameResult) {
return true;
} else {
return false;
}
}
示例6: testURI
/**
* @group ZF-10267
*/
public function testURI()
{
$valuesExpected = array(
array(Zend_Validate_Hostname::ALLOW_URI, true, array('localhost', 'example.com', '~ex%20ample')),
array(Zend_Validate_Hostname::ALLOW_URI, false, array('§bad', 'don?t.know', 'thisisaverylonghostnamewhichextendstwohundredfiftysixcharactersandthereforshouldnotbeallowedbythisvalidatorbecauserfc3986limitstheallowedcharacterstoalimitoftwohunderedfiftysixcharactersinsumbutifthistestwouldfailthenitshouldreturntruewhichthrowsanexceptionbytheunittest')),
);
foreach ($valuesExpected as $element) {
$validator = new Zend_Validate_Hostname($element[0]);
foreach ($element[2] as $input) {
$this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
}
示例7: testTLD
/**
* Ensure the TLD check works as expected
*
*/
public function testTLD()
{
$validator = new Zend_Validate_Hostname();
// Check TLD matching
$valuesExpected = array(
array(true, array('domain.co.uk', 'domain.uk.com', 'domain.tl', 'domain.zw')),
array(false, array('domain.xx', 'domain.zz', 'domain.madeup'))
);
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
}
}
// Check no TLD matching
$validator->setValidateTld(false);
$valuesExpected = array(
array(true, array('domain.xx', 'domain.zz', 'domain.madeup'))
);
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
}
}
// Check setting no TLD matching via constructor
unset($validator);
$validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, true, false);
$valuesExpected = array(
array(true, array('domain.xx', 'domain.zz', 'domain.madeup'))
);
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
}
}
}
示例8: array
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* Standalone Validate_Hostname test script
*
* Please note this file should be encoded as UTF-8 in order to run correctly
*
* @see Zend_Validate_Hostname
*/
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../library/');
require_once 'Zend/Validate/Hostname.php';
// Set up expected values
$valuesExpected = array(array(Zend_Validate_Hostname::CHECK_TLD, false, array('bürger.de', 'hãllo.de', 'hållo.se')), array(Zend_Validate_Hostname::CHECK_IDN, true, array('bürger.de', 'hãllo.de', 'hållo.se')), array(Zend_Validate_Hostname::CHECK_IDN, true, array('bÜrger.de', 'hÃllo.de', 'hÅllo.se')), array(Zend_Validate_Hostname::CHECK_IDN, false, array('hãllo.se', 'bürger.com', 'hãllo.uk')));
// Run test
$ok = true;
foreach ($valuesExpected as $element) {
$validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, $element[0]);
foreach ($element[2] as $input) {
print "{$input} - ";
if ($validator->isValid($input) === $element[1]) {
print 'Pass';
} else {
print 'Fail ' . implode("\n", $validator->getMessages());
$ok = false;
}
print "\n";
}
print "\n";
}
print $ok ? "All tests passed OK :-)\n" : "Some tests failed!\n";
示例9: testIDN
/**
* Ensure the IDN check works as expected
*
*/
public function testIDN()
{
$valuesExpected = array(array(Zend_Validate_Hostname::CHECK_TLD, false, array('bürger.de', 'hãllo.de', 'hållo.se')), array(Zend_Validate_Hostname::CHECK_IDN, true, array('bürger.de', 'hãllo.de', 'hållo.se')), array(Zend_Validate_Hostname::CHECK_IDN, false, array('hãllo.se', 'bürger.com', 'hãllo.uk')));
foreach ($valuesExpected as $element) {
$validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, $element[0]);
foreach ($element[2] as $input) {
$this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages()));
}
}
}
示例10: testGetMessages
/**
* Ensures that getMessages() returns expected default value
*
* @return void
*/
public function testGetMessages()
{
$this->assertEquals(array(), $this->_validator->getMessages());
}
示例11: testDifferentIconvEncoding
/**
* @see ZF-7277
*/
public function testDifferentIconvEncoding()
{
iconv_set_encoding('internal_encoding', 'ISO8859-1');
$validator = new Zend_Validate_Hostname();
$valuesExpected = array(array(true, array('bürger.com', 'hãllo.com', 'hållo.com')), array(true, array('bÜrger.com', 'hÃllo.com', 'hÅllo.com')), array(false, array('hãllo.lt', 'bürger.lt', 'hãllo.lt')));
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
}
示例12: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a valid email address
* according to RFC2822
*
* @link http://www.ietf.org/rfc/rfc2822.txt RFC2822
* @link http://www.columbia.edu/kermit/ascii.html US-ASCII characters
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_messages = array();
$valueString = (string) $value;
// Split email address up
if (!preg_match('/^(.+)@([^@]+)$/', $valueString, $matches)) {
$this->_messages[] = "'{$valueString}' is not a valid email address in the basic format local-part@hostname";
return false;
}
$localPart = $matches[1];
$hostname = $matches[2];
// Match hostname part
$hostnameResult = $this->hostnameValidator->isValid($hostname);
if (!$hostnameResult) {
$this->_messages[] = "'{$hostname}' is not a valid hostname for email address '{$valueString}'";
// Get messages from hostnameValidator
foreach ($this->hostnameValidator->getMessages() as $message) {
$this->_messages[] = $message;
}
}
// MX check on hostname via dns_get_record()
if ($this->_validateMx) {
if ($this->validateMxSupported()) {
$result = dns_get_mx($hostname, $mxHosts);
var_dump($result, $mxHosts);
if (count($result) < 1) {
$hostnameResult = false;
$this->_messages[] = "'{$hostname}' does not appear to have a valid MX record for the email address" . "'{$valueString}'";
}
} else {
/**
* MX checks are not supported by this system
* @see Zend_Validate_Exception
*/
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Internal error: MX checking not available on this system');
}
}
// First try to match the local part on the common dot-atom format
$localResult = false;
// Dot-atom characters are: 1*atext *("." 1*atext)
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
// "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
$atext = 'a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b\\x7c\\x7d';
if (preg_match('/^[' . $atext . ']+(\\x2e+[' . $atext . ']+)*$/', $localPart)) {
$localResult = true;
} else {
$this->_messages[] = "'{$localPart}' not matched against dot-atom format";
}
// If not matched, try quoted string format
if (!$localResult) {
// Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
// qtext: Non white space controls, and the rest of the US-ASCII characters not
// including "\" or the quote character
$noWsCtl = '\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f';
$qtext = $noWsCtl . '\\x21\\x23-\\x5b\\x5d-\\x7e';
$ws = '\\x20\\x09';
if (preg_match('/^\\x22([' . $ws . $qtext . '])*[$ws]?\\x22$/', $localPart)) {
$localResult = true;
} else {
$this->_messages[] = "'{$localPart}' not matched against quoted-string format";
}
}
if (!$localResult) {
$this->_messages[] = "'{$localPart}' is not a valid local part for email address '{$valueString}'";
}
// If both parts valid, return true
if ($localResult && $hostnameResult) {
return true;
} else {
return false;
}
}
示例13: foreach
?>
</h2>
<p><?php
echo $idn ? 'IDN supported' : 'IDN not supported';
?>
</p>
<p>Testing for match in Zend_Validate_Hostname:
<?php
if ($validator->isValid($characters)) {
echo '<strong>Passed</strong>';
} else {
echo "<strong>Failed</strong>, validator messages:<ul>\n";
foreach ($validator->getMessages() as $message) {
echo "<li>{$message}</li>\n";
}
echo "</ul>\n";
}
?>
</p>
<?php
}
?>
<form action="HostnameTestForm.php" method="post">
<fieldset>
<legend>Test IDN domains</legend>
示例14: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a valid email address
*
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$this->_messages = array();
// Split email address up
if (preg_match('/^([^@]+)@([^@]+)$/', $value, $matches)) {
$localPart = $matches[1];
$hostname = $matches[2];
/**
* @todo ZF-42 check isHostname against RFC spec
* @todo ZF-42 implement basic MX check on hostname via dns_get_record()
*/
// Match hostname part
$hostnameResult = $this->_hostnameValidator->isValid($hostname);
if (!$hostnameResult) {
$this->_messages[] = "'{$hostname}' is not a valid hostname for email address '{$value}'";
// Get messages from hostnameValidator
foreach ($this->_hostnameValidator->getMessages() as $message) {
$this->_messages[] = $message;
}
}
// First try to match the local part on the common dot-atom format
$localResult = false;
// Dot-atom characters are:
// ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", "+",
// "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~", "."
// Dot character "." must be surrounded by other non-dot characters
$dotAtom = '[a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27\\x2a\\x2b\\x2d\\x2f\\x3d';
$dotAtom .= '\\x3f\\x5e\\x5f\\x60\\x7b\\x7c\\x7d\\x7e\\x2e]';
if (preg_match('/^' . $dotAtom . '+$/', $localPart) && strpos($localPart, '.') !== 0 && strrpos($localPart, '.') !== strlen($localPart) - 1) {
$localResult = true;
}
/**
* @todo ZF-42 check Quoted-string character class
*/
// If not matched, try quoted string format
if (!$localResult) {
// Quoted-string characters are:
// Any US-ASCII characters except "\" or double-quote "
// DQUOTE *([FWS] qcontent) [FWS] DQUOTE
$quoted = '\\x22[^\\x5c\\x22]+\\x22';
if (preg_match('/^' . $quoted . '$/', $localPart)) {
$localResult = true;
}
}
/**
* @todo ZF-42 check character class, dummy if else statement below to populate error messages
*/
// If not matched, try obsolete format
if (!$localResult) {
if (true === 0) {
} else {
$this->_messages[] = "'{$localPart}' is not a valid local-part according to RFC 2822 for email address '{$value}'";
}
}
// If both parts valid, return true
if ($localResult && $hostnameResult) {
return true;
} else {
return false;
}
} else {
$this->_messages[] = "'{$value}' is not in the valid email address format local-part@hostname";
return false;
}
}
示例15: isValid
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if $value is a valid email address
* according to RFC2822
*
* @link http://www.ietf.org/rfc/rfc2822.txt RFC2822
* @link http://www.columbia.edu/kermit/ascii.html US-ASCII characters
* @param string $value
* @return boolean
*/
public function isValid($value)
{
$valueString = (string) $value;
$matches = array();
$length = true;
$this->_setValue($valueString);
// Split email address up and disallow '..'
if (strpos($valueString, '..') !== false or !preg_match('/^(.+)@([^@]+)$/', $valueString, $matches)) {
$this->_error(self::INVALID);
return false;
}
$this->_localPart = $matches[1];
$this->_hostname = $matches[2];
if (strlen($this->_localPart) > 64 || strlen($this->_hostname) > 255) {
$length = false;
$this->_error(self::LENGTH_EXCEEDED);
}
// Match hostname part
$hostnameResult = $this->hostnameValidator->setTranslator($this->getTranslator())->isValid($this->_hostname);
if (!$hostnameResult) {
$this->_error(self::INVALID_HOSTNAME);
// Get messages and errors from hostnameValidator
foreach ($this->hostnameValidator->getMessages() as $code => $message) {
$this->_messages[$code] = $message;
}
foreach ($this->hostnameValidator->getErrors() as $error) {
$this->_errors[] = $error;
}
} else {
if ($this->_validateMx) {
// MX check on hostname via dns_get_record()
if ($this->validateMxSupported()) {
$result = dns_get_mx($this->_hostname, $mxHosts);
if (count($mxHosts) < 1) {
// the address may can accept email even if there's no MX record but A or A6 or AAAA record found
if ($this->_deepMxCheck && $this->validateDnsSupported()) {
if ($this->isReservedIpAddress($this->_hostname)) {
$hostnameResult = false;
$this->_error(self::INVALID_NETWORK_SEGMENT);
} else {
if (checkdnsrr($this->_hostname, "A") === false && checkdnsrr($this->_hostname, "AAAA") === false && checkdnsrr($this->_hostname, "A6") === false) {
$hostnameResult = false;
$this->_error(self::INVALID_MX_RECORD);
}
}
} else {
$hostnameResult = false;
$this->_error(self::INVALID_MX_RECORD);
}
} else {
// must check every MX record for at least one valid address
if ($this->_deepMxCheck && $this->validateDnsSupported()) {
$hasOneValidAddress = false;
foreach ($mxHosts as $key => $hostname) {
if (!$this->isReservedIpAddress($hostname) && (checkdnsrr($hostname, "A") !== false || checkdnsrr($hostname, "AAAA") !== false || checkdnsrr($hostname, "A6") !== false)) {
$hasOneValidAddress = true;
break;
}
}
if ($hasOneValidAssress === false) {
$hostnameResult = false;
$this->_error(self::INVALID_MX_RECORD);
}
}
}
} else {
/**
* MX checks are not supported by this system
* @see Zend_Validate_Exception
*/
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Internal error: MX checking not available on this system');
}
}
}
// First try to match the local part on the common dot-atom format
$localResult = false;
// Dot-atom characters are: 1*atext *("." 1*atext)
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
// "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
$atext = 'a-zA-Z0-9\\x21\\x23\\x24\\x25\\x26\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b\\x7c\\x7d\\x7e';
if (preg_match('/^[' . $atext . ']+(\\x2e+[' . $atext . ']+)*$/', $this->_localPart)) {
$localResult = true;
} else {
// Try quoted string format
// Quoted-string characters are: DQUOTE *([FWS] qtext/quoted-pair) [FWS] DQUOTE
// qtext: Non white space controls, and the rest of the US-ASCII characters not
// including "\" or the quote character
$noWsCtl = '\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f';
//.........这里部分代码省略.........