Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/01/2009, 12:42
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 11 meses
Puntos: 220
Actualizar el Captcha

Hola a Todos Tengo una Pequeña Dudad sobre los captcha en php
mi Codigo es el siguiente
Captcha.php
Código PHP:
<?php
    
@session_start();
    unset(
$_SESSION["Captcha"]);
    
session_register("Captcha");
    class 
CaptchaCode
    
{
        var 
$Font "Captcha/font23.ttf";
        function 
GenerarCode($CantCar)
        {
            
$Letras "023456789ABCDEFJHIJKMNOPQRSTUVWXYZabcdefjhijkmnopqrstuvwxyz";
            
$Codigo "";
            for(
$i 0$i $CantCar$i++)
            {
                
$Codigo.=substr($Letras,rand(0,60),1);
            }
            return 
$Codigo;
        }
        function 
CaptchaCode($Width 150$Height 50,$CantCar )
        {
            
header('Content-type: image/gif');
            
$Code $this->GenerarCode($CantCar);//Generamos una clave al azar
            
$Size $Height*0.50;//Tamaño de Letra a Dar depende de el Alto del texto
            
$Fondo imagecreatefromgif("Captcha/11.gif");
            
$FondoSize getimagesize("Captcha/11.gif");
            
$Image imagecreatetruecolor($Width,$Height);
            
//Insertamos el Fondo con la Opacidad q le Asignemos Dandole un Posicion x e y
            
imagecopyresampled($Image,$Fondo0000$Width$Height,
                               
$FondoSize[0], $FondoSize[1] );
            
$LineaColor imagecolorallocate($Image100100100);                   
            
//Generando un Random de Lineas en el Fondo
            
for( $i=0$i<($Width $Height)/700$i++ ) 
            {
                
imageline($Imagemt_rand(0,$Width), mt_rand(0,$Height), mt_rand(0,$Width),
                         
mt_rand(0,$Height), $LineaColor);
            }
            
//Generando un Random de Puntos en el Fondo
            
for( $i=0$i<($Width $Height)/7$i++ ) 
            {
                
imagefilledellipse($Imagemt_rand(0,$Width), mt_rand(0,$Height), 11,
                 
$LineaColor);
            }
            
$Color imagecolorallocate($Image2040100);
            
$Text imagettfbbox($Size,0,$this->Font,$Code);
            
$x = ($Width $Text[4])/2;
            
$y = ($Height $Text[5])/2;
            
imagettftext($Image$Size5$x$y$Color$this->Font $Code);
            
imagegif($Image);
            
imagedestroy($Image);
            
$_SESSION["Captcha"] = $Code;
            
session_write_close();//Cierra la Sesion y Guarda los Datos
        
}
    }
    
$Width = isset($_GET["w"]) ? $_GET["w"] : 250;
    
$Height = isset($_GET["h"]) ? $_GET["h"] : 50;
    
$Car = isset($_GET["c"]) ? $_GET["c"] : 7;
    
$Captcha = new CaptchaCode($Width,$Height,$Car);
?>
con esto me genero un Captcha q va a ser reicibido en una imagen
y lo muestro en una imagen
Código PHP:
 <img id="ImgCaptcha" name="ImgCaptcha"
            
src="Captcha.php"/>
<
img src="../Imagenes/Adornos/reload.gif" width="22" height="22" class="MenImg"
            
title="Ver un Nuevo Conjunto de Caracteres"
             
onclick="CambiarCar('ImgCaptcha');"/> 
el Js es el Siguiente
Código PHP:
function CambiarCar(img)
{
    var 
Obj document.getElementById(img);
    if (!
ObjObj window.document.all.ImgCaptcha;
    if(
Obj)
    {
        
Obj.src "Captcha.php";
    }

Mi problema es q al hacerle click ala imagen reload.gif la imagen de captcha no cambia he tratado de mil formas de ver porq no cambia quisiera ayuda estoy deseperado
me han dicho q tal vez pueda ser la sesion pero no se como hacerlo ni tengo idea de otro planteamiento por favor ayuda