Location: PHPKode > projects > ZompLog > plugins/captcha/image.php
<?php
session_start();
### NEW CAPTCHA BY TIM
header("Content-Type: image/gif"); 
error_reporting(E_ALL);
class captcha
{

	function captcha($typ="mysql") 
	{
	$this->typ = $typ;	
	$this->anzahl = 4;
	$this->multi = 37; ### GRÖßE des gifs
	$this->randstr['font'] = rand(8.1,10)*$this->multi/10; //fontgröße
	$this->randstr['grad'] = rand("-10","10");
	}
	
	function buffer($str,$typ)
	{
		if($typ==0)
		{
		@$this->buffer.=$str;
		return $str;
		}
		else
		{
		return $this->buffer;
		}
	}
	
	function createrandom()
	{
	$typ = rand(1,2);
		if($typ == 1)
		{
		## zahlen ##
		$buffer = rand(1,9);
		$this->buffer($buffer,0);
		return $buffer;
		}
		else
		{
		return $this->buffer(chr(rand(65,90)),0);	
		}	
	}
	
		
	
	function getfont()
	{
			foreach (glob("fonts/*.TTF") as $font) 
			{
			$fonts[] = $font;
			}
	return $fonts[rand(0,count($fonts)-1)];
	}
	
	function pixel_left($str=20)
	{
		@$this->bufferleft++;		
		if($this->bufferleft == 1)
		{
		return 10;
		}
		else
		{
		return $this->multi*$this->bufferleft-0.5*$this->multi;
		}
	}
	
	function create_image()
	{
	#### erstell bild
	$höhe = $this->multi*5*$this->anzahl/4;
	$breite = $this->multi*1.35;
	$im = ImageCreate($höhe,$breite);
	$col_sw = ImageColorAllocate($im, 0, 0, 0);
    ImageColorTransparent($im, $col_sw );
	#### bild erstellt
	#### den hintergrund basteln
	for ($i = 1; $i <= $this->anzahl; $i++) {
	ImageTTFText ($im, rand(166,209), $this->randstr['grad'], rand(0,200), rand(0,280), ImageColorAllocate($im,  rand(120,255), rand(120,255),  rand(120,255)), $this->getfont(), "X");
	}
	
	
	#### nun schriftzüge
	
	
	$color = ImageColorAllocate($im, 654, 0, 0);
	for ($i = 1; $i <= $this->anzahl; $i++) {
	ImageTTFText ($im, $this->randstr['font'], $this->randstr['grad'], $this->pixel_left(), 45/37*$this->multi, ImageColorAllocate($im,  rand(0,105), rand(0,105),  rand(0,105)), $this->getfont(), $this->createrandom());
	}
			
	ImageGIF($im);
	return $im;
	}
	
}


$bild = new captcha();
echo $bild->create_image();
	
	//Readin Default Settings

	
	$_SESSION['ragersCaptcha']=$bild->buffer("",1);	
	?>
Return current item: ZompLog