forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 miscellaneous => Topic started by: forumac on June 28, 2022, 09:18:38 pm

Title: Problem displaying captcha code
Post by: forumac on June 28, 2022, 09:18:38 pm
When adding comments the captcha code displays only lines, no letters.
https://www.forumancientcoins.com/ancient-maps/displayimage.php?album=34&pid=366#top_display_media
We are using CPG 1.6.03, the problem happend when upgrading to PHP 7.2.
The same php.ini file is used and of course GD2 is enabled ("extension=php_gd2.dll").
Here is how captcha.php displays: https://www.forumancientcoins.com/Ancient-Maps/captcha.php
And here is DrawCharacters() function from captcha.inc.php
Code: [Select]
      function DrawCharacters() {
         // loop through and write out selected number of characters
         for ($i = 0; $i < strlen($this->sCode); $i++) {
            // select random font
            $sCurrentFont = $this->aFonts[array_rand($this->aFonts)];

            // select random greyscale colour
            $iRandColour = rand(0, 100);
            $iTextColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour);

            if ($this->bCharShadow) {
               // shadow colour
               $iRandColour = rand(0, 100);
               $iShadowColour = imagecolorallocate($this->oImage, $iRandColour, $iRandColour, $iRandColour);
            }

            // select random font size
            $iFontSize = rand(16, 25);

            // select random angle
            $iAngle = rand(-30, 30);

            // get dimensions of character in selected font and text size
            $aCharDetails = imageftbbox($iFontSize, $iAngle, $sCurrentFont, $this->sCode[$i]);

            // calculate character starting coordinates
            $iX = $this->iSpacing / 4 + $i * $this->iSpacing;
            $iCharHeight = $aCharDetails[2] - $aCharDetails[5];
            $iY = $this->iHeight / 2 + $iCharHeight / 4;

            // write text to image
            imagefttext($this->oImage, $iFontSize, $iAngle, $iX, $iY, $iTextColour, $sCurrentFont, $this->sCode[$i]);

            if ($this->bCharShadow) {
               $iOffsetAngle = rand(-30, 30);

               $iRandOffsetX = rand(-5, 5);
               $iRandOffsetY = rand(-5, 5);

               imagefttext($this->oImage, $iFontSize, $iOffsetAngle, $iX + $iRandOffsetX, $iY + $iRandOffsetY, $iShadowColour, $sCurrentFont, $this->sCode[$i]);
            }
         }
      }
Title: Re: Problem displaying captcha code
Post by: forumac on June 28, 2022, 09:42:52 pm
Sorry, for the first link you must be logged in, I'm sending here a screen capture:
Title: Re: Problem displaying captcha code
Post by: forumac on June 28, 2022, 09:45:53 pm
And the upgrade was from PHP 7.1 to PHP 7.2, nothing changed to CPG, it is still version 1.6.03.
Title: Re: Problem displaying captcha code
Post by: phill104 on June 29, 2022, 07:20:51 pm
Please upgrade to the latest release. If the problem still exists we can help then