Foros del Web » Programando para Internet » PHP »

Problema con Captcha

Estas en el tema de Problema con Captcha en el foro de PHP en Foros del Web. Estimados: En http://www.todoalbo.cl/el_muro.html uso un Captcha que funcionaba perfecto!...Pero de un momento a otro no funcionó más! Si entran a http://www.todoalbo.cl/php/captcha.p...0&characters=4 podrán ver el error ...
  #1 (permalink)  
Antiguo 02/07/2009, 08:34
 
Fecha de Ingreso: diciembre-2004
Mensajes: 354
Antigüedad: 19 años, 4 meses
Puntos: 2
Problema con Captcha

Estimados:

En http://www.todoalbo.cl/el_muro.html uso un Captcha que funcionaba perfecto!...Pero de un momento a otro no funcionó más! Si entran a http://www.todoalbo.cl/php/captcha.p...0&characters=4 podrán ver el error que dá.

El codigo PHP del Captcha se los dejo acá:

Código PHP:
<?php
session_start
();
 
/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php

* This program is free software; you can redistribute it and/or 
* modify it under the terms of the GNU General Public License 
* as published by the Free Software Foundation; either version 2 
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful, 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
* GNU General Public License for more details: 
* http://www.gnu.org/licenses/gpl.html
*
*/
 
class CaptchaSecurityImages {
 
   var 
$font 'Arial.ttf';
 
   function 
generateCode($characters) {
      
/* list all possible characters, similar looking characters and vowels have been removed */
      
$possible 'bcdfghjkmnpqrstvwxyz';
      
$code '';
      
$i 0;
      while (
$i $characters) { 
         
$code .= substr($possiblemt_rand(0strlen($possible)-1), 1);
         
$i++;
      }
      return 
$code;
   }
 
   function 
CaptchaSecurityImages($width='120',$height='40',$characters='6') {
      
$code $this->generateCode($characters);
      
/* font size will be 75% of the image height */
      
$font_size $height 0.65;
      
$image imagecreate($width$height) or die('Cannot initialize new GD image stream');
      
/* set the colours */
      
$background_color imagecolorallocate($image255255255);
      
$text_color imagecolorallocate($image000);
      
$noise_color imagecolorallocate($image190190190);
      
/* generate random dots in background */
      
for( $i=0$i<($width*$height)/3$i++ ) {
         
imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
      }
      
/* generate random lines in background */
      
for( $i=0$i<($width*$height)/150$i++ ) {
         
imageline($imagemt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
      }
      
/* create textbox and add text */
      
$textbox imagettfbbox($font_size0$this->font$code) or die('Error in imagettfbbox function');
      
$x = ($width $textbox[4])/2;
      
$y = ($height $textbox[5])/2;
      
imagettftext($image$font_size0$x$y$text_color$this->font $code) or die('Error in imagettftext function');
      
/* output captcha image to browser */
      
header('Content-Type: image/jpeg');
      
imagejpeg($image);
      
imagedestroy($image);
      
$_SESSION['security_code'] = $code;
   }
 
}
 
$width = isset($_GET['width']) && $_GET['height'] < 600 $_GET['width'] : '120';
$height = isset($_GET['height']) && $_GET['height'] < 200 $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > $_GET['characters'] : '6';
 
$captcha = new CaptchaSecurityImages($width,$height,$characters);
 
?>
__________________
Pedro Pablo Vivanco D.
Webmaster todoalbo.cl
[email protected]
http://www.todoalbo.cl
"Dios creo el Cielo, Colo-Colo le puso todas sus Estrellas"
  #2 (permalink)  
Antiguo 02/07/2009, 08:40
Avatar de Carxl
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: Bogotá
Mensajes: 2.993
Antigüedad: 17 años, 8 meses
Puntos: 70
Respuesta: Problema con Captcha

Hola

El error que te arroja es porque usas una función que no estás declarando:

Código:
imagettfbbox()
No creo que sea todo el código...

Busca donde usas y donde declaras esa función, sino te aparece, ahí está el problem

Saludos
__________________
Hay 10 tipos de personas, los que entienden binario y los que no. (Anónimo)
www.programandoweb.com
  #3 (permalink)  
Antiguo 02/07/2009, 08:56
 
Fecha de Ingreso: diciembre-2004
Mensajes: 354
Antigüedad: 19 años, 4 meses
Puntos: 2
Respuesta: Problema con Captcha

Ese es el problema...que no sale como declarada en ninguna parte pero tampoco he modificado nada del Codigo, por eso encuentro muy extraño lo que sucede.
__________________
Pedro Pablo Vivanco D.
Webmaster todoalbo.cl
[email protected]
http://www.todoalbo.cl
"Dios creo el Cielo, Colo-Colo le puso todas sus Estrellas"
  #4 (permalink)  
Antiguo 02/07/2009, 08:57
 
Fecha de Ingreso: diciembre-2004
Mensajes: 354
Antigüedad: 19 años, 4 meses
Puntos: 2
Respuesta: Problema con Captcha

En todo caso, la funcion imagettftext es una funcion predeterminada de PHP: http://php.net/manual/es/function.imagettftext.php

Me tinca que puede ser un problema del Servidor.
__________________
Pedro Pablo Vivanco D.
Webmaster todoalbo.cl
[email protected]
http://www.todoalbo.cl
"Dios creo el Cielo, Colo-Colo le puso todas sus Estrellas"
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:25.