Changeset 28591
- Timestamp:
- Jun 2, 2014, 2:52:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_session.inc.php
r28571 r28591 59 59 * 60 60 * @param int $size 61 * @param string $alphabet chars to use in the key, 62 * default is all digits and all letters uppercase and lowercase 61 63 * @return string 62 64 */ 63 function generate_key($size) 64 { 65 function generate_key($size, $alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') 66 { 67 $l = strlen($alphabet)-1; 65 68 $key = ''; 66 for ( $i = 0; $i < $size; $i++ ) 67 { 68 $c = mt_rand( 0, 2 ); 69 if ( $c == 0 ) $key .= chr( mt_rand( 65, 90 ) ); 70 else if ( $c == 1 ) $key .= chr( mt_rand( 97, 122 ) ); 71 else $key .= mt_rand( 0, 9 ); 69 for ($i=0; $i<$size; $i++) 70 { 71 $key.= $alphabet[mt_rand(0, $l)]; 72 72 } 73 73 return $key;
Note: See TracChangeset
for help on using the changeset viewer.