diff options
Diffstat (limited to '')
-rw-r--r-- | include/functions_session.inc.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php index 9fe28db8c..b3a79acec 100644 --- a/include/functions_session.inc.php +++ b/include/functions_session.inc.php @@ -58,17 +58,17 @@ if (isset($conf['session_save_handler']) * Characters used are a-z A-Z and numerical values. * * @param int $size + * @param string $alphabet chars to use in the key, + * default is all digits and all letters uppercase and lowercase * @return string */ -function generate_key($size) +function generate_key($size, $alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') { + $l = strlen($alphabet)-1; $key = ''; - for ( $i = 0; $i < $size; $i++ ) + for ($i=0; $i<$size; $i++) { - $c = mt_rand( 0, 2 ); - if ( $c == 0 ) $key .= chr( mt_rand( 65, 90 ) ); - else if ( $c == 1 ) $key .= chr( mt_rand( 97, 122 ) ); - else $key .= mt_rand( 0, 9 ); + $key.= $alphabet[mt_rand(0, $l)]; } return $key; } |