Saw that I am not able to do it by myself I looked around for some captcha code.
I’ve this script:
[code]header(“Content-type: image/png”);
$x = 200;
$y = 75;
$code = substr($_GET[‘code’],0,9);
$space = $x / (strlen($code)+1);
$img = imagecreatetruecolor($x,$y);
$bg = imagecolorallocate($img,255,255,255);
$border = imagecolorallocate($img,0,0,0);
$colors[] = imagecolorallocate($img,128,64,192);
$colors[] = imagecolorallocate($img,192,64,128);
$colors[] = imagecolorallocate($img,108,192,64);
imagefilledrectangle($img,1,1,$x-2,$y-2,$bg);
imagerectangle($img,0,0,$x-1,$y-2,$border);
for ($i=0; $i< strlen ($code); $i++){
$color = $colors[$i % count($colors)];
imagettftext($img,28+rand(0,8),-20+rand(0,40),($i+0.3)*$space,50+rand(0,10),$color,’alba.ttf’,$code{$i});
}
for($i=0;$i<400;$i++)
{
$x1 = rand(3,$x-3);
$y1 = rand(3,$y-3);
$x2 = $x1-2-rand(0,8);
$y2 = $y1-2-rand(0,8);
imageline($img,$x1,$y1,$x2,$y2,$colors[rand(0,count($colors)-1)]);
}
imagepng($img);
I’m not sure to understand all of it but the problem is another one.
[code]imagettftext($img,28+rand(0,8),-20+rand(0,40),($i+0.3)*$space,50+rand(0,10),$color,’alba.ttf’,$code{$i});
Imagettftext does not print the distorted text.
Alba.ttf is correctly uploaded in the same directory of the script.
All this code produce [url=http://www.abelascimmia.org/test/prova/test.php]this[url=http://static.trackback.it/625X0/www/trackback/it/img/tb.png]like this
I’ve tried to pass a get variable but the function returns me an error, if I replace the $_GET code with a string it’s still not working.
The error is: The image “[url]http://www.abelascimmia.org/test/prova/test.php”
Can anybody help me?
Thanks