I changed the captcha code for a more complete version that I used in my old script.
In this version you have control over the amount of characters you want to display your username when you register it on the site.
You can also control the background color.
Below is the source code.
You should put it in config / captcha.php
Ok good job to all
Original Code
/*
//----------------------- Original Code ----------------------------------------------------
defined('_VALID') or die('Restricted Access!');
return array(
'driver' => 'image',
'level' => 'easy',
'words' => 'random',
'width' => 170,
'height' => 50,
'recaptcha_public_key' => '',
'recaptcha_private_key' => '',
'fonts' => array('Vera.ttf', 'Custom.ttf', 'arialbi.ttf')
);
//----------------------- end code ----------------------------------------------------
*/
//---------------------------------New code-------------------------------------------
session_start();
$possible_chars="23456789QWERTYUPADFGHJLXCVBNM"; //define your characters here
$code="";
$i=0;
//set the captcha length - change 8 to other value
while($i<8) {
$char=substr($possible_chars,mt_rand(0,strlen($possible_chars)-1),1);
if (!strstr($code,$char)) {
$code.=$char;
$i++;
}
}
$_SESSION["captcha_code"]=$code;
$width="80"; //width
$height="25"; //height
$image=imagecreate($width,$height);
$bg=imagecolorallocate($image,0,0,0); //background color
$text=imagecolorallocate($image,255,255,255); //text color
$line=imagecolorallocate($image,0,0,0); //fuziness
for($i=0;$i<($height*$width)/2;$i++) imagefilledellipse($image,mt_rand(0,$height),mt_rand(0,$width),1,1,$line);
for($i=0;$i<($height*$width)/150;$i++) imageline($image,mt_rand(0,$height),mt_rand(0,$width),mt_rand(0,$height),mt_rand(0,$width),$line);
imagestring($image,5,4,5,$code,$text);
header("Content-type: image/png");
imagepng($image);
//---------------------------------End code-------------------------------------------
'level' => 'medium',
with:
'level' => 'easy',
Let me know if that helps.
]]>