forked from Wavyzz/dolibarr
Fix for php8
This commit is contained in:
@@ -467,15 +467,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
|
||||
{
|
||||
$max = strlen($lowercase) - 1;
|
||||
for ($x = 0; $x < $nbofchar; $x++) {
|
||||
$randomCode .= $lowercase{random_int(0, $max)};
|
||||
$tmp = random_int(0, $max);
|
||||
$randomCode .= $lowercase[$tmp];
|
||||
}
|
||||
$max = strlen($uppercase) - 1;
|
||||
for ($x = 0; $x < $nbofchar; $x++) {
|
||||
$randomCode .= $uppercase{random_int(0, $max)};
|
||||
$tmp = random_int(0, $max);
|
||||
$randomCode .= $uppercase[$tmp];
|
||||
}
|
||||
$max = strlen($numbers) - 1;
|
||||
for ($x = 0; $x < $nbofcharlast; $x++) {
|
||||
$randomCode .= $numbers{random_int(0, $max)};
|
||||
$tmp = random_int(0, $max);
|
||||
$randomCode .= $numbers[$tmp];
|
||||
}
|
||||
|
||||
$generated_password=str_shuffle($randomCode);
|
||||
@@ -484,15 +487,18 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
|
||||
{
|
||||
$max = strlen($lowercase) - 1;
|
||||
for ($x = 0; $x < $nbofchar; $x++) {
|
||||
$randomCode .= $lowercase{mt_rand(0, $max)};
|
||||
$tmp = mt_rand(0, $max);
|
||||
$randomCode .= $lowercase[$tmp];
|
||||
}
|
||||
$max = strlen($uppercase) - 1;
|
||||
for ($x = 0; $x < $nbofchar; $x++) {
|
||||
$randomCode .= $uppercase{mt_rand(0, $max)};
|
||||
$tmp = mt_rand(0, $max);
|
||||
$randomCode .= $uppercase[$tmp];
|
||||
}
|
||||
$max = strlen($numbers) - 1;
|
||||
for ($x = 0; $x < $nbofcharlast; $x++) {
|
||||
$randomCode .= $numbers{mt_rand(0, $max)};
|
||||
$tmp = mt_rand(0, $max);
|
||||
$randomCode .= $numbers[$tmp];
|
||||
}
|
||||
|
||||
$generated_password=str_shuffle($randomCode);
|
||||
@@ -516,11 +522,13 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
|
||||
$max = strlen($numbers) - 1;
|
||||
if (function_exists('random_int')) // Cryptographic random
|
||||
{
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
|
||||
$tmp = random_int(0, $max);
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
|
||||
$tmp = random_int(0, $max);
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers[$tmp], $generated_password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user