"using mt_rand() instead of rand() and not longer seeding it explicitly (as recommened on php.net)"

This commit is contained in:
Ralf Becker 2010-04-23 18:41:01 +00:00
parent d4869ec11a
commit 0b38159c94

View File

@ -281,18 +281,17 @@ class common
*/
static function randomstring($size)
{
$s = '';
srand((double)microtime()*1000000);
$random_char = array(
static $random_char = array(
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
);
for ($i=0; $i<$size; $i++)
$s = '';
for ($i=0; $i < $size; $i++)
{
$s .= $random_char[rand(1,61)];
$s .= $random_char[mt_rand(0,count($random_char)-1)];
}
return $s;
}