1
leopsyrj
setImageSize() class/captcha/image/scripts/image.php
  • 2010/9/16 15:58

  • leopsyrj

  • Just popping in

  • Posts: 5

  • Since: 2008/8/28


function setImageSize()
{
$MaxCharWidth = 0;
$MaxCharHeight = 0;
$oImage = imagecreatetruecolor(100, 100);
$text_color = imagecolorallocate($oImage, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
$FontSize = $this->config["fontsize_max"];
for ($Angle = -30; $Angle <= 30; $Angle++) {
for ($i = 65; $i <= 90; $i++) {
$CharDetails = imageftbbox($FontSize, $Angle, $this->font, chr($i), array());
$_MaxCharWidth = abs($CharDetails[0] + $CharDetails[2]);
if (($_MaxCharWidth > $MaxCharWidth ) && ($_MaxCharWidth < 1000000)) {
$MaxCharWidth = $_MaxCharWidth;
}
$_MaxCharHeight = abs($CharDetails[1] + $CharDetails[5]);
if (($_MaxCharHeight > $MaxCharHeight ) && ($_MaxCharHeight < 1000000)) {
$MaxCharHeight = $_MaxCharHeight;
}
}
}
imagedestroy($oImage);

$this->height = $MaxCharHeight + 2;
$this->spacing = intval( ($this->config["num_chars"] * $MaxCharWidth) / $this->config["num_chars"] );
$this->width = ($this->config["num_chars"] * $MaxCharWidth) + ($this->spacing/2);
}


class/captcha/image/scripts/image.php line 202 and 206
of xoops 2,4,5

$_MaxCharWidth and $_MaxCharHeight get a high values (2147483651 p ex) only on first call of imageftbbox...

making a big loop on function drawBars(), server slow response and no shows the image...

i resolved adding && ($_MaxCharWidth < 1000000)
working fine now...

Login

Who's Online

253 user(s) are online (124 user(s) are browsing Support Forums)


Members: 0


Guests: 253


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits