diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index ba1cc230258bfb13448ffd144c5beb34581f0993..e6f6228eec9ecc6626b1787862f9c84dcad5a977 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -480,47 +480,47 @@ function clean_url($url,$http=1) } - -/** - * Returns an email value with obfuscated parts. - * - * @param string $mail Email - * @param string $replace Replacement character (defaul : *) - * @param int $nbreplace Number of replacement character (default : 8) - * @param int $nbdisplaymail Number of character unchanged (default: 4) - * @param int $nbdisplaydomain Number of character unchanged of domain (default: 3) - * @param bool $displaytld Display tld (default: true) - * @return string Return email with hidden parts or ''; - */ -function dolObfuscateEmail($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 = ''; - - for($i=1; $i < count($tab2) && $displaytld ;$i++) - { - $mail_tld .= '.'.$tab2[$i]; - } - - 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; -} + +/** + * Returns an email value with obfuscated parts. + * + * @param string $mail Email + * @param string $replace Replacement character (defaul : *) + * @param int $nbreplace Number of replacement character (default : 8) + * @param int $nbdisplaymail Number of character unchanged (default: 4) + * @param int $nbdisplaydomain Number of character unchanged of domain (default: 3) + * @param bool $displaytld Display tld (default: true) + * @return string Return email with hidden parts or ''; + */ +function dolObfuscateEmail($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 = ''; + + for($i=1; $i < count($tab2) && $displaytld ;$i++) + { + $mail_tld .= '.'.$tab2[$i]; + } + + 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; +} /**