<?php
header('Content-type: image/jpeg');
$font = 'ariblk.ttf';
$lineCount = 10;
$fontSize = 10;
$height = 25;
$width = 80;
$ih = imagecreate($width,$height) or die('GD Library must be installed.');
$bgColor = imagecolorallocate($ih,0,0,0);
$lineColor = imagecolorallocate($ih,178,238,238);
$txtColor = imagecolorallocate($ih,254,154,139);
$str = 'abcdefghijklmnopqrstuvwxyz0123456789';
for($x=0;$x<6;$x++){
$pos = rand(0,strlen($str));
$stri .= $str{$pos};
}
$stri = strtolower($stri);
$textbox = imagettfbbox($fontSize,0,$font,$stri) or die('Try replacing imagettfbox with imagettfbbox function on d left.');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($ih,$fontSize,0,$x,$y,$txtColor,$font,$stri);
for($x=0;$x<$lineCount;$x++){
$x1 = rand(0,$width); $x2= rand(0,$width); $y1 = rand(0,$width); $y2 = rand(0,$width);
imageline($ih,$x1,$y1,$x2,$y2,$lineColor);
}
imagejpeg($ih,NULL,75);
imagedestroy($ih);
session_start();
$_SESSION['captchaAuth'] = $stri;
?>