Jump to content

Captcha font


Zaper Gallis

Recommended Posts

Ok, I'm writing a captcha script for my site and i have it working and doing most of what i want. Here's what i have:

<?php session_start(); 	//imagecreatefrompng :: create a new image from file or URL	$img = rand(1, 4);		if ($img == 1)	{		$img = imagecreatefrompng('captchaimage1.png');	}	else if ($img == 2)	{		$img = imagecreatefrompng('captchaimage2.png');	}	else if ($img == 3)	{		$img = imagecreatefrompng('captchaimage3.png');	}	else if ($img == 4)	{		$img = imagecreatefrompng('captchaimage4.png');	}		//displaying the random text on the captcha 	$word1 = rand(1, 10);	if ( $word1 == 1)	{		$word1 = "The" . rand(1, 9) . "rn" . rand(1, 9);	}	if ( $word1 == 2)	{		$word1 = "Sh" . rand(1, 9) . "uth" . rand(1, 9);	}	if ( $word1 == 3)	{		$word1 = "Puta" . rand(1, 9) . "h" . rand(1, 9);	}	if ( $word1 == 4)	{		$word1 = "r" . rand(1, 9) . "ies" . rand(1, 9);	}	if ( $word1 == 5)	{		$word1 = "ri" . rand(1, 9) . "tys" . rand(1, 9);	}	if ( $word1 == 6)	{		$word1 = "cro" . rand(1, 9) . "wle" . rand(1, 9);	}	if ( $word1 == 7)	{		$word1 = "ri" . rand(1, 9) . "tys" . rand(1, 9);	}	if ( $word1 == 8)	{		$word1 = "g" . rand(1, 9) . "res" . rand(1, 9);	}	if ( $word1 == 9)	{		$word1 = "si" . rand(1, 9) . "ons" . rand(1, 9);	}	if ( $word1 == 10)	{		$word1 = "hi" . rand(1, 9) . "zing" . rand(1, 9);	}		$word2 = rand(1, 10);	if ( $word2 == 1)	{		$word2 = "The" . rand(1, 9) . "rn" . rand(1, 9);	}	if ( $word2 == 2)	{		$word2 = "Sh" . rand(1, 9) . "uth" . rand(1, 9);	}	if ( $word2 == 3)	{		$word2 = "Puta" . rand(1, 9) . "h" . rand(1, 9);	}	if ( $word2 == 4)	{		$word2 = "r" . rand(1, 9) . "ies" . rand(1, 9);	}	if ( $word2 == 5)	{		$word2 = "ri" . rand(1, 9) . "tys" . rand(1, 9);	}	if ( $word2 == 6)	{		$word2 = "cro" . rand(1, 9) . "wle" . rand(1, 9);	}	if ( $word2 == 7)	{		$word2 = "ri" . rand(1, 9) . "tys" . rand(1, 9);	}	if ( $word2 == 8)	{		$word2 = "g" . rand(1, 9) . "res" . rand(1, 9);	}	if ( $word2 == 9)	{		$word2 = "si" . rand(1, 9) . "ons" . rand(1, 9);	}	if ( $word2 == 10)	{		$word2 = "hi" . rand(1, 9) . "zing" . rand(1, 9);	}		$key = $word1 . " " . $word2;		$_SESSION['check'] = ($key);		//The function imagecolorallocate creates a color using RGB (red,green,blue) format.	$textcolor = imagecolorallocate($img, rand(0, 199), 0, 0);	$line = imagecolorallocate($img,0,0,0);	$lineselect1= rand(1, 2);	$lineselect2= rand(1, 2);	$lineselect3= rand(1, 2);	$lineselect3= rand(1, 2);		if ($lineselect1== 1)	{	imageline($img,rand(0, 200),0,rand(10, 200),75,$line);	}	else	{	imageline($img,0,rand(0, 200),255,rand(10, 200),$line);	}	if ($lineselect2== 1)	{	imageline($img,rand(0, 200),0,rand(10, 200),75,$line);	}	else	{	imageline($img,0,rand(10, 255),255,rand(10, 200),$line);	}	if ($lineselect3== 1)	{	imageline($img,rand(0, 200),0,rand(10, 200),75,$line);	}	else	{	imageline($img,0,rand(10, 255),255,rand(10, 200),$line);	}	if ($lineselect4== 1)	{	imageline($img,rand(0, 200),0,rand(10, 200),75,$line);	}	else	{	imageline($img,0,rand(10, 255),255,rand(10, 200),$line);	}		imagestring($img, 10, 8, 3, $key, $textcolor);	header ("Content-type: image/png"); imagepng($img); ?>

And a live demo is on my site at: http://www.webmasterseverything.com/test/What i need now is to make the text bigger and easier for humans to read (a must), and I'd like to be able distort the text like most captcha's (Not so important right now). I can't find anything on Google for this that doesn't expect me to be using a pre-programed system. Can some one explain how to do this, or give me a link explaining it?And one final thing, I heard of some kind of something called "TTF font", but can't find a clear explanation of what it is or how to use it in a captcha. does any one have a good explanation of it?Thanks for the help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...