Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    224
    Thanks
    1
    Thanked 0 Times in 0 Posts

    imagettfbbox = undefined function?

    I just downloaded a script, and part of that script is this file:

    PHP Code:
    <?php

    /*

    Nice script from http://www.finalwebsites.com/snippets.php?id=39

    example of usage:
    inside your form
    <input type="text" name="validator" id="validator" size="4" />
    <img src="captcha.php" alt="CAPTCHA image" width="60" height="20" vspace="1" align="top" />

    and test the value of the "validator" form field like:
    if (!empty($_POST['validator']) && $_POST['validator'] == $_SESSION['rand_code']) {
        process your form here
        at least destroy the session
        unset($_SESSION['rand_code']);

    */

    session_start();
    session_regenerate_id(true); // Generate new session id and delete old (PHP >= 5 only)

    // Captcha string
    if (!isset($_SESSION['rand_code'])) {
        
    $str "";
        
    $length 0;
        for (
    $i 0$i 4$i++) {
        
    // this numbers refer to numbers of the ascii table (small-caps)
             
    $str .= chr(rand(97122));
        }
        
    $_SESSION['rand_code'] = $str;
    }

    // generate captcha image
    $imgX 60;
    $imgY 20;
    $image imagecreatetruecolor(6020);
    $backgr_col imagecolorallocate($image238,239,239);
    $border_col imagecolorallocate($image125,125,125);
    $text_col imagecolorallocate($image125,125,125);
    imagefilledrectangle($image006020$backgr_col);
    imagerectangle($image005919$border_col);
    $font "includes/elephant.ttf"// font
    $font_size rand(1215);
    $angle rand(-55);
    //Line 46 VVV
    $box imagettfbbox($font_size$angle$font$_SESSION['rand_code']);
    //Line 46 ^^^
    $x = (int)($imgX $box[4]) / 2;
    $y = (int)($imgY $box[5]) / 2;
    imagettftext($image$font_size$angle$x$y$text_col$font$_SESSION['rand_code']);
    header("Content-type: image/png");
    imagepng($image);
    imagedestroy ($image);

    ?>
    When that is run, I get
    Quote Originally Posted by error
    Fatal error: Call to undefined function: imagettfbbox() in /home/dotbooks/public_html/auth/captcha.php on line 46
    PHP version 4.4.3

    GD info:
    gd
    GD Support enabled
    GD Version bundled (2.0.28 compatible)
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled
    What's going wrong?
    Last edited by Crazydog; 10-28-2006 at 08:53 PM.

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you need Freetype as well as GD


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •