Add verif and correction lang
This commit is contained in:
parent
5074feacd6
commit
796f2409a1
@ -326,7 +326,7 @@ $var=!$var;
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
print '<td>' . $langs->trans("NoAmbiCaracAutoGeneration")."</td>";
|
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>';
|
print '</tr>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
@ -360,6 +360,9 @@ $var=!$var;
|
|||||||
print ' function valuePatternChange(){';
|
print ' function valuePatternChange(){';
|
||||||
print ' var lang_save = "'.$langs->trans("Save").'";';
|
print ' var lang_save = "'.$langs->trans("Save").'";';
|
||||||
print ' var lang_error = "'.$langs->trans("Error").'";';
|
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 ' if(valuePossible()){';
|
||||||
print ' $("#linkChangePattern").attr("href",generatelink()).text(lang_save);';
|
print ' $("#linkChangePattern").attr("href",generatelink()).text(lang_save);';
|
||||||
print ' }';
|
print ' }';
|
||||||
|
|||||||
@ -72,16 +72,14 @@ class modGeneratePassPerso extends ModeleGenPassword
|
|||||||
$this->user=$user;
|
$this->user=$user;
|
||||||
|
|
||||||
if(empty($conf->global->USER_PASSWORD_PATTERN)){
|
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 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
//$this->Maj = "Y";
|
|
||||||
$this->Min = strtolower($this->Maj);
|
$this->Min = strtolower($this->Maj);
|
||||||
$this->Nb = "0123456789";
|
$this->Nb = "0123456789";
|
||||||
//$this->Nb = "X";
|
|
||||||
$this->Spe = "!@#$%&*()_-+={}[]\\|:;'/";
|
$this->Spe = "!@#$%&*()_-+={}[]\\|:;'/";
|
||||||
//$this->Spe = "<>;}?";
|
|
||||||
$this->Ambi = array("1","I","l","|","O","0");
|
$this->Ambi = array("1","I","l","|","O","0");
|
||||||
|
|
||||||
$tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN);
|
$tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN);
|
||||||
@ -149,7 +147,13 @@ class modGeneratePassPerso extends ModeleGenPassword
|
|||||||
for($i=strlen($pass);$i<$this->length2; $i++){ // y
|
for($i=strlen($pass);$i<$this->length2; $i++){ // y
|
||||||
$pass .= $this->All[rand(0,strlen($this->All) -1)];
|
$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)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,8 +197,7 @@ class modGeneratePassPerso extends ModeleGenPassword
|
|||||||
function consecutiveInterationSameCharacter($password){
|
function consecutiveInterationSameCharacter($password){
|
||||||
$last = "";
|
$last = "";
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$char = explode("", $password);
|
$char = str_split($password);
|
||||||
|
|
||||||
foreach($char as $c){
|
foreach($char as $c){
|
||||||
if($c != $last){
|
if($c != $last){
|
||||||
$last = $c;
|
$last = $c;
|
||||||
@ -182,11 +206,11 @@ class modGeneratePassPerso extends ModeleGenPassword
|
|||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($count > $this->NbRepeat) {
|
if($count >= $this->NbRepeat) {
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -331,7 +331,7 @@ NbMajMin=Nombre de majuscule minimum
|
|||||||
NbNumMin=Nombre de chiffre minimum
|
NbNumMin=Nombre de chiffre minimum
|
||||||
NbSpeMin=Nombre de caractère speciaux minimum
|
NbSpeMin=Nombre de caractère speciaux minimum
|
||||||
NbIteConsecutive=Nombre maximum d'iterations consecutive du même caractère
|
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
|
SetupPerso=Configuration personalisable
|
||||||
LanguageFilesCachedIntoShmopSharedMemory=Fichiers .lang en mémoire partagée
|
LanguageFilesCachedIntoShmopSharedMemory=Fichiers .lang en mémoire partagée
|
||||||
ExamplesWithCurrentSetup=Exemples avec le paramétrage actif courant
|
ExamplesWithCurrentSetup=Exemples avec le paramétrage actif courant
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user