Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales
Autor
|
Tema: captchas (Leído 921 veces)
|
peib0l
Wiki
Conectado
Mensajes: 3.122
vista mi blog ^.^
|
 |
captchas
« en: 20 Diciembre 2011, 13:41 » |
|
hola amigos, estoy con el tema de los captcha y me preguntaba como se hacen estos  y la otra pregunta es como se implementan los captcha ya creados como el de google? Gracias!
|
|
|
|
|
En línea
|
|
|
|
|
|
EFEX
Desconectado
Mensajes: 327
"Dinero Facil"
|
Traté de hacer un script pero creo que la libreria GD no soporta animaciones gif? <?php function crearCaptcha($largo = 8){ $captcha = imagecreatefromgif("bg.gif"); $posicionX=15; for($i = 0;$i <$largo;$i++){ $r=rand(0,255); $g=rand(0,255); $b=rand(0,255); $numero = rand(0,9); $posicionY=rand(20,40); $colorText = imagecolorallocate($captcha, $r, $g, $b); imagestring($captcha, 12, $posicionX, $posicionY, $numero, $colorText); $posicionX+=15; } $black = ImageColorAllocate($captcha,0,0,0); ImageFill($captcha,0,0,$black); ImageColorTransparent($captcha,$black); $superponer = imagecreatefromgif("sub.gif"); imagecopy( $captcha, $superponer, 0, 0, 0, 0, imagesx( $superponer ), imagesy( $superponer ) ); header("Content-type: image/gif"); imagegif($captcha); } crearCaptcha(); ?> Animación  Fondo  Resultado  
|
|
|
|
|
En línea
|
GITHUB: github.com/empirefx
|
|
|
|
|
|
|
EFEX
Desconectado
Mensajes: 327
"Dinero Facil"
|
Pero ¿ debo primero tomar los frames animados, ponerle de fondo el captcha a cada uno, gardarlos por frame y despues unirlos con la clase ? Veo que tiene problemas con la transparencia y la animacion..  v3.0 gifencoder
|
|
|
|
« Última modificación: 23 Diciembre 2011, 15:20 por EFEX »
|
En línea
|
GITHUB: github.com/empirefx
|
|
|
dark_sargon
Desconectado
Mensajes: 532
CJ
|
Encontré un script ya hecho. Lo que hace es crear todos los frames en la carpeta 'tmp' y luego construye el GIF y los borra. Se podría hacer aleatoria la animación para que no sea la misma siempre.  A ver si nos ponemos en la tarea de mejorar la apariencia. Éste tema de las CAPTCHAs es muy interesante. Acá el script junto con la clase GIFEncoder: http://www.actimediaonline.com/captchaGIF.zip
|
|
|
|
|
En línea
|
|
|
|
EFEX
Desconectado
Mensajes: 327
"Dinero Facil"
|
No me crea el gif por que no me guarda las imagenes en la carpeta tmp ¿por que ?
|
|
|
|
|
En línea
|
GITHUB: github.com/empirefx
|
|
|
peib0l
Wiki
Conectado
Mensajes: 3.122
vista mi blog ^.^
|
Alguno a sacado ya como hacerlos en movimiento?  yo sigo en ello pero no se mueve...
|
|
|
|
|
En línea
|
|
|
|
EFEX
Desconectado
Mensajes: 327
"Dinero Facil"
|
Alguno a sacado ya como hacerlos en movimiento?  yo sigo en ello pero no se mueve... Es crear varios frames, como un gif con un circulo, cuadrado, lo que sea (hacerlo aleatorio) que tape parte del captcha y despues unirlos con el script que menciona dark_sargon, el problema que tenia es que no me guarda la imagen creada en el archivo tmp(es el mismo script que aconseja dark_sargon), haber si alguien me ayuda asi seguimos con esto  .
|
|
|
|
|
En línea
|
GITHUB: github.com/empirefx
|
|
|
EFEX
Desconectado
Mensajes: 327
"Dinero Facil"
|
Version de GIFEncoder que utilizé PHPclasses / Pastie Bin. <?php /* ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: GIFEncoder Version 2.0 by László Zsidi, http://gifs.hu :: ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */ include "GIFEncoder.class.php"; class Captcha { protected $captcha; protected $clave; function __construct() { $rnd = rand(0, 1000000); $key = strtoupper(substr(md5( microtime() * $rnd),1,5)); $this->clave = $key; $this->captcha = imagecreatefromgif('bg.gif'); $posicion_x=15; for($i = 0;$i<strlen($key);$i++){ $r=rand(0,255); $g=rand(0,255); $b=rand(0,255); $posicion_y=rand(20,40); $colorText = imagecolorallocate($this->captcha, $r, $g, $b); imagestring($this->captcha, 30, $posicion_x, $posicion_y, $key[$i], $colorText); $posicion_x+=25; } //Fix con el color de la segunda letra $white = ImageColorAllocate($this->captcha,0,0,0); ImageColorTransparent($this->captcha,$white); } public function imprimir() { if (!empty($this->frames) AND !empty($this->framed)) { $gif = new GIFEncoder($this->frames, $this->framed, 0, 2, 0, 0, 0, 'url'); Header ('Content-type:image/gif'); echo $gif->GetAnimation(); imagedestroy($this->captcha); }else{ Header('Content-type:image/gif'); imagegif($this->captcha); } } public function guardar() { $_SESSION['CAPTCHA_TEXT'] = $this->clave; return $this->clave; } } class Animacion extends Captcha { public $frames; public $framed; function __construct($aleatorio = 1) { parent::__construct(); if ($aleatorio == 1) { $n = rand(1,3); $n == 1 ? $this->circulo() : 'no' ; $n == 2 ? $this->bum() : 'no' ; $n == 3 ? $this->desliz() : 'no' ; } } public function circulo() { $circulo_x = 40; $circulo_y = 0; $frames_x = 20; for($b=0;$b<$frames_x;$b++){ $im = imagecreatetruecolor(150, 80); imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha)); //fix $white = ImageColorAllocate($im,255,255,255); ImageFill($im,0,0,$white); $circulo = imagecolorallocate($im, 0, 0, 0); imagefilledellipse( $im, $circulo_y, $circulo_x, 30, 30, $circulo ); $fname = 'tmp/'.$b.'.gif'; imagegif($im, $fname); $this->frames[] = $fname; $this->framed[] = 1; $circulo_y+=10; imagedestroy($im); } $this->imprimir(); } public function bum() { $frames_x = 30; for($b=0;$b<$frames_x;$b++){ $im = imagecreatetruecolor(150, 80); imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha)); //fix $white = ImageColorAllocate($im,255,255,255); ImageFill($im,0,0,$white); imagefilledrectangle($im,($b*5),($b*5),10+($b*5),10+($b*5),0); imagefilledrectangle($im,($b*1),($b*5),10+($b*1),10+($b*5),0); imagefilledrectangle($im,($b*3)*2,($b*1)+$b,10+($b*3)*2,10+($b*1)+$b,0); imagefilledrectangle($im,($b*4)*2,($b*2)+$b,10+($b*4)*2,10+($b*2)+$b,0); $fname = 'tmp/'.$b.'.gif'; imagegif($im, $fname); $this->frames[] = $fname; $this->framed[] = 1; imagedestroy($im); } $this->imprimir(); } public function desliz() { $imgwidth = imagesx($this->captcha); $imgheight = imagesy($this->captcha); $frames_x = 30; for($b=0;$b<$frames_x;$b++){ $im = imagecreatetruecolor(150, 80); imagecopy($im, $this->captcha, 0, 0, 0, 0, imagesx($this->captcha), imagesy($this->captcha)); //fix $white = ImageColorAllocate($im,255,255,255); ImageFill($im,0,0,$white); imagefilledrectangle($im,($b - 1) * 8 + 8,1,$imgwidth,$imgheight, 0); $fname = 'tmp/'.$b.'.gif'; imagegif($im, $fname); $this->frames[] = $fname; $this->framed[] = 1; imagedestroy($im); } $this->imprimir(); } } // Animacion aleatoria $showtime = new Animacion(); //$showtime->guardar(); // Seleccionar animacion //$showtime = new Animacion(0); //$showtime->bum(); // Sin animacion //$showtime = new Captcha(); //$showtime->imprimir(); ?>
|
|
|
|
|
En línea
|
GITHUB: github.com/empirefx
|
|
|
|
|