Merge remote-tracking branch 'origin/ticket/r16490-email_error'
This commit is contained in:
commit
34e2bdc553
@ -83,15 +83,115 @@ 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',
|
||||
'@yahoocom' => '@yahoo.com',
|
||||
'@yahoofr' => '@yahoo.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['friendsEmail'] = '';
|
||||
}
|
||||
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,114 @@ 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',
|
||||
'@yahoocom' => '@yahoo.com',
|
||||
'@yahoofr' => '@yahoo.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();
|
||||
@ -140,14 +239,16 @@ class AuthController extends AuthControllerCore
|
||||
$_POST['firstname'] = $firstnameAddress;
|
||||
|
||||
if (!sizeof($this->errors)) {
|
||||
if(Customer::customerExists($email)) {
|
||||
if (Customer::customerExists($email)) {
|
||||
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
|
||||
}
|
||||
if(Tools::isSubmit('newsletter')) {
|
||||
|
||||
if (Tools::isSubmit('newsletter')) {
|
||||
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
|
||||
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$customer->email = $_POST['email'] = $email;
|
||||
$customer->birthday = (empty($_POST['years'])? '': (int)($_POST['years']).'-'.(int)($_POST['months']).'-'.(int)($_POST['days']));
|
||||
|
||||
if (!sizeof($this->errors)) {
|
||||
@ -158,14 +259,21 @@ class AuthController extends AuthControllerCore
|
||||
} else {
|
||||
$customer->is_guest = 0;
|
||||
}
|
||||
|
||||
if (!$customer->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
} else {
|
||||
if(!$customer->is_guest) {
|
||||
if (!$customer->is_guest) {
|
||||
if(!Mail::Send((int)(self::$cookie->id_lang), 'account', Mail::l('Welcome!'),
|
||||
array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname.' '.$customer->lastname))
|
||||
array(
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{email}' => $customer->email,
|
||||
'{passwd}' => Tools::getValue('passwd')
|
||||
), $customer->email, $customer->firstname.' '.$customer->lastname)) {
|
||||
$this->errors[] = Tools::displayError('Cannot send email');
|
||||
}
|
||||
}
|
||||
|
||||
global $site_version_front;
|
||||
Db::getInstance()->ExecuteS('
|
||||
|
Loading…
Reference in New Issue
Block a user