summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-03-05 20:18:50 +0300
committerAndrew Dolgov <[email protected]>2019-03-05 20:18:50 +0300
commitdfd3a4e581d10fa64f5b4f16e66fdb5c31b70444 (patch)
tree86890e7f89d3ea2e98d9dc7cd0b645b910f316b8 /include
parent16a9bdc38708c0e3b81eae3a79216214d493b57e (diff)
update previous with make_password() in tt-rss proper
Diffstat (limited to 'include')
-rwxr-xr-xinclude/functions.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index acc53c84c..d93be856d 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -738,20 +738,27 @@
}
function make_password($length = 12) {
-
$password = "";
- $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ";
+ $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^";
- $i = 0;
+ $i = 0;
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)) {
$password .= $char;
$i++;
}
}
+
return $password;
}