aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/captcha/captcha_gd.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-12-03 17:36:59 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-12-03 17:36:59 +0000
commitec80eb74aa5874f8790c3435bf4dd9fdf9614c6f (patch)
tree8f42fed41f0e463dd60d499674489edce609d072 /phpBB/includes/captcha/captcha_gd.php
parent1f7224c6019be5871f8385c6bb4403fd6ea28563 (diff)
downloadforums-ec80eb74aa5874f8790c3435bf4dd9fdf9614c6f.tar
forums-ec80eb74aa5874f8790c3435bf4dd9fdf9614c6f.tar.gz
forums-ec80eb74aa5874f8790c3435bf4dd9fdf9614c6f.tar.bz2
forums-ec80eb74aa5874f8790c3435bf4dd9fdf9614c6f.tar.xz
forums-ec80eb74aa5874f8790c3435bf4dd9fdf9614c6f.zip
#5734
- 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
Diffstat (limited to 'phpBB/includes/captcha/captcha_gd.php')
-rw-r--r--phpBB/includes/captcha/captcha_gd.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php
index 3d64cb1c26..c513c45fe7 100644
--- a/phpBB/includes/captcha/captcha_gd.php
+++ b/phpBB/includes/captcha/captcha_gd.php
@@ -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)];
}
}