本文整理汇总了PHP中checkdnsrr函数的典型用法代码示例。如果您正苦于以下问题:PHP checkdnsrr函数的具体用法?PHP checkdnsrr怎么用?PHP checkdnsrr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkdnsrr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid(AnnotatedInterface $model, $attribute)
{
if ($this->allowEmpty && empty($model->{$attribute})) {
return true;
}
$label = ManganMeta::create($model)->field($attribute)->label;
if (!is_scalar($model->{$attribute})) {
$this->addError('msgValid', ['{attribute}' => $label]);
return false;
}
if (!preg_match($this->pattern, $model->{$attribute})) {
$this->addError('msgValid', ['{attribute}' => $label]);
return false;
}
$domain = rtrim(substr($model->{$attribute}, strpos($model->{$attribute}, '@') + 1), '>');
if ($this->checkMX) {
if (function_exists('checkdnsrr')) {
if (!checkdnsrr($domain, 'MX')) {
$this->addError('msgDomain', ['{domain}' => $domain]);
return false;
}
}
}
if ($this->checkPort) {
if ($this->checkMxPorts($domain)) {
$this->addError('msgPort', ['{domain}' => $domain]);
return false;
}
}
return true;
}
示例2: send
function send($newsletter_id)
{
// # routine for selecting and adding appropriate user select into newsletters_queue table of database.
//tep_db_query("DELETE FROM newsletter_queue WHERE newsletters_id = ".(int)$newsletter_id);
// # SELECT only retail customers price group who are NOT amazon customers and who ARE subscribed.
$mail_query = tep_db_query("SELECT c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address \n\t\t\t\t\t\t\t\t FROM " . TABLE_CUSTOMERS . " c\n\t\t\t\t\t\t\t\t\tWHERE c.customers_email_address ='chrisd@zwaveproducts.com'\n\t\t\t\t\t\t\t\t ");
// # set the status of the existing newsletter back to pending - wont send if it's in completed status
tep_db_query("UPDATE " . TABLE_NEWSLETTERS . " SET status='pending' WHERE newsletters_id = " . (int) $newsletter_id);
$known_domains = array('gmail.com', 'yahoo.com', 'hotmail.com', 'aol.com');
while ($mail = tep_db_fetch_array($mail_query)) {
$ok_insert = false;
preg_match('/@(.*)/', $mail['customers_email_address'], $domain);
if (in_array($domain[1], $known_domains)) {
$ok_insert = true;
} else {
if (checkdnsrr($domain[1], "MX")) {
$ok_insert = true;
}
}
if ($ok_insert) {
$known_domains[] = $domain[1];
// # routine for adding appropriate user select into newsletter_queue table of database.
tep_db_query("INSERT IGNORE INTO newsletter_queue \n\t\t\t\t\t\t\t SET newsletters_id = '" . (int) $newsletter_id . "',\n\t\t\t\t\t\t\t user_id = '" . (!empty($mail['customers_id']) ? $mail['customers_id'] : '0') . "',\n\t\t\t\t\t\t\t firstname = '" . mysql_real_escape_string($mail['customers_firstname']) . "',\n\t\t\t\t\t\t\t lastname = '" . mysql_real_escape_string($mail['customers_lastname']) . "',\n\t\t\t\t\t\t\t email = '" . $mail['customers_email_address'] . "',\n\t\t\t\t\t\t\t updated = NOW(),\n\t\t\t\t\t\t\t status = 'pending'\n\t\t\t\t\t\t\t");
}
}
}
示例3: email
public function email()
{
$isValid = true;
$atIndex = strrpos($this->data, "@");
if (is_bool($atIndex) && !$atIndex) {
$isValid = false;
} else {
$domain = substr($this->data, $atIndex + 1);
$local = substr($this->data, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64) {
$isValid = false;
} elseif ($domainLen < 1 || $domainLen > 255) {
$isValid = false;
} elseif ($local[0] == '.' || $local[$localLen - 1] == '.') {
$isValid = false;
} elseif (preg_match('/\\.\\./', $local)) {
$isValid = false;
} elseif (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
$isValid = false;
} elseif (preg_match('/\\.\\./', $domain)) {
$isValid = false;
} elseif (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
$isValid = false;
}
return $isValid;
}
}
示例4: checkDNS_record
/**
* Check if are any DNS records corresponding to a given Internet host name or IP address
* @param string $hostname Host name or IP address
* @return boolean TRUE if any records are found or FALSE if no records were found or if an error occurred
*/
function checkDNS_record($hostname = '')
{
$result = false;
$hostname = strtolower(trim($hostname));
if ($hostname != '') {
if (function_exists('checkdnsrr')) {
// Non-Windows platform
$result = checkdnsrr($hostname, 'ANY');
} else {
// Windows platform
$output = null;
@exec('nslookup.exe -type=ANY ' . $hostname, $output);
if (!empty($output)) {
foreach ($output as $line) {
if (0 === strpos(strtolower($line), $hostname)) {
// DNS record found
$result = true;
break;
}
}
}
}
}
return $result;
}
示例5: tep_validate_email
function tep_validate_email($email)
{
$email = trim($email);
if (strlen($email) > 255) {
$valid_address = false;
} elseif (function_exists('filter_var') && defined('FILTER_VALIDATE_EMAIL')) {
$valid_address = (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
} else {
if (substr_count($email, '@') > 1) {
$valid_address = false;
}
if (preg_match("/[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+\\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i", $email)) {
$valid_address = true;
} else {
$valid_address = false;
}
}
if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') {
$domain = explode('@', $email);
if (!checkdnsrr($domain[1], "MX") && !checkdnsrr($domain[1], "A")) {
$valid_address = false;
}
}
return $valid_address;
}
示例6: formCheck
function formCheck()
{
$error_message = "";
// Validate that expected data exists
if (!isset($_POST['email']) || !isset($_POST['url'])) {
$error_message .= "Il manque des champs dans le formulaire fourni";
return;
}
$email = $_POST['email'];
// required
$antispam = $_POST['url'];
// required to be empty
// Check the email syntax is valid
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error_message .= "La syntaxe de votre adresse email est incorrecte.<br />";
} else {
// Check that the email domain has a MX record
$email_domain = substr(strrchr($email, "@"), 1);
if (!checkdnsrr($email_domain, 'MX')) {
$error_message .= "Le domaine de l'adresse email est invalide (pas de MX record).<br />";
}
}
// Check antispam is empty
if (strlen($antispam) > 0) {
$error_message .= "Sneaky spammer ! This will go in /dev/null !<br />";
}
return $error_message;
}
示例7: rbl_lookup
function rbl_lookup($rbl_host)
{
if (empty($rbl_host)) {
return '';
}
/* gethostbyname() seems to hate hostnames with "/" in
if we have a "/" in the host, look it up this way
instead which works but doesn't give us the returned data.
dns_get_record() relies on PHP5 so I'm not going to use it */
if (strpos($rbl_host, '/') !== false) {
//BUT WAIT, checkdnsrr() is only available on UNIX
if (function_exists('checkdnsrr')) {
$this->log_msg(sprintf(__("%s has a slash in it; falling back to checkdnsrr :(", 'sk2'), $rbl_host), 0);
if (checkdnsrr($rbl_host, "A")) {
return "127.0.133.7";
//fake a reply (mmm, 1337)
} else {
//not listed
return '';
}
} else {
//no checkdnsrr :( we'll have to fail-safe
return '';
}
}
//no "/" in the host, so we'll do it the usual way
$get_host = gethostbyname($rbl_host);
$this->log_msg(sprintf(__("rbl_lookup: lookup for %s returned %s", 'sk2'), $rbl_host, $get_host), 2);
if ($get_host && $get_host != $rbl_host && $rbl_host != $_SERVER['HTTP_HOST'] && $rbl_host != $_SERVER['SERVER_ADDR'] && strncmp($rbl_host, "127.", 4) == 0) {
return $get_host;
} else {
return '';
}
}
示例8: valid_email
/**
* Validate the user's email address.
* Courtesy LinuxJournal.com : http://www.linuxjournal.com/article/9585?page=0,3
*
* @param $email The email address to validate.
*/
function valid_email($email)
{
$isValid = TRUE;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex) {
$isValid = FALSE;
} else {
$domain = substr($email, $atIndex + 1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64) {
$isValid = FALSE;
} elseif ($domainLen < 1 || $domainLen > 255) {
$isValid = FALSE;
} elseif ($local[0] == '.' || $local[$localLen - 1] == '.') {
$isValid = FALSE;
} elseif (preg_match('/\\.\\./', $local)) {
$isValid = FALSE;
} elseif (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
$isValid = FALSE;
} elseif (preg_match('/\\.\\./', $domain)) {
$isValid = FALSE;
} elseif (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", '', $local))) {
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", '', $local))) {
$isValid = FALSE;
}
}
if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
$isValid = FALSE;
}
}
return (bool) $isValid;
}
示例9: validate
/**
* checks if given value is a valid email address
*
* @link http://iamcal.com/publish/articles/php/parsing_email/pdf/
* @param mixed $value
* @return boolean
*/
public function validate($value)
{
if (empty($value)) {
return true;
}
if (isset($this->args)) {
$parts = explode('@', $value);
if (isset($parts[1]) && function_exists('checkdnsrr')) {
if (!checkdnsrr($parts[1], 'MX')) {
return false;
}
}
}
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quotedPair = '\\x5c[\\x00-\\x7f]';
$domainLiteral = "\\x5b({$dtext}|{$quotedPair})*\\x5d";
$quotedString = "\\x22({$qtext}|{$quotedPair})*\\x22";
$domain_ref = $atom;
$subDomain = "({$domain_ref}|{$domainLiteral})";
$word = "({$atom}|{$quotedString})";
$domain = "{$subDomain}(\\x2e{$subDomain})+";
/*
following pseudocode to allow strict checking - ask pookey about this if you're puzzled
if ($this->getValidationOption('strict_checking') == true) {
$domain = "$sub_domain(\\x2e$sub_domain)*";
}
*/
$localPart = "{$word}(\\x2e{$word})*";
$addrSpec = "{$localPart}\\x40{$domain}";
return (bool) preg_match("!^{$addrSpec}\$!D", $value);
}
示例10: phorum_valid_email
function phorum_valid_email($email)
{
$PHORUM = $GLOBALS["PHORUM"];
$ret = false;
$email = trim($email);
if (preg_match('/^([a-z0-9\\!\\#\\$\\%\\&\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+(\\.[a-z0-9\\!\\#\\$\\%\\&\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+)*)@(((([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\]))\\.)*((([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\\]))$/i', $email)) {
if (!$PHORUM["dns_lookup"]) {
// format is valid
// don't look up mail server
$ret = true;
} elseif (function_exists('checkdnsrr')) {
$fulldomain = substr(strstr($email, "@"), 1) . ".";
// check if a mailserver exists for the domain
if (checkdnsrr($fulldomain, "MX")) {
$ret = true;
}
// some hosts don't have an MX record, but accept mail themselves
if (!$ret) {
// default timeout of 60 seconds makes the user way too long
// in case of problems.
ini_set('default_socket_timeout', 10);
if (@fsockopen($fulldomain, 25)) {
$ret = true;
}
}
} else {
// bah, you must be using windows and we can't run real checks
$ret = true;
}
}
return $ret;
}
示例11: _check_dnsbls
/**
* Checks major dns-blacklists and adds to error log if found
* @author GJE and mix of suggestions from: http://php.net/manual/en/function.checkdnsrr.php
* @return bool
*/
function _check_dnsbls()
{
$results = array();
if ($this->_rip) {
$this->__ez_debug("timemark");
$dnsbls = array('sbl.spamhaus.org' => 'http://www.spamhaus.org/sbl/delistingprocedure.html');
if ($this->use_strong_verification) {
$dnsbls['xbl.spamhaus.org'] = 'http://www.spamhaus.org/lookup.lasso';
}
foreach ($dnsbls as $dnsbl => $dnsbl_removal_url) {
$this->__ez_debug("Checking DNSBL: {$dnsbl}.");
$this->__ez_debug("network-connection: checkdnsrr");
if (checkdnsrr($this->_rip . '.' . $dnsbl . '.', 'A')) {
$this->__ez_debug("FAIL: ip address `{$this->ip}` is on blacklist {$dnsbl}.");
list($usec, $sec) = explode(" ", microtime());
$debug_time = $sec . substr($usec, 1, 7);
$this->debug_messages[$debug_time][__CLASS__ . '::' . __FUNCTION__ . '#' . __LINE__] = array($dnsbl => $this->_rip . '.' . $dnsbl);
$this->errors[(string) microtime(true)] = array('failed-dnsbl-check' => "IP address `{$this->ip}` is on blacklist `{$dnsbl}`. For information about this blacklist and removing your IP address from it please see: {$dnsbl_removal_url}");
$this->_bad_ip = true;
break;
}
}
$this->__ez_debug("timemark");
}
return $results;
}
示例12: checkMX
/**
* Check DNS Records for MX type.
*
* @param string $host Host name
*
* @return Boolean
*/
private function checkMX($host)
{
if (function_exists('checkdnsrr')) {
return checkdnsrr($host, 'MX');
}
throw new ValidatorError('Could not retrieve DNS record information. Remove check_mx = true to prevent this warning');
}
示例13: isValidEmail
/**
* implementation of isValidEmail by linuxjournal.
* @link http://www.linuxjournal.com/article/9585?page=0,3
* @return boolean
*/
private function isValidEmail($email, $remoteCheck)
{
// check for all the non-printable codes in the standard ASCII set,
// including null bytes and newlines, and exit immediately if any are found.
if (preg_match("/[\\000-\\037]/", $email)) {
return false;
}
$pattern = "/^[-_a-z0-9\\'+*\$^&%=~!?{}]++(?:\\.[-_a-z0-9\\'+*\$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\\.[a-z]{2,6}|\\d{1,3}(?:\\.\\d{1,3}){3})(?::\\d++)?\$/iD";
if (!preg_match($pattern, $email)) {
return false;
}
if ($remoteCheck === true) {
// Validate the domain exists with a DNS check
// if the checks cannot be made (soft fail over to true)
list($user, $domain) = explode('@', $email);
if (function_exists('checkdnsrr')) {
if (!checkdnsrr($domain, "MX")) {
// Linux: PHP 4.3.0 and higher & Windows: PHP 5.3.0 and higher
return false;
}
} else {
if (function_exists("getmxrr")) {
if (!getmxrr($domain, $mxhosts)) {
return false;
}
}
}
}
return true;
}
示例14: email
static function email($email)
{
$isValid = true;
$atIndex = strrpos($email, '@');
if (is_bool($atIndex) && !$atIndex)
{
return false;
}
else
{
$domain = substr($email, $atIndex + 1);
$local = substr($email, 0, $atIndex);
$validLocalLength = validate::length($local, 1, 64);
$validDomainLength = validate::length($domain, 1, 255);
$validStartFinish = !($local[0] == '.' || $local[strlen($local) - 1] == '.');
$validLocalDots = !(preg_match('/\\.\\./', $local) || preg_match( '/\\.$/', $local ));
$validDomainCharacters = preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain);
$validDomainDots = !preg_match('/\\.\\./', $domain);
$validLocalCharacters = !(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local)) && !preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)));
$validMailRecord = checkdnsrr($domain, 'MX') || checkdnsrr($domain, 'A');
return $validLocalLength && $validDomainLength && $validStartFinish && $validLocalDots && $validDomainCharacters && $validDomainDots && $validLocalCharacters && $validMailRecord;
}
}
示例15: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Url) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\Url');
}
if (null === $value) {
return;
}
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedTypeException($value, 'string');
}
$value = (string) $value;
if ('' === $value) {
return;
}
$pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols));
if (!preg_match($pattern, $value)) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->addViolation();
} else {
$this->buildViolation($constraint->message)->setParameter('{{ value }}', $this->formatValue($value))->addViolation();
}
return;
}
if ($constraint->checkDNS) {
$host = parse_url($value, PHP_URL_HOST);
if (!checkdnsrr($host, 'ANY')) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context->buildViolation($constraint->dnsMessage)->setParameter('{{ value }}', $this->formatValue($host))->addViolation();
} else {
$this->buildViolation($constraint->dnsMessage)->setParameter('{{ value }}', $this->formatValue($host))->addViolation();
}
}
}
}