From 10329e517b22671f002bcb2929ebb54a09f22573 Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 25 Jan 2006 00:47:31 +0000 Subject: bug: new session system does not use db session handler during install.php bug: put back function generate_key (was also used by new password generation and new feed generation) git-svn-id: http://piwigo.org/svn/trunk@1013 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_session.inc.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'include/functions_session.inc.php') diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php index 52970f0d3..8a5438374 100644 --- a/include/functions_session.inc.php +++ b/include/functions_session.inc.php @@ -25,8 +25,38 @@ // | USA. | // +-----------------------------------------------------------------------+ +// The function generate_key creates a string with pseudo random characters. +// the size of the string depends on the $conf['session_id_size']. +// Characters used are a-z A-Z and numerical values. Examples : +// "Er4Tgh6", "Rrp08P", "54gj" +// input : none (using global variable) +// output : $key +function generate_key($size) +{ + global $conf; + + $md5 = md5(substr(microtime(), 2, 6)); + $init = ''; + for ( $i = 0; $i < strlen( $md5 ); $i++ ) + { + if ( is_numeric( $md5[$i] ) ) $init.= $md5[$i]; + } + $init = substr( $init, 0, 8 ); + mt_srand( $init ); + $key = ''; + 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 ); + } + return $key; +} + if (isset($conf['session_save_handler']) - and ($conf['session_save_handler'] == 'db')) + and ($conf['session_save_handler'] == 'db') + and defined('PHPWG_INSTALLED')) { session_set_save_handler('pwg_session_open', 'pwg_session_close', -- cgit v1.2.3