mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-10 02:36:38 +02:00
- replaced array_rand($array) with mt_rand(0, sizeof($array) - 1) as array_rand did not take my seed git-svn-id: file:///svn/phpbb/trunk@6705 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -19,7 +19,7 @@ class captcha
|
||||
var $width = 360;
|
||||
var $height = 96;
|
||||
|
||||
function execute($code)
|
||||
function execute($code, $seed)
|
||||
{
|
||||
global $config;
|
||||
$stats = gd_info();
|
||||
@@ -48,6 +48,9 @@ class captcha
|
||||
imageantialias($image, true);
|
||||
}
|
||||
|
||||
// seed the random generator
|
||||
mt_srand($seed);
|
||||
|
||||
// set background color
|
||||
$back = imagecolorallocate($image, mt_rand(224, 255), mt_rand(224, 255), mt_rand(224, 255));
|
||||
imagefilledrectangle($image, 0, 0, $this->width, $this->height, $back);
|
||||
@@ -79,7 +82,7 @@ class captcha
|
||||
$x = mt_rand(0, 360);
|
||||
$y = mt_rand(0, (int)($this->height - ($size / 5)));
|
||||
$color = $func2($image, mt_rand(160, 224), mt_rand(160, 224), mt_rand(160, 224));
|
||||
$text = $chars_allowed[array_rand($chars_allowed)];
|
||||
$text = $chars_allowed[mt_rand(0, sizeof($chars_allowed) - 1)];
|
||||
imagettftext($image, $size, $angle, $x, $y, $color, $this->get_font(), $text);
|
||||
}
|
||||
unset($chars_allowed);
|
||||
@@ -145,7 +148,7 @@ class captcha
|
||||
closedir($dr);
|
||||
}
|
||||
|
||||
return $fonts[array_rand($fonts)];
|
||||
return $fonts[mt_rand(0, sizeof($fonts) - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -30,15 +30,14 @@ class captcha
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the image containing $code
|
||||
* Create the image containing $code with a seed of $seed
|
||||
*/
|
||||
function execute($code)
|
||||
function execute($code, $seed)
|
||||
{
|
||||
$img_height = $this->height - 10;
|
||||
$img_width = 0;
|
||||
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
mt_srand($sec * $usec);
|
||||
mt_srand($seed);
|
||||
|
||||
$char_widths = $hold_chars = array();
|
||||
$code_len = strlen($code);
|
||||
|
Reference in New Issue
Block a user