captchas

Iniciado por peib0l, 20 Diciembre 2011, 13:41 PM

0 Miembros y 1 Visitante están viendo este tema.

EFEX

Version de GIFEncoder que utilizé PHPclasses / Pastie Bin.
Código (php) [Seleccionar]

<?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(01000000);
$key strtoupper(substr(md5microtime() * $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->captcha30$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->framed02000'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 == $this->circulo() : 'no' ;
$n == $this->bum() : 'no' ;
$n == $this->desliz() : 'no' ;
}
}

public function circulo()
{
$circulo_x 40;
$circulo_y 0;
$frames_x 20;
for($b=0;$b<$frames_x;$b++){
$im imagecreatetruecolor(15080);
imagecopy($im$this->captcha0000imagesx($this->captcha), imagesy($this->captcha));
//fix
$white ImageColorAllocate($im,255,255,255);
ImageFill($im,0,0,$white);
$circulo imagecolorallocate($im000);
imagefilledellipse$im$circulo_y$circulo_x3030$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(15080);
imagecopy($im$this->captcha0000imagesx($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(15080);
imagecopy($im$this->captcha0000imagesx($this->captcha), imagesy($this->captcha));
//fix
$white ImageColorAllocate($im,255,255,255);
ImageFill($im,0,0,$white);
imagefilledrectangle($im,($b 1) * 8,1,$imgwidth,$imgheight0);
$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();

?>

GITHUB