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

Gracias hgp147 el problema consistia el cache del navegador por fin me salio agrege lo q me dijiste y todo me corre Ok aqui les dejo el codigo modificado en caso les sirva a alguien
Captcha.php
Código PHP:
@session_start();
    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;
        }
                
//Esta Funcion me Permite Averiguar si ya existe la sesion Captcha
        
function isSesion()
        {
            if(isset(
$_SESSION["Captcha"]))unset($_SESSION["Captcha"]);
            
session_register("Captcha");
        }
        function 
CaptchaCode($Width = 150, $Height = 50,$CantCar = 7 )
        {
            
$Code = $this->GenerarCode($CantCar);//Generamos una clave al azar
            
$this->isSesion();//Verifico la variable de sesion si ya existe esto me ayuda para q no queden datos grabados asi q si existe lo elimino y creo uno nuevo
            
$_SESSION["Captcha"] = $Code;
                        
//Elimino la cache por si queda grabada para evitarme problemas
            
header("Expires: Sun, 1 Jan 2000 12:00:00 GMT");
            
header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
            
header("Cache-Control: no-store, no-cache, must-revalidate");
            
header("Cache-Control: post-check=0, pre-check=0", false);
            
header("Pragma: no-cache");
            
header('Content-type: image/gif');
            
$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,$Fondo, 0, 0, 0, 0, $Width, $Height,
                               
$FondoSize[0], $FondoSize[1] );
            
$LineaColor = imagecolorallocate($Image, 100, 100, 100);                   
            
//Generando un Random de Lineas en el Fondo
            
for( $i=0; $i<($Width * $Height)/700; $i++ ) 
            {
                
imageline($Image, mt_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($Image, mt_rand(0,$Width), mt_rand(0,$Height), 1, 1,
                 
$LineaColor);
            }
            
$Color = imagecolorallocate($Image, 20, 40, 100);
            
$Text = imagettfbbox($Size,0,$this->Font,$Code);
            
$x = ($Width - $Text[4])/2;
            
$y = ($Height - $Text[5])/2;
            
imagettftext($Image, $Size, 5, $x, $y, $Color, $this->Font , $Code);
            
imagegif($Image);
            
imagedestroy($Image);
            
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); 
Registro.php
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');"/>  
...... 
aqui va el js q ha sido corregido

Código PHP:
function CambiarCar(img)
{
    var 
Obj = document.getElementById(img);
    if (!
Obj) Obj = window.document.all.ImgCaptcha;
    if(
Obj)
    {
        var 
date = new Date();
        var 
Time = date.getTime();
        
Obj.src = "Captcha.php?Time="+Time;
    }
} 
Ahora el Captcha si Cambia Gracias a Todos