getting spurious character in captcha...
05-25-2010, 03:18 PM
|
getting spurious character in captcha...
|
Posts: 351
Name: Butch Begy
|
I have the following script for generating a captcha code and image, for the most part it works fine, but occasionally it generates a spurious character which appears as a square in image, can anybody figure out why, I can't...
Code:
<?php
$length = 8;
$characters = ‘0123456789abcdefghijklmnopqrstuvwxyz’;
$string = "";
$file = "../Images/Captcha/Captcha.png";
$font = "../Fonts/ariblk.ttf";
for ($i = 0; $i < $length; $i++)
{
$count = mt_rand(1, strlen($characters));
$string = $string.$characters[$count];
}
$im = imagecreatetruecolor(148, 60);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 148, 60, $grey);
imagettftext($im, 12, 0, 18, 32, $grey, $font, $string);
imagettftext($im, 12, 0, 16, 30, $black, $font, $string);
$emboss = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1));
imageconvolution($im, $emboss, 1, 127);
imagepng($im,$file);
imagedestroy($im);
echo (
$string
);
?>
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
|
|
|
|
05-25-2010, 03:22 PM
|
Re: getting spurious character in captcha...
|
Posts: 241
|
Have you tried a different font?
__________________
██ HostMantis Please login or register to view this content. Registration is FREE
██ Shared • Reseller • 24/7/365 Support • Instant Activation
██ CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
|
|
|
|
05-25-2010, 03:25 PM
|
Re: getting spurious character in captcha...
|
Posts: 351
Name: Butch Begy
|
No, but that is a pretty basic font, will try though.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
|
|
|
|
05-25-2010, 03:27 PM
|
Re: getting spurious character in captcha...
|
Posts: 241
|
Yeah, your current font is pretty standard, but I figured it was worth a try.
__________________
██ HostMantis Please login or register to view this content. Registration is FREE
██ Shared • Reseller • 24/7/365 Support • Instant Activation
██ CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
|
|
|
|
05-25-2010, 03:40 PM
|
Re: getting spurious character in captcha...
|
Posts: 351
Name: Butch Begy
|
h3g1�ovs Hey! you can see it! this is what I get, what is that fffd stuff? btw I did try different fonts, same result, this one is arial.ttf
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
|
|
|
|
05-25-2010, 03:43 PM
|
Re: getting spurious character in captcha...
|
Posts: 241
|
Can you provide a link to the page with the captcha?
__________________
██ HostMantis Please login or register to view this content. Registration is FREE
██ Shared • Reseller • 24/7/365 Support • Instant Activation
██ CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
|
|
|
|
05-25-2010, 03:55 PM
|
Re: getting spurious character in captcha...
|
Posts: 351
Name: Butch Begy
|
No, it is on localhost, I can send a zip...
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
|
|
|
|
05-26-2010, 03:29 AM
|
Re: getting spurious character in captcha...
|
Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
|
That question mark is related to char encoding.
|
|
|
|
05-27-2010, 08:15 AM
|
Re: getting spurious character in captcha...
|
Posts: 181
Name: David Jackson
|
just after your for loop add this
PHP Code:
$string = utf8_encode($string);
|
|
|
|
|
« Reply to getting spurious character in captcha...
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|