mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Add verif and correction lang
This commit is contained in:
@@ -326,7 +326,7 @@ $var=!$var;
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>' . $langs->trans("NoAmbiCaracAutoGeneration")."</td>";
|
||||
print '<td colspan="2" align="center"><input type="checkbox" id="NoAmbiCaracAutoGeneration" '.($tabConf[5] ? "checked" : "").' min="0"></td>';
|
||||
print '<td colspan="2"><input type="checkbox" id="NoAmbiCaracAutoGeneration" '.($tabConf[5] ? "checked" : "").' min="0"> <span id="textcheckbox">'.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'</span></td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=!$var;
|
||||
@@ -360,6 +360,9 @@ $var=!$var;
|
||||
print ' function valuePatternChange(){';
|
||||
print ' var lang_save = "'.$langs->trans("Save").'";';
|
||||
print ' var lang_error = "'.$langs->trans("Error").'";';
|
||||
print ' var lang_Disabled = "'.$langs->trans("Disabled").'";';
|
||||
print ' var lang_Activated = "'.$langs->trans("Activated").'";';
|
||||
print ' $("#textcheckbox").html($("#NoAmbiCaracAutoGeneration")[0].checked ? unescape(lang_Activated) : unescape(lang_Disabled));';
|
||||
print ' if(valuePossible()){';
|
||||
print ' $("#linkChangePattern").attr("href",generatelink()).text(lang_save);';
|
||||
print ' }';
|
||||
|
||||
@@ -72,16 +72,14 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
$this->user=$user;
|
||||
|
||||
if(empty($conf->global->USER_PASSWORD_PATTERN)){
|
||||
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;8;0','chaine',0,'',$conf->entity);
|
||||
// default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation.
|
||||
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1','chaine',0,'',$conf->entity);
|
||||
}
|
||||
|
||||
$this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
//$this->Maj = "Y";
|
||||
$this->Min = strtolower($this->Maj);
|
||||
$this->Nb = "0123456789";
|
||||
//$this->Nb = "X";
|
||||
$this->Spe = "!@#$%&*()_-+={}[]\\|:;'/";
|
||||
//$this->Spe = "<>;}?";
|
||||
$this->Ambi = array("1","I","l","|","O","0");
|
||||
|
||||
$tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN);
|
||||
@@ -149,7 +147,13 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
for($i=strlen($pass);$i<$this->length2; $i++){ // y
|
||||
$pass .= $this->All[rand(0,strlen($this->All) -1)];
|
||||
}
|
||||
return str_shuffle($pass) ;
|
||||
|
||||
$pass = str_shuffle($pass) ;
|
||||
|
||||
if($this->validatePassword($pass)) {
|
||||
return $pass;
|
||||
}
|
||||
return $this->getNewGeneratedPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,6 +164,27 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
*/
|
||||
function validatePassword($password)
|
||||
{
|
||||
$password_a = str_split($password);
|
||||
$maj = str_split($this->Maj);
|
||||
$num = str_split($this->Nb);
|
||||
$spe = str_split($this->Spe);
|
||||
|
||||
if(count(array_intersect($password_a, $maj)) < $this->NbMaj){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(count(array_intersect($password_a, $num)) < $this->NbNum){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(count(array_intersect($password_a, $spe)) < $this->NbSpe){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!$this->consecutiveInterationSameCharacter($password)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -172,8 +197,7 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
function consecutiveInterationSameCharacter($password){
|
||||
$last = "";
|
||||
$count = 0;
|
||||
$char = explode("", $password);
|
||||
|
||||
$char = str_split($password);
|
||||
foreach($char as $c){
|
||||
if($c != $last){
|
||||
$last = $c;
|
||||
@@ -182,11 +206,11 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($count > $this->NbRepeat) {
|
||||
return true;
|
||||
if($count >= $this->NbRepeat) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ NbMajMin=Nombre de majuscule minimum
|
||||
NbNumMin=Nombre de chiffre minimum
|
||||
NbSpeMin=Nombre de caractère speciaux minimum
|
||||
NbIteConsecutive=Nombre maximum d'iterations consecutive du même caractère
|
||||
NoAmbiCaracAutoGeneration=Desactivaté les caractère ambigus pour la generation automatique ("1","I","l","|","0","O")
|
||||
NoAmbiCaracAutoGeneration=Ne pas utiliser les caractère ambigus pour la generation automatique ("1","I","l","|","0","O")
|
||||
SetupPerso=Configuration personalisable
|
||||
LanguageFilesCachedIntoShmopSharedMemory=Fichiers .lang en mémoire partagée
|
||||
ExamplesWithCurrentSetup=Exemples avec le paramétrage actif courant
|
||||
|
||||
Reference in New Issue
Block a user