diff options
author | plegall <plg@piwigo.org> | 2016-05-02 13:09:12 +0200 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2016-05-02 13:09:12 +0200 |
commit | 7ea9cf90752c460e29e14b5e6064519eaba9eed2 (patch) | |
tree | 4a5223faa57187ac16ff6af1d5bbe1ede6d61aae /include/functions_session.inc.php | |
parent | cfa7bf2228fbd4a3e3534943a6ea7945b58f0beb (diff) | |
parent | f51ee90c66527fd7ff634f3e8d414cb670da068d (diff) |
Merge branch '2.8'
Diffstat (limited to 'include/functions_session.inc.php')
-rw-r--r-- | include/functions_session.inc.php | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php index fe43bc570..0829bcfda 100644 --- a/include/functions_session.inc.php +++ b/include/functions_session.inc.php @@ -62,32 +62,17 @@ if (isset($conf['session_save_handler']) */ function generate_key($size) { - if ( - is_callable('openssl_random_pseudo_bytes') - and !(version_compare(PHP_VERSION, '5.3.4') < 0 and defined('PHP_WINDOWS_VERSION_MAJOR')) - ) - { - return substr( - str_replace( - array('+', '/'), - '', - base64_encode(openssl_random_pseudo_bytes($size+10)) - ), - 0, - $size - ); - } - else - { - $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - $l = strlen($alphabet)-1; - $key = ''; - for ($i=0; $i<$size; $i++) - { - $key.= $alphabet[mt_rand(0, $l)]; - } - return $key; - } + include_once(PHPWG_ROOT_PATH.'include/random_compat/random.php'); + + return substr( + str_replace( + array('+', '/'), + '', + base64_encode(random_bytes($size+10)) + ), + 0, + $size + ); } /** |