function validEmail($email, $extended = false) { if (empty($email) or !is_string($email)) { return false; } if (!preg_match('/^([a-z0-9_\'&\\.\\-\\+=])+\\@(([a-z0-9\\-])+\\.)+([a-z0-9]{2,10})+$/i', $email)) { return false; } if (!$extended) { return true; } $config = acymailing_config(); if ($config->get('email_checkpopmailclient', false)) { if (preg_match('#^.{1,5}@(gmail|yahoo|aol|hotmail|msn|ymail)#i', $email)) { return false; } } if ($config->get('email_checkdomain', false) and function_exists('getmxrr')) { $domain = substr($email, strrpos($email, '@') + 1); $mxhosts = array(); $checkDomain = getmxrr($domain, $mxhosts); if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) { array_shift($mxhosts); } if (!$checkDomain || empty($mxhosts)) { $dns = @dns_get_record($domain, DNS_A); if (empty($dns)) { return false; } } } $object = new stdClass(); $object->IP = $this->getIP(); $object->emailAddress = $email; if ($config->get('email_botscout', false)) { $botscoutClass = new acybotscout(); $botscoutClass->apiKey = $config->get('email_botscout_key'); if (!$botscoutClass->getInfo($object)) { return false; } } if ($config->get('email_stopforumspam', false)) { $email_stopforumspam = new acystopforumspam(); if (!$email_stopforumspam->getInfo($object)) { return false; } } if ($config->get('email_iptimecheck', 0)) { $lapseTime = time() - 7200; $db = JFactory::getDBO(); $db->setQuery('SELECT COUNT(*) FROM #__acymailing_subscriber WHERE created > ' . intval($lapseTime) . ' AND ip = ' . $db->Quote($object->IP)); $nbUsers = $db->loadResult(); if ($nbUsers >= 3) { return false; } } return true; }
function validEmail($email, $extended = false) { if (empty($email) or !is_string($email)) { return false; } if (!preg_match('/^([a-z0-9_\'&\\.\\-\\+=])+\\@(([a-z0-9\\-])+\\.)+([a-z0-9]{2,10})+$/i', $email)) { return false; } if (!$extended) { return true; } $config = acymailing_config(); if ($config->get('email_checkpopmailclient', false)) { if (preg_match('#^.{1,5}@(gmail|yahoo|aol|hotmail|msn|ymail)#i', $email)) { return false; } } if ($config->get('email_checkdomain', false) and function_exists('getmxrr')) { $domain = substr($email, strrpos($email, '@') + 1); $mxhosts = array(); $checkDomain = getmxrr($domain, $mxhosts); if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) { array_shift($mxhosts); } if (!$checkDomain || empty($mxhosts)) { $dns = @dns_get_record($domain, DNS_A); if (empty($dns)) { return false; } } } $object = new stdClass(); $object->IP = $this->getIP(); $object->emailAddress = $email; if ($config->get('email_botscout', false)) { $botscoutClass = new acybotscout(); $botscoutClass->apiKey = $config->get('email_botscout_key'); if (!$botscoutClass->getInfo($object)) { return false; } } if ($config->get('email_stopforumspam', false)) { $email_stopforumspam = new acystopforumspam(); if (!$email_stopforumspam->getInfo($object)) { return false; } } return true; }