No Funcionó, alguna idea?
Código PHP:
<?php
ob_start();
###########################################################################################
#
# CAPTCHA FÁCIL 1.0
#
# Autor: Alejandro Martín Núñez
# Contact: alemnunez at gmail dot com
# Date: October 10, 2009
#
# COMO USAR CAPTCHA FÁCIL
#
# FORMULARIO
# En el formulario que deseas validar, inserta el siguiente código:
#
# <img src="captcha.php" /><br/>
# <input type="text" size="12" name="captcha" />
#
#
# VERIFICACIÓN
# Al procesar el formulario, compara el contenido del campo que
# completó el usuario con el contenido de $_SESSION["captcha"]
# que generó este programa:
#
# session_start();
# if(strtoupper($_REQUEST["captcha"]) == $_SESSION["captcha"]){
# // REMPLAZO EL CAPTCHA USADO POR UN TEXTO LARGO PARA EVITAR QUE SE VUELVA A INTENTAR
# $_SESSION["captcha"] = md5(rand()*time());
# // INSERTA EL CÓDIGO EXITOSO AQUI
# }else{
# // REMPLAZO EL CAPTCHA USADO POR UN TEXTO LARGO PARA EVITAR QUE SE VUELVA A INTENTAR
# $_SESSION["captcha"] = md5(rand()*time());
# // INSERTA EL CÓDIGO DE ERROR AQUÍ
# }
#
#
# OLVIDÁ EL SPAM!
#
###########################################################################################
#create image and set background color
$captcha = imagecreatetruecolor(120,35);
$background_color = imagecolorallocate($captcha, 255, 255, 255);
imagefill($captcha, 0, 0, $background_color);
#generate a random string of 5 characters
$string = substr(md5(rand()*time()),0,5);
#make string uppercase and replace "O" and "0" to avoid mistakes
$string = strtoupper($string);
$string = str_replace("O","B", $string);
$string = str_replace("0","C", $string);
#save string in session "captcha" key
session_start();
$_SESSION["captcha"]=$string;
#place each character in a random position
$font = 'arial.ttf';
for($i=0;$i<5;$i++){
$color = rand(0,32);
if(file_exists($font)){
$x=4+$i*23+rand(0,6);
$y=rand(18,28);
imagettftext ($captcha, 15, rand(-25,25), $x, $y, imagecolorallocate($captcha, $color, $color, $color), $font, $string[$i]);
}else{
$x=5+$i*24+rand(0,6);
$y=rand(1,18);
imagestring($captcha, 5, $x, $y, $string[$i], imagecolorallocate($captcha, $color, $color, $color));
}
}
#applies distorsion to image
$matrix = array(array(1, 1, 1), array(1.0, 7, 1.0), array(1, 1, 1));
imageconvolution($captcha, $matrix, 16, 32);
#avoids catching
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
#return the image
header("Content-type: image/gif");
imagejpeg($captcha);
ob_end_flush();
?>
Lo convirtio en Texto al Error:
Cita: <br />
<b>Warning</b>: imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagettftext() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagettftext() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagettftext() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagettftext() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagecolorallocate(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imagettftext() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>: imageconvolution() expects parameter 1 to be resource, string given in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>78</b><br />
<br />
<b>Warning</b>: imagejpeg(): supplied argument is not a valid Image resource in <b>/home/miweb/public_html/captcha/captcha.php</b> on line <b>87</b><br />