- Timestamp:
- Oct 26, 2009, 11:34:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
r4061 r4124 575 575 576 576 577 /* Obsolete function - Check for no forbidden email provider */ 578 /* This don't work on function call */ 579 //function ValidateEmailProvider($email) 580 //{ 581 // global $conf; 582 // 583 // $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 584 // if (isset($conf_nbc_UserAdvManager[12])) 585 // { 586 // $ncsemail = strtolower($email); 587 // $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); 588 // for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 589 // { 590 // $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; 591 // if (preg_match($pattern, $ncsemail)) 592 // return false; 593 // else 594 // return true; 595 // } 596 // } 597 //} 577 /* Function called from main.inc.php - Check if user's email is in excluded email providers list */ 578 function ValidateEmailProvider($email) 579 { 580 global $conf; 581 582 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 583 if (isset($conf_nbc_UserAdvManager[12])) 584 { 585 $ncsemail = strtolower($email); 586 $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); 587 for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 588 { 589 $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; 590 if (preg_match($pattern, $ncsemail)) 591 return false; 592 else 593 return true; 594 } 595 } 596 } 598 597 599 598 … … 743 742 * Thanx to MathieuGut from http://m-gut.developpez.com 744 743 */ 745 function testpassword($password) { // Le mot de passe passé en paramètre - $password given by user 746 747 // Initialisation des variables - Variables initiation 748 $points = 0; 749 $point_lowercase = 0; 750 $point_uppercase = 0; 751 $point_numbers = 0; 752 $point_characters = 0; 753 754 // On récupère la longueur du mot de passe - Getting password lengh 755 $length = strlen($password); 756 757 // On fait une boucle pour lire chaque lettre - Loop to read password characters 758 for($i = 0; $i < $length; $i++) { 759 760 // On sélectionne une à une chaque lettre - Select each letters 761 // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn 762 $letters = $password[$i]; 763 764 if ($letters>='a' && $letters<='z'){ 765 // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase 766 $points = $points + 1; 767 768 // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase 769 $point_lowercase = 1; 770 } 771 else if ($letters>='A' && $letters <='Z'){ 772 // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase 773 $points = $points + 2; 744 function testpassword($password) // Le mot de passe passé en paramètre - $password given by user 745 { 746 747 // Initialisation des variables - Variables initiation 748 $points = 0; 749 $point_lowercase = 0; 750 $point_uppercase = 0; 751 $point_numbers = 0; 752 $point_characters = 0; 753 754 // On récupère la longueur du mot de passe - Getting password lengh 755 $length = strlen($password); 756 757 // On fait une boucle pour lire chaque lettre - Loop to read password characters 758 for($i = 0; $i < $length; $i++) 759 { 760 // On sélectionne une à une chaque lettre - Select each letters 761 // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn 762 $letters = $password[$i]; 763 764 if ($letters>='a' && $letters<='z') 765 { 766 // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase 767 $points = $points + 1; 768 769 // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase 770 $point_lowercase = 1; 771 } 772 else if ($letters>='A' && $letters <='Z') 773 { 774 // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase 775 $points = $points + 2; 774 776 775 // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase 776 $point_uppercase = 2; 777 } 778 else if ($letters>='0' && $letters<='9'){ 779 // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers 780 $points = $points + 3; 777 // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase 778 $point_uppercase = 2; 779 } 780 else if ($letters>='0' && $letters<='9') 781 { 782 // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers 783 $points = $points + 3; 781 784 782 // On rajoute le bonus pour un chiffre - Adding bonus points for numbers 783 $point_numbers = 3; 784 } 785 else { 786 // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters 787 $points = $points + 5; 785 // On rajoute le bonus pour un chiffre - Adding bonus points for numbers 786 $point_numbers = 3; 787 } 788 else 789 { 790 // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters 791 $points = $points + 5; 788 792 789 790 791 792 }793 794 // Calcul du coefficient points/longueur - calculating the coefficient points / length795 $step1 = $points / $length;796 797 // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types...798 $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters;799 800 // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length801 $score = $step1 * $step2;802 803 // Multiplication du résultat par la longueur de la chaîne - Multiplying the result by the length of the chain804 $finalscore = $score * $length;805 806 return $finalscore;793 // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters 794 $point_characters = 5; 795 } 796 } 797 798 // Calcul du coefficient points/longueur - calculating the coefficient points / length 799 $step1 = $points / $length; 800 801 // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types... 802 $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters; 803 804 // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length 805 $score = $step1 * $step2; 806 807 // Multiplication du résultat par la longueur de la chaîne - Multiplying the result by the length of the chain 808 $finalscore = $score * $length; 809 810 return $finalscore; 807 811 } 808 812 ?>
Note: See TracChangeset
for help on using the changeset viewer.