mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 06:55:56 +00:00
update previous with make_password() in tt-rss proper
This commit is contained in:
@@ -738,20 +738,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function make_password($length = 12) {
|
function make_password($length = 12) {
|
||||||
|
|
||||||
$password = "";
|
$password = "";
|
||||||
$possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ";
|
$possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^";
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $length) {
|
while ($i < $length) {
|
||||||
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
|
|
||||||
|
try {
|
||||||
|
$idx = function_exists("random_int") ? random_int(0, strlen($possible) - 1) : mt_rand(0, strlen($possible) - 1);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$idx = mt_rand(0, strlen($possible) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$char = substr($possible, $idx, 1);
|
||||||
|
|
||||||
if (!strstr($password, $char)) {
|
if (!strstr($password, $char)) {
|
||||||
$password .= $char;
|
$password .= $char;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $password;
|
return $password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user