Exemple #1
1
 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;
 }
 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 ='*****@*****.**'\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");
         }
     }
 }
 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;
     }
 }
 /**
  * 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;
 }
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;
}
 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;
 }
Exemple #7
0
 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 '';
     }
 }
Exemple #8
0
/**
 * 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;
}
Exemple #9
0
 /**
  * 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);
 }
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;
}
Exemple #11
0
 /**
  * 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;
 }
Exemple #12
0
 /**
  * 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');
 }
Exemple #13
0
 /**
  * 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;
 }
	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;
		}
	}
Exemple #15
0
 /**
  * {@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();
             }
         }
     }
 }
Exemple #16
0
 public function checkDns($host = '', $type = 'MX')
 {
     if (!is_string($host) || !is_string($type)) {
         return Error::set('Error', 'stringParameter', '1.(host) & 2.(type)');
     }
     return checkdnsrr($this->cleanHttp($host), $type);
 }
Exemple #17
0
 public function check($email)
 {
     // Must be more than 9 characters.
     if (strlen($email) < 9) {
         $this->_message = '%s must be larger than 9 characters';
         return false;
     }
     // Must be less than 255 characters
     if (strlen($email) > 255) {
         $this->_message = '%s may only be 255 characters long';
         return false;
     }
     // Must have an @ symbol
     $pos = strpos($email, '@');
     if ($pos === false or $pos === 0) {
         $this->_message = '%s must contain an "@" symbol';
         return false;
     }
     // Must be a valid format
     if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
         $this->_message = '%s is not a valid email address';
         return false;
     }
     list($user, $domain) = explode('@', $email);
     // Perform a DNS check
     if (!checkdnsrr($domain, "MX")) {
         $this->_message = '%s failed our DNS lookup, please enter a currently valid email';
         return false;
     }
     return true;
 }
function xtc_validate_email($email)
{
    //BOF - web28 - 2011-07-31 - SQL nullbyte injection fix 16.02.2011
    if (strpos($email, "") !== false) {
        return false;
    }
    if (strpos($email, "") !== false) {
        return false;
    }
    if (strpos($email, "\\u0000") !== false) {
        return false;
    }
    if (strpos($email, "") !== false) {
        return false;
    }
    //EOF - web28 - 2011-07-31 - SQL nullbyte injection fix 16.02.2011
    $email = trim($email);
    $valid_address = false;
    if (strlen($email) > 255) {
        return false;
    } else {
        // Check for one @
        if (substr_count($email, '@') !== 1) {
            return false;
        }
        $valid_address = true;
    }
    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;
}
Exemple #19
0
 /**
  * Validate the elements data against the rule
  *
  * @param   string  $data           To check
  * @param   int     $repeatCounter  Repeat group counter
  *
  * @return  bool  true if validation passes, false if fails
  */
 public function validate($data, $repeatCounter)
 {
     $email = $data;
     // Could be a drop-down with multi-values
     if (is_array($email)) {
         $email = implode('', $email);
     }
     // Decode as it can be posted via ajax
     // (but first % encode any + characters, as urldecode() will turn + into space)
     $email = urldecode(str_replace('+', '%2B', $email));
     $params = $this->getParams();
     $allow_empty = $params->get('isemail-allow_empty');
     if ($allow_empty == '1' and empty($email)) {
         return true;
     }
     // $$$ hugh - let's try using new helper func instead of rolling our own.
     if (FabrikWorker::isEmail($email)) {
         if ($params->get('isemail-check_mx', '0') === '1') {
             list($user, $domain) = explode('@', $data);
             if (!checkdnsrr($domain, 'MX')) {
                 return false;
             }
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #20
0
 /**
  * Validates an email address
  *
  * @param     string    $email          Email address
  * @param     boolean   $checkDomain    True if dns check should be performed
  * @access    public
  * @return    boolean   true if email is valid
  */
 function validate($email, $checkDomain = false)
 {
     if (function_exists('idn_to_ascii')) {
         if ($parts = explode('@', $email)) {
             if (sizeof($parts) == 2) {
                 foreach ($parts as &$part) {
                     $part = idn_to_ascii($part);
                 }
                 $email = implode('@', $parts);
             }
         }
     }
     // Fix for bug #10799: add 'D' modifier to regex
     if (preg_match($this->regex . 'D', $email)) {
         if ($checkDomain && function_exists('checkdnsrr')) {
             $tokens = explode('@', $email);
             if (checkdnsrr($tokens[1], 'MX') || checkdnsrr($tokens[1], 'A')) {
                 return true;
             }
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #21
0
 /**
  * Validate an email address, assuming the user name has valid characters in it.
  *
  * @param string $email Email address
  * @param bool $network Check to see if the server portion exists and is reachable.
  * @return bool
  */
 public function email($email = '', $network = false)
 {
     if (!Helpers::is_string_ne($email)) {
         $this->error_message = 'Empty input: email';
         return false;
     }
     if (substr_count($email, '@') > 1) {
         $this->error_message = 'More than 1 @ in email';
         return false;
     }
     list($user, $server) = explode('@', $email);
     if (!Helpers::is_string_ne($user)) {
         $this->error_message = 'Empty input: email user portion';
         return false;
     }
     if (!Helpers::is_string_ne($server)) {
         $this->error_message = 'Empty input: email server portion';
         return false;
     }
     if (strlen($server) < 3) {
         $this->error_message = 'Invalid length: email server portion';
         return false;
     }
     $valid = true;
     if ($network === true) {
         $valid = checkdnsrr($server, 'MX');
         if (!$valid) {
             $this->error_message = 'Network error: server portion does not resolve';
         }
     }
     return $valid;
 }
function is_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)
		{
			// local part length exceeded
			$isValid = false;
		}
		else if ($domainLen < 1 || $domainLen > 255)
		{
			// domain part length exceeded
			$isValid = false;
		}
		else if ($local[0] == '.' || $local[$localLen-1] == '.')
		{
			// local part starts or ends with '.'
			$isValid = false;
		}
		else if (preg_match('/\\.\\./', $local))
		{
			// local part has two consecutive dots
			$isValid = false;
		}
		else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
		{
			// character not valid in domain part
			$isValid = false;
		}
		else if (preg_match('/\\.\\./', $domain))
		{
			// domain part has two consecutive dots
			$isValid = false;
		}
		else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local)))
		{
			// character not valid in local part unless 
			// local part is quoted
			if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local)))
				$isValid = false;
		}
		if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
		{
			// domain not found in DNS
			$isValid = false;
		}
	}
	return $isValid;
}
function isemail($email)
{
    if (preg_match("/^[\\w-]+(\\.[\\w-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\\.)+([a-z]{2,4})\$/i", $email)) {
        $parts = explode("@", $email);
        return checkdnsrr($parts[1], "MX");
    }
    return false;
}
Exemple #24
0
 function blacklisted($ip)
 {
     if (!$ip instanceof IP) {
         $ip = new IP($ip);
     }
     $ip = $ip->reverse();
     return checkdnsrr($ip . "." . $this->list . ".", "A");
 }
Exemple #25
0
 private function check_email($param)
 {
     if (checkdnsrr(preg_replace('/^[^@]++@/', '', $param), 'MX')) {
         return true;
     } else {
         return false;
     }
 }
Exemple #26
0
 public function validate($value, $valueIdentifier = null)
 {
     $value = (string) $value;
     $this->value = $value;
     // Check if the email domain has a valid MX record
     $this->success = (bool) checkdnsrr(preg_replace('/^[^@]+@/', '', $value), 'MX');
     return $this->success;
 }
Exemple #27
0
 function _checkdns($host)
 {
     if (function_exists('checkdnsrr')) {
         return checkdnsrr($host);
     } else {
         return $this->_checkdnsrr($host);
     }
 }
Exemple #28
0
 /**
  * Test if e-mail is valid.
  *
  * @param  string $email
  * @return bool
  */
 public static function isValid($email, $domain = false)
 {
     $isValid = filter_var($email, FILTER_VALIDATE_EMAIL);
     if ($isValid and $domain) {
         return checkdnsrr($email);
     }
     return is_string($isValid);
 }
 function main($params)
 {
     if ($_POST['send']) {
         $mail = $_POST['mail'];
         list($userName, $mailDomain) = split("@", $mail['add']);
         if (checkdnsrr($mailDomain, "MX")) {
             // eMail-Adresse des Absenders zusammensetzen
             // this is a valid email domain!
             $sender = $mail['add'];
             // Eventuell den Namen für das From-Statement davorkleben
             if (sizeof($mail['name']) > 0) {
                 $fullsender = '"' . $mail['name'] . '" <' . $sender . '>';
             }
             // eMail-Adresse des Empfängers
             $mailto = $this->extConfig['params']['to'];
             // Betreffzeile zusammenbauen
             $subject = $this->extConfig['params']['subject'] . ": " . $mail['subject'];
             // Header zusammenbasteln
             $header = 'Content-Type: text/plain; charset="us-ascii"' . "\n";
             $header .= 'Content-Transfer-Encoding: 7bit' . "\n";
             $header .= 'FROM: ' . $fullsender . "\n";
             // Message eintragen
             $msg = $mail['text'] . "\n\n";
             // Infos über den Nutzer sammeln
             $msg .= "Zusätzliche Informationen (maschinell gesammelt):\n\n";
             $msg .= "Sollten Sie die Antworten-Funktion Ihres Mailprogramms nutzen, so achten Sie\n";
             $msg .= "darauf, dass die folgenden Informationen nicht zum Kunden gesendet werden.\n";
             $msg .= "Er hat sie zwar freiwillig angegeben,ist sich dessen aber wahrscheinlich nicht \n";
             $msg .= "bewußt. Er würde sich mit Sicherheit über die Erhebung dieser Daten wundern.\n\n";
             $referer = $mail['referer'];
             if (strlen($referer) > 0) {
                 $msg .= "Der Kunde hat das Formular von dieser Adresse aus aufgerufen: " . $referer . "\n";
             }
             $browser = $_SERVER['HTTP_USER_AGENT'];
             if (strlen($browser) > 0) {
                 $msg .= "Der Kunde benutzte diesen Browser: " . $browser . "\n";
             }
             $ip = $_SERVER['REMOTE_ADDR'];
             $host = gethostbyaddr($ip);
             if (strlen($host) > 0) {
                 $msg .= "Der Kunde kommt über diesen Rechner ins Internet: " . $host . " (" . $ip . ")\n";
             }
             mail($mailto, $subject, $msg, $header);
             return $this->smarty->fetch("mailform/tpl/sended.tpl");
         } else {
             $this->smarty->assign("referer", $mail['referer']);
         }
         $this->smarty->assign("name", $mail['name']);
         $this->smarty->assign("add", "UNGÜLTIGE E-MAIL");
         $this->smarty->assign("subject", $mail['subject']);
         $this->smarty->assign("text", $mail['text']);
         return $this->smarty->fetch("mailform/tpl/mailform.tpl");
     } else {
         $this->smarty->assign("self", $_SERVER['REQUEST_URI']);
         $this->smarty->assign("referer", $_SERVER['HTTP_REFERER']);
         return $this->smarty->fetch("mailform/tpl/mailform.tpl");
     }
 }
Exemple #30
0
 public static function verifyAddress($email)
 {
     if (preg_match("/[0-9a-zA-Z@\\.\\!#\$%\\&\\*+_\\~\\?\\-]/", $email)) {
         $email_parts = explode("@", $email);
         return checkdnsrr(array_pop($email_parts), "MX");
     } else {
         return false;
     }
 }