From 6544a2d2e20d38253d2073b9dff9ca9affef2e20 Mon Sep 17 00:00:00 2001 From: Repellent Date: Sat, 8 Nov 2025 22:41:40 +0500 Subject: [PATCH] fix kcaptcha --- lib/kcaptcha/kcaptcha.php | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/kcaptcha/kcaptcha.php b/lib/kcaptcha/kcaptcha.php index 5de0357..c09a516 100644 --- a/lib/kcaptcha/kcaptcha.php +++ b/lib/kcaptcha/kcaptcha.php @@ -1,6 +1,6 @@ keystring, $i, 1)]; - $y=(($i%2)*$fluctuation_amplitude - $fluctuation_amplitude/2)*$odd + // 🛑 ИСПРАВЛЕНИЕ: Приведение к int для координаты Y + $y=(int)( + (($i%2)*$fluctuation_amplitude - $fluctuation_amplitude/2)*$odd + mt_rand(-round($fluctuation_amplitude/3), round($fluctuation_amplitude/3)) - + ($height-$fontfile_height)/2; + + ($height-$fontfile_height)/2 + ); if($no_spaces){ $shift=0; @@ -104,7 +101,10 @@ class KCAPTCHA{ $opacity=$rgb>>24; if($opacity<127){ $left=$sx-$m['start']+$x; - $py=$sy+$y; + + // 🛑 ИСПРАВЛЕНИЕ: Приведение к int для координаты PY + $py=(int)($sy+$y); + if($py>$height) break; for($px=min($left,$width-1);$px>$left-200 && $px>=0;$px-=1){ $color=imagecolorat($img, $px, $py) & 0xff; @@ -172,8 +172,9 @@ class KCAPTCHA{ for($x=0;$x<$width;$x++){ for($y=0;$y<$height;$y++){ - $sx=$x+(sin($x*$rand1+$rand5)+sin($y*$rand3+$rand6))*$rand9-$width/2+$center+1; - $sy=$y+(sin($x*$rand2+$rand7)+sin($y*$rand4+$rand8))*$rand10; + // 🛑 ИСПРАВЛЕНИЕ: Приведение к int для sx и sy + $sx=(int)($x+(sin($x*$rand1+$rand5)+sin($y*$rand3+$rand6))*$rand9-$width/2+$center+1); + $sy=(int)($y+(sin($x*$rand2+$rand7)+sin($y*$rand4+$rand8))*$rand10); if($sx<0 || $sy<0 || $sx>=$width-1 || $sy>=$height-1){ continue; @@ -206,18 +207,18 @@ class KCAPTCHA{ $newcolor=$newcolor/255; $newcolor0=1-$newcolor; - $newred=$newcolor0*$foreground_color[0]+$newcolor*$background_color[0]; - $newgreen=$newcolor0*$foreground_color[1]+$newcolor*$background_color[1]; - $newblue=$newcolor0*$foreground_color[2]+$newcolor*$background_color[2]; + $newred=(int)($newcolor0*$foreground_color[0]+$newcolor*$background_color[0]); + $newgreen=(int)($newcolor0*$foreground_color[1]+$newcolor*$background_color[1]); + $newblue=(int)($newcolor0*$foreground_color[2]+$newcolor*$background_color[2]); } imagesetpixel($img2, $x, $y, imagecolorallocate($img2, $newred, $newgreen, $newblue)); } } - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Cache-Control: no-store, no-cache, must-revalidate'); - header('Cache-Control: post-check=0, pre-check=0', FALSE); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + header('Cache-Control: no-store, no-cache, must-revalidate'); + header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); if(function_exists("imagejpeg")){ header("Content-Type: image/jpeg");