Fix captcha generator securimage.php to work with php 8
- basically use intval() everywhere to avoid implicit conversion from float
This commit is contained in:
parent
4f5dcd1773
commit
b118588a82
|
@ -338,6 +338,8 @@ class Securimage
|
||||||
|
|
||||||
/*%*********************************************************************%*/
|
/*%*********************************************************************%*/
|
||||||
// Properties
|
// Properties
|
||||||
|
public $config_file;
|
||||||
|
public $gdnoisecolor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the captcha image
|
* The width of the captcha image
|
||||||
|
@ -2232,9 +2234,9 @@ class Securimage
|
||||||
$py = array(); // y coordinates of poles
|
$py = array(); // y coordinates of poles
|
||||||
$rad = array(); // radius of distortion from pole
|
$rad = array(); // radius of distortion from pole
|
||||||
$amp = array(); // amplitude
|
$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
|
$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
|
$y = mt_rand(20, $this->image_height - 20); // random y coord
|
||||||
$dy = mt_rand(20, $this->image_height * 0.7); // y distance
|
$dy = mt_rand(20, $this->image_height * 0.7); // y distance
|
||||||
$minY = 20; // minimum y coordinate
|
$minY = 20; // minimum y coordinate
|
||||||
|
@ -2277,7 +2279,7 @@ class Securimage
|
||||||
$x *= $this->iscale;
|
$x *= $this->iscale;
|
||||||
$y *= $this->iscale;
|
$y *= $this->iscale;
|
||||||
if ($x >= 0 && $x < $width2 && $y >= 0 && $y < $height2) {
|
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
|
if ($c != $bgCol) { // only copy pixels of letters to preserve any background image
|
||||||
imagesetpixel($this->im, $ix, $iy, $c);
|
imagesetpixel($this->im, $ix, $iy, $c);
|
||||||
|
@ -2298,7 +2300,7 @@ class Securimage
|
||||||
|
|
||||||
$theta = ($this->frand() - 0.5) * M_PI * 0.33;
|
$theta = ($this->frand() - 0.5) * M_PI * 0.33;
|
||||||
$w = $this->image_width;
|
$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);
|
$lwid = mt_rand(0, 4);
|
||||||
|
|
||||||
$k = $this->frand() * 0.6 + 0.2;
|
$k = $this->frand() * 0.6 + 0.2;
|
||||||
|
@ -2318,7 +2320,7 @@ class Securimage
|
||||||
for ($i = 0; $i < $n; ++ $i) {
|
for ($i = 0; $i < $n; ++ $i) {
|
||||||
$x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
|
$x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
|
||||||
$y = $y0 + $i * $dy - $amp * $dx * 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue