aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-06-02 12:52:00 +0000
committermistic100 <mistic@piwigo.org>2014-06-02 12:52:00 +0000
commitf47ef1493f2dce611b63afdeddd0cf7ced5772fc (patch)
treefe022f87168c95a733030d366c4843e05c6eff4c /include
parent0cba9b4b644ccbbec15f968751b942d1f4080724 (diff)
use lookup string for generate_key function
git-svn-id: http://piwigo.org/svn/trunk@28591 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/functions_session.inc.php12
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;
}