Commit f649b42d authored by Dries's avatar Dries

- Patch #44767 by jvandyk: small (code) improvements

parent 84beb258
......@@ -285,14 +285,11 @@ function user_password($length = 10) {
// This variable contains the list of allowable characters for the
// password. Note that the number 0 and the letter 'O' have been
// removed to avoid confusion between the two. The same is true
// of 'I' and 1.
$allowable_characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
// of 'I', 1, and l.
$allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
// We see how many characters are in the allowable list:
$len = strlen($allowable_characters);
// Seed the random number generator with the microtime stamp.
mt_srand((double)microtime() * 1000000);
// Zero-based count of characters in the allowable list:
$len = strlen($allowable_characters) - 1;
// Declare the password as a blank string.
$pass = '';
......@@ -302,7 +299,7 @@ function user_password($length = 10) {
// Each iteration, pick a random character from the
// allowable string and append it to the password:
$pass .= $allowable_characters[mt_rand(0, $len - 1)];
$pass .= $allowable_characters[mt_rand(0, $len)];
}
return $pass;
......
......@@ -285,14 +285,11 @@ function user_password($length = 10) {
// This variable contains the list of allowable characters for the
// password. Note that the number 0 and the letter 'O' have been
// removed to avoid confusion between the two. The same is true
// of 'I' and 1.
$allowable_characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
// of 'I', 1, and l.
$allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
// We see how many characters are in the allowable list:
$len = strlen($allowable_characters);
// Seed the random number generator with the microtime stamp.
mt_srand((double)microtime() * 1000000);
// Zero-based count of characters in the allowable list:
$len = strlen($allowable_characters) - 1;
// Declare the password as a blank string.
$pass = '';
......@@ -302,7 +299,7 @@ function user_password($length = 10) {
// Each iteration, pick a random character from the
// allowable string and append it to the password:
$pass .= $allowable_characters[mt_rand(0, $len - 1)];
$pass .= $allowable_characters[mt_rand(0, $len)];
}
return $pass;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment