Skip to content

Commit c0b8c6e

Browse files
authored
fix generating captcha in PHP 8.1
addresses a PHP 8.1 (and above) deprecation issue that results in losing precision because of `float` instead of `int` when creating a captcha
1 parent 63d0375 commit c0b8c6e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

system/helpers/captcha_helper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,12 @@ function create_captcha($data)
297297
{
298298
$theta += $thetac;
299299
$rad = $radius * ($i / $points);
300-
$x = ($rad * cos($theta)) + $x_axis;
301-
$y = ($rad * sin($theta)) + $y_axis;
300+
$x = round(($rad * cos($theta)) + $x_axis);
301+
$y = round(($rad * sin($theta)) + $y_axis);
302302
$theta += $thetac;
303303
$rad1 = $radius * (($i + 1) / $points);
304-
$x1 = ($rad1 * cos($theta)) + $x_axis;
305-
$y1 = ($rad1 * sin($theta)) + $y_axis;
304+
$x1 = round(($rad1 * cos($theta)) + $x_axis);
305+
$y1 = round(($rad1 * sin($theta)) + $y_axis);
306306
imageline($im, $x, $y, $x1, $y1, $colors['grid']);
307307
$theta -= $thetac;
308308
}

0 commit comments

Comments
 (0)