From f47ef1493f2dce611b63afdeddd0cf7ced5772fc Mon Sep 17 00:00:00 2001 From: mistic100 Date: Mon, 2 Jun 2014 12:52:00 +0000 Subject: use lookup string for generate_key function git-svn-id: http://piwigo.org/svn/trunk@28591 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_session.inc.php | 12 ++++++------ 1 file 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; } -- cgit v1.2.3