mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-29 04:39:56 +03:00
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:
parent
0cba9b4b64
commit
f47ef1493f
1 changed files with 6 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue