aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_session.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-01-25 00:47:31 +0000
committerrvelices <rv-github@modusoptimus.com>2006-01-25 00:47:31 +0000
commit10329e517b22671f002bcb2929ebb54a09f22573 (patch)
tree5849bdf1ed34991e514aec24b33f4c2da30bd77a /include/functions_session.inc.php
parent02f08d3c4fc7154f0c2b0157e531e0b256c6f0ba (diff)
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
Diffstat (limited to '')
-rw-r--r--include/functions_session.inc.php32
1 files changed, 31 insertions, 1 deletions
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',