Changeset 4061 for extensions/NBC_UserAdvManager/trunk/include
- Timestamp:
- Oct 19, 2009, 6:22:25 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
r3982 r4061 535 535 536 536 /* Obsolete function - Check for single email in database */ 537 function SearchMail($email)538 {539 global $conf, $lang;540 541 if (isset($email))542 {543 $query = "544 SELECT COUNT(*)545 FROM ".USERS_TABLE."546 WHERE ".$conf['user_fields']['email']." = '".$email."'547 ;";548 list($nbr_mail) = mysql_fetch_row(pwg_query($query));549 550 return isset($nbr_mail) ? $nbr_mail : 0;551 }552 }537 //function SearchMail($email) 538 //{ 539 // global $conf, $lang; 540 // 541 // if (isset($email)) 542 // { 543 // $query = " 544 // SELECT COUNT(*) 545 // FROM ".USERS_TABLE." 546 // WHERE ".$conf['user_fields']['email']." = '".$email."' 547 // ;"; 548 // list($nbr_mail) = mysql_fetch_row(pwg_query($query)); 549 // 550 // return isset($nbr_mail) ? $nbr_mail : 0; 551 // } 552 //} 553 553 554 554 … … 577 577 /* Obsolete function - Check for no forbidden email provider */ 578 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 else594 return true;595 }596 }597 }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 //} 598 598 599 599 … … 735 735 } 736 736 } 737 738 /** 739 * Returns a password's score for password complexity check 740 * 741 * @param password entered 742 * 743 * Thanx to MathieuGut from http://m-gut.developpez.com 744 */ 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; 774 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; 781 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; 788 789 // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters 790 $point_characters = 5; 791 } 792 } 793 794 // Calcul du coefficient points/longueur - calculating the coefficient points / length 795 $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 length 801 $score = $step1 * $step2; 802 803 // Multiplication du résultat par la longueur de la chaîne - Multiplying the result by the length of the chain 804 $finalscore = $score * $length; 805 806 return $finalscore; 807 } 737 808 ?>
Note: See TracChangeset
for help on using the changeset viewer.