/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] always captcha

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 &#37; 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);[/code]

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});[/code]

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] to me and it should appear [url=http://static.trackback.it/625X0/www/trackback/it/img/tb.png]like this[/url]

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 &#8220;[url]http://www.abelascimmia.org/test/prova/test.php&#8221;[/url] cannot be displayed, because it contains errors.
Can anybody help me?

Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeMar 26.2012 — I'm a fan of SecurImage. Just drop it in, customize the look how you like, and go.
Copy linkTweet thisAlerts:
@AbeWayerauthorMar 27.2012 — I'm going to try it!

Thank you very much ?
×

Success!

Help @AbeWayer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...