From b118588a8260b61e4fa08dfb992b9ee8dab7ce27 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Tue, 7 May 2024 10:54:59 -0400 Subject: [PATCH] Fix captcha generator securimage.php to work with php 8 - basically use intval() everywhere to avoid implicit conversion from float --- inc/lib/securimage/securimage.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/inc/lib/securimage/securimage.php b/inc/lib/securimage/securimage.php index 23a8feaa..a2be97f7 100644 --- a/inc/lib/securimage/securimage.php +++ b/inc/lib/securimage/securimage.php @@ -338,6 +338,8 @@ class Securimage /*%*********************************************************************%*/ // Properties + public $config_file; + public $gdnoisecolor; /** * The width of the captcha image @@ -2232,9 +2234,9 @@ class Securimage $py = array(); // y coordinates of poles $rad = array(); // radius of distortion from pole $amp = array(); // amplitude - $x = ($this->image_width / 4); // lowest x coordinate of a pole + $x = round($this->image_width / 4); // lowest x coordinate of a pole $maxX = $this->image_width - $x; // maximum x coordinate of a pole - $dx = mt_rand($x / 10, $x); // horizontal distance between poles + $dx = mt_rand(intval($x / 10), $x); // horizontal distance between poles $y = mt_rand(20, $this->image_height - 20); // random y coord $dy = mt_rand(20, $this->image_height * 0.7); // y distance $minY = 20; // minimum y coordinate @@ -2277,7 +2279,7 @@ class Securimage $x *= $this->iscale; $y *= $this->iscale; if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) { - $c = imagecolorat($this->tmpimg, $x, $y); + $c = imagecolorat($this->tmpimg, intval($x), intval($y)); } if ($c != $bgCol) { // only copy pixels of letters to preserve any background image imagesetpixel($this->im, $ix, $iy, $c); @@ -2298,7 +2300,7 @@ class Securimage $theta = ($this->frand() - 0.5) * M_PI * 0.33; $w = $this->image_width; - $len = mt_rand($w * 0.4, $w * 0.7); + $len = mt_rand(intval($w * 0.4), intval($w * 0.7)); $lwid = mt_rand(0, 4); $k = $this->frand() * 0.6 + 0.2; @@ -2318,7 +2320,7 @@ class Securimage for ($i = 0; $i < $n; ++ $i) { $x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi); $y = $y0 + $i * $dy - $amp * $dx * sin($k * $i * $step + $phi); - imagefilledrectangle($this->im, $x, $y, $x + $lwid, $y + $lwid, $this->gdlinecolor); + imagefilledrectangle($this->im, intval($x), intval($y), intval($x + $lwid), intval($y + $lwid), $this->gdlinecolor); } } }