I got this simple captcha script from online. I like it, and I edited it to suit my site, but was wondering if someone could edit it to add some random lines on the captcha itself as it is somewhat too simple.
I did find tutorials on how to do it but it was not working for me in.
Here is the simple captcha script; I would love to modify it to have some random lines appear on the captcha.
$width = 150;
$height = 24;
$length = 5;
$font = 'caviardreams.ttf';
$font_size = 14;
$bg_color = array(245, 245, 245);
$chars = 'ABCDEFGHKMNPQRSTUVWXYZ23456789';
session_start();
//putenv('GDFONTPATH=' . realpath('.'));
$img = imagecreatetruecolor($width, $height);
$bkgr = imagecolorallocate($img, $bg_color[0], $bg_color[1], $bg_color[2]);
imagefilledrectangle($img, 0, 0, $width, $height, $bkgr);
$code = '';
for($i = 0; $i < $length; $i++)
{
$code .= $chr = $chars[mt_rand(0, strlen($chars)-1)];
$r = rand(0, 192);
$g = rand(0, 192);
$b = rand(0, 192);
$color = imagecolorallocate($img, $r, $g, $b);
$rotation = rand(-35, 35);
$x = 5+$i*(4/3*$font_size+2);
$y = rand(4/3*$font_size, $height-(4/3*$font_size)/2);
imagettftext($img, $font_size, $rotation, $x, $y, $color, $font, $chr);
}
$_SESSION['random_txt'] = md5($code);
header("Content-type: image/png");
header("Expires: Mon, 01 Jul 1998 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
imagepng($img);
imagedestroy($img);