Skip to content

Commit ca5461e

Browse files
committed
Cast mt_rand() arguments to int
1 parent a2538ba commit ca5461e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

system/helpers/captcha_helper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
240240
// -----------------------------------
241241
$length = strlen($word);
242242
$angle = ($length >= 6) ? mt_rand(-($length-6), ($length-6)) : 0;
243-
$x_axis = mt_rand(6, (360/$length)-16);
243+
$x_axis = mt_rand(6, (int) ((360/$length)-16));
244244
$y_axis = ($angle >= 0) ? mt_rand($img_height, $img_width) : mt_rand(6, $img_height);
245245

246246
// Create image
@@ -296,27 +296,27 @@ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path =
296296
if ($use_font === FALSE)
297297
{
298298
($font_size > 5) && $font_size = 5;
299-
$x = mt_rand(0, $img_width / ($length / 3));
299+
$x = mt_rand(0, (int) ($img_width / ($length / 3)));
300300
$y = 0;
301301
}
302302
else
303303
{
304304
($font_size > 30) && $font_size = 30;
305-
$x = mt_rand(0, $img_width / ($length / 1.5));
305+
$x = mt_rand(0, (int) ($img_width / ($length / 1.5)));
306306
$y = $font_size + 2;
307307
}
308308

309309
for ($i = 0; $i < $length; $i++)
310310
{
311311
if ($use_font === FALSE)
312312
{
313-
$y = mt_rand(0 , $img_height / 2);
313+
$y = mt_rand(0 , (int) ($img_height / 2));
314314
imagestring($im, $font_size, $x, $y, $word[$i], $colors['text']);
315315
$x += ($font_size * 2);
316316
}
317317
else
318318
{
319-
$y = mt_rand($img_height / 2, $img_height - 3);
319+
$y = mt_rand((int) ($img_height / 2), $img_height - 3);
320320
imagettftext($im, $font_size, $angle, $x, $y, $colors['text'], $font_path, $word[$i]);
321321
$x += $font_size;
322322
}

0 commit comments

Comments
 (0)