Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-28-2006, 07:50 PM   PM User | #1
Crazydog
Regular Coder

 
Join Date: May 2005
Posts: 224
Thanks: 1
Thanked 0 Times in 0 Posts
Crazydog is an unknown quantity at this point
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:
Quote:
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 07:53 PM..
Crazydog is offline   Reply With Quote
Old 10-28-2006, 08:01 PM   PM User | #2
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
you need Freetype as well as GD
GJay is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.