Changeset 108447 in spipzone for _plugins_/motpassecomplexe/trunk/motpassecomplexe_fonctions.php
 Timestamp:
 Jan 11, 2018, 9:18:05 AM (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

_plugins_/motpassecomplexe/trunk/motpassecomplexe_fonctions.php
r96779 r108447 1 1 <?php 2 2 3 if (!defined('_ECRIRE_INC_VERSION')) return; 3 if (!defined('_ECRIRE_INC_VERSION')) { 4 return; 5 } 4 6 5 7 /** … … 14 16 function motpassecomplexe_verifier_pass($new_pass){ 15 17 16 // charge les constantes 17 // define('_PASS_LONGUEUR_MINI', '6'); // longueur  defaut: 6 18 if (!defined('_MOTCOMPLEXE_MINUSCULE')) define('_MOTCOMPLEXE_MINUSCULE', 1); // nb de minuscules  defaut: 1 19 if (!defined('_MOTCOMPLEXE_MAJUSCULE')) define('_MOTCOMPLEXE_MAJUSCULE', 1); // nb de majuscules  defaut: 1 20 if (!defined('_MOTCOMPLEXE_CHIFFRE')) define('_MOTCOMPLEXE_CHIFFRE', 1); // nb de chiffres  defaut: 1 21 if (!defined('_MOTCOMPLEXE_SPECIAL')) define('_MOTCOMPLEXE_SPECIAL', 1); // nb de caractères spéciaux  defaut: 1 22 23 $requis = array ( 24 'nb' => _PASS_LONGUEUR_MINI, 25 'nb_min' => _MOTCOMPLEXE_MINUSCULE, 26 'nb_maj' => _MOTCOMPLEXE_MAJUSCULE, 27 'nb_int' => _MOTCOMPLEXE_CHIFFRE, 28 'nb_spe' => _MOTCOMPLEXE_SPECIAL, 29 ); 30 31 $nb = strlen($new_pass); 32 $nb_min = motpassecomplexe_count_pattern($new_pass, '![^az]+!'); 33 $nb_maj = motpassecomplexe_count_pattern($new_pass, '![^AZ]+!'); 34 $nb_int = motpassecomplexe_count_pattern($new_pass, '![^09]+!'); 35 $nb_spe = $nb  motpassecomplexe_count_pattern($new_pass, '![^Az09 ]+!'); 36 37 $verifications = array( 38 array ( 39 'constante' => _PASS_LONGUEUR_MINI, 40 'operateur' => '>=', 41 'variable' => $nb, 42 ), 43 array ( 44 'constante' => _MOTCOMPLEXE_MINUSCULE, 45 'operateur' => '>=', 46 'variable' => $nb_min, 47 ), 48 array ( 49 'constante' => _MOTCOMPLEXE_MAJUSCULE, 50 'operateur' => '>=', 51 'variable' => $nb_maj, 52 ), 53 array ( 54 'constante' => _MOTCOMPLEXE_CHIFFRE, 55 'operateur' => '>=', 56 'variable' => $nb_int, 57 ), 58 array ( 59 'constante' => _MOTCOMPLEXE_SPECIAL, 60 'operateur' => '>=', 61 'variable' => $nb_spe, 62 ), 63 ); 64 18 // charge les constantes 19 // define('_PASS_LONGUEUR_MINI', '6'); // longueur minimale  defaut: 6 20 if (!defined('_MOTCOMPLEXE_MINUSCULE')) define('_MOTCOMPLEXE_MINUSCULE', 1); // nb de minuscules  defaut: 1 21 if (!defined('_MOTCOMPLEXE_MAJUSCULE')) define('_MOTCOMPLEXE_MAJUSCULE', 1); // nb de majuscules  defaut: 1 22 if (!defined('_MOTCOMPLEXE_CHIFFRE')) define('_MOTCOMPLEXE_CHIFFRE', 1); // nb de chiffres  defaut: 1 23 if (!defined('_MOTCOMPLEXE_SPECIAL')) define('_MOTCOMPLEXE_SPECIAL', 1); // nb de caractères spéciaux  defaut: 1 65 24 66 foreach ($verifications as $verification) { 67 if (!version_compare($verification['variable'], $verification['constante'], $verification['operateur'])) 68 return _T('motpassecomplexe:info_passe_trop_court', $requis); 69 } 70 25 $requis = array ( 26 'nb' => _PASS_LONGUEUR_MINI, 27 'nb_min' => _MOTCOMPLEXE_MINUSCULE, 28 'nb_maj' => _MOTCOMPLEXE_MAJUSCULE, 29 'nb_int' => _MOTCOMPLEXE_CHIFFRE, 30 'nb_spe' => _MOTCOMPLEXE_SPECIAL, 31 ); 32 33 $nb = strlen($new_pass); 34 $nb_min = motpassecomplexe_count_pattern($new_pass, '![^az]+!'); 35 $nb_maj = motpassecomplexe_count_pattern($new_pass, '![^AZ]+!'); 36 $nb_int = motpassecomplexe_count_pattern($new_pass, '![^09]+!'); 37 $nb_spe = $nb  motpassecomplexe_count_pattern($new_pass, '![^Az09 ]+!'); 38 39 $verifications = array( 40 array ( 41 'constante' => _PASS_LONGUEUR_MINI, 42 'operateur' => '>=', 43 'variable' => $nb, 44 ), 45 array ( 46 'constante' => _MOTCOMPLEXE_MINUSCULE, 47 'operateur' => '>=', 48 'variable' => $nb_min, 49 ), 50 array ( 51 'constante' => _MOTCOMPLEXE_MAJUSCULE, 52 'operateur' => '>=', 53 'variable' => $nb_maj, 54 ), 55 array ( 56 'constante' => _MOTCOMPLEXE_CHIFFRE, 57 'operateur' => '>=', 58 'variable' => $nb_int, 59 ), 60 array ( 61 'constante' => _MOTCOMPLEXE_SPECIAL, 62 'operateur' => '>=', 63 'variable' => $nb_spe, 64 ), 65 ); 66 67 68 foreach ($verifications as $verification) { 69 if (!version_compare($verification['variable'], $verification['constante'], $verification['operateur'])) { 70 return _T('motpassecomplexe:info_passe_trop_court', $requis); 71 } 72 } 71 73 72 74 return ''; … … 84 86 */ 85 87 function motpassecomplexe_count_pattern($str, $pattern) { 86 88 return strlen(preg_replace($pattern, '', $str)); 87 89 }
Note: See TracChangeset
for help on using the changeset viewer.