diff options
author | Mario <mario@mariovavti.com> | 2022-01-02 20:45:25 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-01-02 20:45:25 +0000 |
commit | df8bb0596a2a657cb2b0be951e2bc713f2b5e89d (patch) | |
tree | dd0f4fba1747f202d81001dabcf0ff661ae654b3 /include/text.php | |
parent | 0003e0b8a5841bfc9e845f0b833aa206527826de (diff) | |
download | volse-hubzilla-df8bb0596a2a657cb2b0be951e2bc713f2b5e89d.tar.gz volse-hubzilla-df8bb0596a2a657cb2b0be951e2bc713f2b5e89d.tar.bz2 volse-hubzilla-df8bb0596a2a657cb2b0be951e2bc713f2b5e89d.zip |
port new_token from zap, fixes and more cleanup
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/include/text.php b/include/text.php index 0522dd3c9..29b9d039c 100644 --- a/include/text.php +++ b/include/text.php @@ -2586,7 +2586,7 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1"); } - $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown', 'anon')"); + $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown', 'anon', 'token')"); if(! $chans) $chans = $xchans; else @@ -3889,6 +3889,26 @@ function array_path_exists($str,$arr) { /** + * @brief provide psuedo random token (string) consisting entirely of US-ASCII letters/numbers + * and with possibly variable length + * + * @return string + */ +function new_token($minlen = 36, $maxlen = 48) { + $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; + $str = EMPTY_STR; + + $len = (($minlen === $maxlen) ? $minlen : mt_rand($minlen, $maxlen)); + + for ($a = 0; $a < $len; $a++) { + $str .= $chars[mt_rand(0, 62)]; + } + + return $str; +} + + +/** * @brief Generate a random v4 UUID. * * @return string |