We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9585
    • 50 Posts
    Hi Folks,

    I’ve run into a strange problem displaying the CAPTCHA verification codes in forms. I have several forms throughout the site and the CAPTCHAs were displaying fine until a couple of days ago. The site is running on a subdomain, on php4. When I run phpinfo.php it says GD is supported but there is no mention of Freetype - I know both of these things are required to generate CAPTCHAs but then how come they were dispaying ok until recently?

    Instead of the CAPTCHA image I get a blank with ’verification code’ and if I look at the source I get <img src="/manager/includes/veriword.php?rand=2145727560" alt="verification code" /> . If I put this source in a browser I get ’
    Fatal error: Call to undefined function: imagettfbbox() in /home/softplan/public_html/learn/manager/includes/veriword.php on line 124’

    Anyone got any ideas?

    thanks

    Danny
      • 33992 ☆ A M B ☆
      • 455 Posts
      Hi Danny,
      Quote from: PHP.net

      Note: This function requires GD 2.0.1 or later (2.0.28 or later is recommended).


        God loves me. 【ツ】


        MODX.ir (Persian Support)

        Boplo.ir/modx/ (Persian)
        • 9585
        • 50 Posts
        Thanks, just check and GD vesion 2.0.28 is installed so I guess that’s ok. I wonder if it might be a subdomain issue.
          • 3749
          • 24,544 Posts
          I found this via Google:

          "Using imagettfbbox with relative font paths in PHP >= 4.3.0 may result in an error. A solution seems to be to use absolute paths. If this isn’t the issue, it could be spaces in the filename."



          Try hardcoding the path in line 124 of veriword.php.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 9585
            • 50 Posts
            Thanks....can’t see any path in line 124 of veriword.php just ’ $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word);’

            I notice there’s paths to the font (ttf) and noises directories at the top of veriword.php but if I put absolute paths in here it gives me even more errors.
              • 3749
              • 24,544 Posts
              I don’t have the original version of vericode.php but the section that’s causing the trouble should look something like this:

              $dir = dir("[color=red]./ttf[/color]");
              
                   $fontstmp = array();
                   while (false !== ($file = $dir->read())) {
                        if($file!="." && $file!=".." && file_exists('[color=red]./ttf/[/color]'.$file) && !is_dir('[color=red]./ttf/[/color]'.$file)) {
                             $fontstmp[] = '[color=red]./ttf/[/color]'.$file;
                        }
                   }


              All the highlighted sections would have to be changed to a full absolute paths--probably from your user root (not the site root). e.g. /home/user/public_html/site_name/. etc.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 9585
                • 50 Posts
                Thanks Bob, will give that a try