Add a better way to correct email - to test
This commit is contained in:
parent
62139fe9fd
commit
d1d0642f91
@ -83,15 +83,113 @@ if($canSendInvitations) {
|
||||
$friendsFirstName = Tools::getValue('friendsFirstName');
|
||||
$mails_exists = array();
|
||||
foreach ($friendsEmail AS $key => $friendEmail) {
|
||||
$friendEmail = strval($friendEmail);
|
||||
$friendEmail = trim($friendEmail);
|
||||
/** @Override Antadis - mail fixing */
|
||||
$friendEmail = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.',$friendEmail);
|
||||
$friendEmail = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.',$friendEmail);
|
||||
$friendEmail = str_replace('@gmailcom','@gmail.com',$friendEmail);
|
||||
$friendEmail = str_replace('@hotmailcom','@hotmail.com',$friendEmail);
|
||||
$friendEmail = str_replace('@hotmailfr','@hotmail.fr',$friendEmail);
|
||||
/** @End Override Antadis - mail fixing */
|
||||
$friendEmail = $emailOri = strtolower(trim(strval($friendEmail)));
|
||||
|
||||
// Prepare Check email
|
||||
$domains = array(
|
||||
/* Default domains included */
|
||||
"aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
|
||||
"google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
|
||||
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk",
|
||||
|
||||
/* Other global domains */
|
||||
"email.com", "fastmail.fm", "games.com" /* AOL */, "gmx.net", "hush.com", "hushmail.com", "icloud.com",
|
||||
"iname.com", "inbox.com", "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "protonmail.com",
|
||||
"rocketmail.com" /* Yahoo */, "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */,
|
||||
"ymail.com" /* Yahoo */, "zoho.com", "yandex.com",
|
||||
|
||||
/* United States ISP domains */
|
||||
"bellsouth.net", "charter.net", "cox.net", "earthlink.net", "juno.com",
|
||||
|
||||
/* British ISP domains */
|
||||
"btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
|
||||
"ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
|
||||
"virgin.net", "wanadoo.co.uk", "bt.com",
|
||||
|
||||
/* Domains used in Asia */
|
||||
"sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com", "yahoo.co.jp", "yahoo.co.kr", "yahoo.co.id", "yahoo.co.in", "yahoo.com.sg", "yahoo.com.ph",
|
||||
|
||||
/* French ISP domains */
|
||||
"hotmail.fr", "live.fr", "laposte.net", "yahoo.fr", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",
|
||||
|
||||
/* German ISP domains */
|
||||
"gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de", "yahoo.de",
|
||||
|
||||
/* Italian ISP domains */
|
||||
"libero.it", "virgilio.it", "hotmail.it", "aol.it", "tiscali.it", "alice.it", "live.it", "yahoo.it", "email.it", "tin.it", "poste.it", "teletu.it",
|
||||
|
||||
/* Russian ISP domains */
|
||||
"mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",
|
||||
|
||||
/* Belgian ISP domains */
|
||||
"hotmail.be", "live.be", "skynet.be", "voo.be", "tvcablenet.be", "telenet.be",
|
||||
|
||||
/* Argentinian ISP domains */
|
||||
"hotmail.com.ar", "live.com.ar", "yahoo.com.ar", "fibertel.com.ar", "speedy.com.ar", "arnet.com.ar",
|
||||
|
||||
/* Domains used in Mexico */
|
||||
"yahoo.com.mx", "live.com.mx", "hotmail.es", "hotmail.com.mx", "prodigy.net.mx",
|
||||
|
||||
/* Domains used in Brazil */
|
||||
"yahoo.com.br", "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br"
|
||||
);
|
||||
|
||||
// Real association
|
||||
$replaceSLD = array(
|
||||
'@hotmil.' => '@hotmail.',
|
||||
'@htmail.' => '@hotmail.',
|
||||
'@hotmal.' => '@hotmail.',
|
||||
'@hotml.' => '@hotmail.',
|
||||
'@hotmai.' => '@hotmail.',
|
||||
'@gmal.' => '@gmail.',
|
||||
'@gail.' => '@gmail.',
|
||||
'@gml.' => '@gmail.',
|
||||
'@gmai.' => '@gmail.',
|
||||
'@gmil.' => '@gmail.',
|
||||
);
|
||||
|
||||
$replaceGlobal = array(
|
||||
'@gmailcom' => '@gmail.com',
|
||||
'@hotmailcom' => '@hotmail.com',
|
||||
'@hotmailfr' => '@hotmail.fr',
|
||||
);
|
||||
// Real use case replacement
|
||||
$friendEmail = strtr($friendEmail, $replaceGlobal);
|
||||
|
||||
// Check TLD
|
||||
$atPos = strpos($friendEmail, '@');
|
||||
$pointPos = strpos($friendEmail, '.', $atPos);
|
||||
$tld = substr($friendEmail, $pointPos + 1);
|
||||
$sld = substr($friendEmail, $atPos + 1, strlen($friendEmail) - ($atPos+1) - (strlen($tld)+1) );
|
||||
if (empty($tld)) {
|
||||
$this->errors[] = Tools::displayError('Invalid email');
|
||||
$_POST['email'] = '';
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
// If you have a complete list of TLD, check it !
|
||||
}
|
||||
|
||||
// Check SLD
|
||||
if (empty($this->errors)) {
|
||||
// Real use case replacement
|
||||
$friendEmail = strtr($friendEmail, $replaceSLD);
|
||||
// Levenhstein remplacement
|
||||
if (count($domains) > 0 && $friendEmail == $emailOri) {
|
||||
foreach ($domains as $d) {
|
||||
$dpPos = strpos($d, '.');
|
||||
$realDomain = substr($d, 0, $dpPos);
|
||||
$lev = levenshtein($sld, $realDomain);
|
||||
if ($lev == O) {
|
||||
break;
|
||||
}
|
||||
elseif ($lev == 1 && $tld == substr($d, $dpPos+1)) {
|
||||
$friendEmail = str_replace('@'.$sld.'.', '@'.$realDomain.'.', $friendEmail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($askName) {
|
||||
$friendLastName = strval($friendsLastName[$key]);
|
||||
$friendFirstName = strval($friendsFirstName[$key]);
|
||||
|
@ -114,15 +114,112 @@ class AuthController extends AuthControllerCore
|
||||
if (Tools::getValue('guest_email') !== false) {
|
||||
$email = Tools::getValue('guest_email');
|
||||
}
|
||||
$email = strtolower(trim($email));
|
||||
$email = $emailOri = strtolower(trim($email));
|
||||
|
||||
/** @Override Antadis - mail fixing */
|
||||
$email = str_replace(array('@hotmil.','@htmail.','@hotmal.','@hotml.','@hotmai.'),'@hotmail.', $email);
|
||||
$email = str_replace(array('@gmal.','@gail.','@gml.','@gmai.','@gmil.'),'@gmail.', $email);
|
||||
$email = str_replace('@gmailcom','@gmail.com', $email);
|
||||
$email = str_replace('@hotmailcom','@hotmail.com', $email);
|
||||
$email = str_replace('@hotmailfr','@hotmail.fr', $email);
|
||||
/** @End Override Antadis - mail fixing */
|
||||
// Prepare Check email
|
||||
$domains = array(
|
||||
/* Default domains included */
|
||||
"aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
|
||||
"google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
|
||||
"live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk",
|
||||
|
||||
/* Other global domains */
|
||||
"email.com", "fastmail.fm", "games.com" /* AOL */, "gmx.net", "hush.com", "hushmail.com", "icloud.com",
|
||||
"iname.com", "inbox.com", "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "protonmail.com",
|
||||
"rocketmail.com" /* Yahoo */, "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */,
|
||||
"ymail.com" /* Yahoo */, "zoho.com", "yandex.com",
|
||||
|
||||
/* United States ISP domains */
|
||||
"bellsouth.net", "charter.net", "cox.net", "earthlink.net", "juno.com",
|
||||
|
||||
/* British ISP domains */
|
||||
"btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
|
||||
"ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
|
||||
"virgin.net", "wanadoo.co.uk", "bt.com",
|
||||
|
||||
/* Domains used in Asia */
|
||||
"sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com", "yahoo.co.jp", "yahoo.co.kr", "yahoo.co.id", "yahoo.co.in", "yahoo.com.sg", "yahoo.com.ph",
|
||||
|
||||
/* French ISP domains */
|
||||
"hotmail.fr", "live.fr", "laposte.net", "yahoo.fr", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",
|
||||
|
||||
/* German ISP domains */
|
||||
"gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de", "yahoo.de",
|
||||
|
||||
/* Italian ISP domains */
|
||||
"libero.it", "virgilio.it", "hotmail.it", "aol.it", "tiscali.it", "alice.it", "live.it", "yahoo.it", "email.it", "tin.it", "poste.it", "teletu.it",
|
||||
|
||||
/* Russian ISP domains */
|
||||
"mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",
|
||||
|
||||
/* Belgian ISP domains */
|
||||
"hotmail.be", "live.be", "skynet.be", "voo.be", "tvcablenet.be", "telenet.be",
|
||||
|
||||
/* Argentinian ISP domains */
|
||||
"hotmail.com.ar", "live.com.ar", "yahoo.com.ar", "fibertel.com.ar", "speedy.com.ar", "arnet.com.ar",
|
||||
|
||||
/* Domains used in Mexico */
|
||||
"yahoo.com.mx", "live.com.mx", "hotmail.es", "hotmail.com.mx", "prodigy.net.mx",
|
||||
|
||||
/* Domains used in Brazil */
|
||||
"yahoo.com.br", "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br"
|
||||
);
|
||||
|
||||
// Real association
|
||||
$replaceSLD = array(
|
||||
'@hotmil.' => '@hotmail.',
|
||||
'@htmail.' => '@hotmail.',
|
||||
'@hotmal.' => '@hotmail.',
|
||||
'@hotml.' => '@hotmail.',
|
||||
'@hotmai.' => '@hotmail.',
|
||||
'@gmal.' => '@gmail.',
|
||||
'@gail.' => '@gmail.',
|
||||
'@gml.' => '@gmail.',
|
||||
'@gmai.' => '@gmail.',
|
||||
'@gmil.' => '@gmail.',
|
||||
);
|
||||
|
||||
$replaceGlobal = array(
|
||||
'@gmailcom' => '@gmail.com',
|
||||
'@hotmailcom' => '@hotmail.com',
|
||||
'@hotmailfr' => '@hotmail.fr',
|
||||
);
|
||||
// Real use case replacement
|
||||
$email = strtr($email, $replaceGlobal);
|
||||
|
||||
// Check TLD
|
||||
$atPos = strpos($email, '@');
|
||||
$pointPos = strpos($email, '.', $atPos);
|
||||
$tld = substr($email, $pointPos + 1);
|
||||
$sld = substr($email, $atPos + 1, strlen($email) - ($atPos+1) - (strlen($tld)+1) );
|
||||
if (empty($tld)) {
|
||||
$this->errors[] = Tools::displayError('Invalid email');
|
||||
$_POST['email'] = '';
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
// If you have a complete list of TLD, check it !
|
||||
}
|
||||
|
||||
// Check SLD
|
||||
if (empty($this->errors)) {
|
||||
// Real use case replacement
|
||||
$email = strtr($email, $replaceSLD);
|
||||
// Levenhstein remplacement
|
||||
if (count($domains) > 0 && $email == $emailOri) {
|
||||
foreach ($domains as $d) {
|
||||
$dpPos = strpos($d, '.');
|
||||
$realDomain = substr($d, 0, $dpPos);
|
||||
$lev = levenshtein($sld, $realDomain);
|
||||
if ($lev == O) {
|
||||
break;
|
||||
}
|
||||
elseif ($lev == 1 && $tld == substr($d, $dpPos+1)) {
|
||||
$email = str_replace('@'.$sld.'.', '@'.$realDomain.'.', $email);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Preparing customer */
|
||||
$customer = new Customer();
|
||||
|
Loading…
Reference in New Issue
Block a user