| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | +defined('ABSPATH') || die('Restricted Access'); | |
| 2 | 3 | |
| 3 | 4 | function acym_getEmailRegex(bool $secureJS = false, bool $forceRegex = false): string |
| 4 | 5 | { |
| 5 | 6 | $config = acym_config(); |
| @@ -29,8 +30,9 @@ | ||
| 29 | 30 | if (!$extended) { |
| 30 | 31 | return true; |
| 31 | 32 | } |
| 32 | 33 | |
| 34 | + //Now we do an extended verification... | |
| 33 | 35 | |
| 34 | 36 | $config = acym_config(); |
| 35 | 37 | |
| 36 | 38 | if ($config->get('email_checkdomain', false) && function_exists('getmxrr')) { |
| @@ -35,14 +37,22 @@ | ||
| 35 | 37 | |
| 36 | 38 | if ($config->get('email_checkdomain', false) && function_exists('getmxrr')) { |
| 37 | 39 | $domain = substr($email, strrpos($email, '@') + 1); |
| 38 | 40 | $mxhosts = []; |
| 41 | + //Check if the domain exists | |
| 39 | 42 | $checkDomain = getmxrr($domain, $mxhosts); |
| 43 | + //Sometimes the returned host is checkyouremailaddress-hostnamedoesnotexist262392208.com ... not sure why! | |
| 44 | + //But we remove it if it's the case... | |
| 40 | 45 | if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) { |
| 41 | 46 | array_shift($mxhosts); |
| 42 | 47 | } |
| 43 | 48 | if (!$checkDomain || empty($mxhosts)) { |
| 49 | + //Lets check with another function in case of... | |
| 44 | 50 | $dns = @dns_get_record($domain, DNS_A); |
| 51 | + if (empty($dns)) { | |
| 52 | + return false; | |
| 53 | + } | |
| 54 | + | |
| 45 | 55 | $domainChanged = true; |
| 46 | 56 | foreach ($dns as $oneRes) { |
| 47 | 57 | if (strtolower($oneRes['host']) == strtolower($domain)) { |
| 48 | 58 | $domainChanged = false; |
| @@ -47,21 +57,21 @@ | ||
| 47 | 57 | if (strtolower($oneRes['host']) == strtolower($domain)) { |
| 48 | 58 | $domainChanged = false; |
| 49 | 59 | } |
| 50 | 60 | } |
| 51 | - if (empty($dns) || $domainChanged) { | |
| 61 | + | |
| 62 | + if ($domainChanged) { | |
| 52 | 63 | return false; |
| 53 | 64 | } |
| 54 | 65 | } |
| 55 | 66 | } |
| 56 | 67 | |
| 57 | - $object = new stdClass(); | |
| 58 | - $object->IP = acym_getIP(); | |
| 59 | - $object->emailAddress = $email; | |
| 68 | + $ip = acym_getIP(); | |
| 60 | 69 | |
| 61 | - if ($config->get('email_iptimecheck', 0)) { | |
| 70 | + // Check IP to limit subscription to max 3 per 2 hours | |
| 71 | + if (!empty($ip) && $config->get('email_iptimecheck', 0)) { | |
| 62 | 72 | $lapseTime = time() - 7200; |
| 63 | - $nbUsers = acym_loadResult('SELECT COUNT(*) FROM #__acym_user WHERE creation_date > '.intval($lapseTime).' AND ip = '.acym_escapeDB($object->IP)); | |
| 73 | + $nbUsers = acym_loadResult('SELECT COUNT(*) FROM #__acym_user WHERE creation_date > '.intval($lapseTime).' AND ip = '.acym_escapeDB($ip)); | |
| 64 | 74 | if ($nbUsers >= 3) { |
| 65 | 75 | return false; |
| 66 | 76 | } |
| 67 | 77 | } |