TeddyKiller Posted May 17, 2010 Share Posted May 17, 2010 I have a captcha image.. with noise and random lines. It simply the text gets displayed like.. AhD934 That's cluntched together. I want it more spacious: A h D 9 3 4 I would also like each letter to have a different height. I'm not sure how to do it. Here is my captcha generation.. <?php session_start(); header ("Content-type: image/png"); // String Length $length = 6; // Primary Numbers - 0 To 9 $primary = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'; // Reset strings $pri = ''; // Primary Number - 0 To 9 $charslength = strlen($primary); for ($i = 0; $i < $length; $i++) $pri .= substr($primary, rand(0, $charslength - 1), 1); // Width (px) $width = 150; // Height (px) $height = 30; // Background Image $img_handle = imageCreateFromPNG("../ima/captcha.png"); //Font color $color = imagecolorallocate($img_handle, 0, 0, 0); // Random lines $LineColor = imagecolorallocate($img_handle,172,172,172); for($i = 0; $i < 2; $i++) { $rand_x_1 = rand(0, $width - 1); $rand_x_2 = rand(0, $width - 1); $rand_y_1 = rand(0, $height - 1); $rand_y_2 = rand(0, $height - 1); imageline($img_handle, $rand_x_1, $rand_y_1, $rand_x_2, $rand_y_2, $LineColor); } // Noise $PixelColor = imagecolorallocate($img_handle,225,25,25); for ($c = 0; $c < 150; $c++){ $x = rand(0, $width - 1); $y = rand(0, $height - 1); imagesetpixel($img_handle, $x, $y, $PixelColor); } // Define the axis $x = rand(5,25); $y = rand(0,10); // Set the image string imagestring($img_handle, 5, $x, $y, $pri, $color); // The string put in a session for validation $_SESSION['ckey'] = $pri; // Turn into an image imagepng ($img_handle); // Destroy the image imagedestroy ($img_handle); ?> How would I do it? Thanks Quote Link to comment Share on other sites More sharing options...
BizLab Posted May 17, 2010 Share Posted May 17, 2010 You should actually leave them stuck together. It is more secure that way. If the letters are spaced out the text "readers" can see the letters more easily. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted May 17, 2010 Author Share Posted May 17, 2010 Thanks Hmm.. how would I change it so that maybe I can do a recaptcha method. Word1 Word2 with a space in the middle of course. It'd be a list of prefixes and suffixes I'd imagine? Though how would that work. Then problems with slightly different heights of the letters so it isn't just.. straight across. Quote Link to comment Share on other sites More sharing options...
BizLab Posted June 1, 2010 Share Posted June 1, 2010 i'm not sure what you mean by "recaptcha". Are you talking about refreshing the captcha? If so you will need to integrate javascript into the captcha system - i don't have any details on this for you though lol i'm assuming a jquery .load() function will do the trick, but it's rather sketchy to be modifying the captcha session variable with javascript... Quote Link to comment Share on other sites More sharing options...
aeroswat Posted June 1, 2010 Share Posted June 1, 2010 Thanks Hmm.. how would I change it so that maybe I can do a recaptcha method. Word1 Word2 with a space in the middle of course. It'd be a list of prefixes and suffixes I'd imagine? Though how would that work. Then problems with slightly different heights of the letters so it isn't just.. straight across. A recaptcha method would require AJAX my friend. In that case you should hit up the AJAX forums. Unless of course you want a manual refresh of the entire page which would be a bit more lengthy in order to keep previously entered values. In order to have a list of prefixes and suffixes you would have to have an array containing the values or a file to read from that contained the sets of each. Quote Link to comment Share on other sites More sharing options...
BizLab Posted June 1, 2010 Share Posted June 1, 2010 Thanks Hmm.. how would I change it so that maybe I can do a recaptcha method. Word1 Word2 with a space in the middle of course. It'd be a list of prefixes and suffixes I'd imagine? Though how would that work. Then problems with slightly different heights of the letters so it isn't just.. straight across. A recaptcha method would require AJAX my friend. In that case you should hit up the AJAX forums. Unless of course you want a manual refresh of the entire page which would be a bit more lengthy in order to keep previously entered values. In order to have a list of prefixes and suffixes you would have to have an array containing the values or a file to read from that contained the sets of each. don't be mistaken Teddy - the Jquery AJAX is much easier to use.. some of the javascript forums will shun the use of it, but it is much more flexible andmuuuuuuuch quicker to deploy.. ask about the security of the refreshed data Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.