PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.0.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.0.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Helpers / global / email.php

email.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.0.1, at back/Helpers/global/email.php

86 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function acym_getEmailRegex($secureJS = false, $forceRegex = false)
4 {
5 $config = acym_config();
6 if ($forceRegex || $config->get('special_chars', 0) == 0) {
7 $regex = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*\@([a-z0-9-]+\.)+[a-z0-9]{2,20}';
8 } else {
9 $regex = '.+\@(.+\.)+.{2,20}';
10 }
11
12 if ($secureJS) {
13 $regex = str_replace(['"', "'"], ['\"', "\'"], $regex);
14 }
15
16 return $regex;
17 }
18
19 function acym_isValidEmail($email, $extended = false)
20 {
21 if (empty($email) || !is_string($email)) {
22 return false;
23 }
24
25 if (!preg_match('/^'.acym_getEmailRegex().'$/i', $email)) {
26 return false;
27 }
28
29 if (!$extended) {
30 return true;
31 }
32
33
34 $config = acym_config();
35
36 if ($config->get('email_checkdomain', false) && function_exists('getmxrr')) {
37 $domain = substr($email, strrpos($email, '@') + 1);
38 $mxhosts = [];
39 $checkDomain = getmxrr($domain, $mxhosts);
40 if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) {
41 array_shift($mxhosts);
42 }
43 if (!$checkDomain || empty($mxhosts)) {
44 $dns = @dns_get_record($domain, DNS_A);
45 $domainChanged = true;
46 foreach ($dns as $oneRes) {
47 if (strtolower($oneRes['host']) == strtolower($domain)) {
48 $domainChanged = false;
49 }
50 }
51 if (empty($dns) || $domainChanged) {
52 return false;
53 }
54 }
55 }
56
57 $object = new stdClass();
58 $object->IP = acym_getIP();
59 $object->emailAddress = $email;
60
61 if ($config->get('email_iptimecheck', 0)) {
62 $lapseTime = time() - 7200;
63 $nbUsers = acym_loadResult('SELECT COUNT(*) FROM #__acym_user WHERE creation_date > '.intval($lapseTime).' AND ip = '.acym_escapeDB($object->IP));
64 if ($nbUsers >= 3) {
65 return false;
66 }
67 }
68
69 return true;
70 }
71
72 function acym_isPunycode($email)
73 {
74 return strpos($email, '@xn--') !== false;
75 }
76
77 function acym_getDomain($email)
78 {
79 if (!is_string($email)) return '';
80
81 $aPos = strrpos($email, '@');
82 if (empty($aPos)) return '';
83
84 return substr($email, $aPos + 1);
85 }
86