diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7097bd2abae63df5cb50ae1ed9e66b54c20fab38..931c0b95fdd944ade55f38d4ab169fdad005aa5a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1224,6 +1224,42 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid= return $newemail; } +/** + * Returns a hidden email. + * Hide part of email. + * + * @param string $mail Email + * @param string $replace Replacement caractaire ( defaul : *) + * @param int $nbreplace Number of replacement caractaire (default : 8) + * @param int $nbdisplaymail Number of caractaire unchanged (default: 4) + * @param int $nbdisplaydomain Number of caractaire unchanged of domain (default: 3) + * @param bool $displaytld Display tld (default: true) + * @return string Return hiden email or ''; + */ +function dol_hideMail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true){ + if(!isValidEmail($mail))return ' '; + $tab = explode('@', $mail); + $tab2 = explode('.',$tab[1]); + $string_replace = ''; + $mail_name = $tab[0]; + $mail_domaine = $tab2[0]; + $mail_tld = $displaytld ? ".".$tab2[1] : " "; + + for($i=0; $i < $nbreplace; $i++){ + $string_replace .= $replace; + } + + if(strlen($mail_name) > $nbdisplaymail){ + $mail_name = substr($mail_name, 0, $nbdisplaymail); + } + + if(strlen($mail_domaine) > $nbdisplaydomain){ + $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); + } + + return $mail_name . $string_replace . $mail_domaine . $mail_tld; +} + /** * Show Skype link * diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 4f1a36c6e040231ff235bd7d5cd3460719cf951f..c3c4fccb888bbe5b3d2df24840b805670d56f567 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -130,7 +130,8 @@ if ($action == 'buildnewpassword' && $username) // Success if ($edituser->send_password($user,$newpassword,1) > 0) { - $message = '<div class="ok">'.$langs->trans("PasswordChangeRequestSent",$edituser->login,$edituser->email).'</div>'; + + $message = '<div class="ok">'.$langs->trans("PasswordChangeRequestSent",$edituser->login,dol_hideMail($edituser->email)).'</div>'; //$message.=$newpassword; $username=''; }