<?php 
session_start(); 

$ranStr = md5(microtime()); 

$ranStr = substr($ranStr, 0, 6); 



$_SESSION['cap_code'] = $ranStr; 


$rgb[0] = 00;
$rgb[1] = 00;
$rgb[2] = 00;

$newImage = imagecreatefrompng("captcha.png");
$txtColor = imagecolorallocate($newImage, $rgb[0], $rgb[1], $rgb[2]); 
$imageInfo = getimagesize("captcha.png");


$linesToDraw = 0;

for( $i = 0; $i < $linesToDraw; $i++ ) {

$xStart = mt_rand( 0, $imageInfo[ 0 ] );
$xEnd = mt_rand( 0, $imageInfo[ 0 ] );

imageline( $newImage, $xStart, 0, $xEnd, $imageInfo[1], $txtColor );
}

header( "Content-type: image/png" ); 

putenv('GDFONTPATH=' . realpath('.'));
$fuente = 'arial.ttf';
$angulo=rand(-10, 10);

/*imagettftext($newImage, 20, $angulo, 30, 35, $txtColor, $fuente, $ranStr);*/
imagestring($newImage, 5, 15, 15, $ranStr, $txtColor);

imagepng($newImage); 

?>