use lookup string for generate_key function

git-svn-id: http://piwigo.org/svn/trunk@28591 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100 2014-06-02 12:52:00 +00:00
parent 0cba9b4b64
commit f47ef1493f

View file

@ -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;
}