Dumb question:
I just switched servers. I've got captchas working with Spam Protector 1.68. Here's the deal: My entire site is in grayscale. On the legacy server, I had converted the captchas .png to grayscale. Checked and indeed, those same .pngs are in the plugin folder. BUT on the site, they now render in color.
?
Modern miracle? Should I call a priest?
Brian
Captchas Rendering Spam Protector 1.68
-
bdconnolly
- Regular
- Posts: 140
- Joined: Tue Apr 04, 2006 9:37 pm
More likely you need to call a programmer.
I don't know when it happened, but Spam Protector uses GD fonts to render the CAPTCHA. If the functions 'imagettftext' and 'imagejpeg' both exist, then GD will be used (line 711 of version 1.70, from the nightlies).
If GD is used, then the fonts are used and randomly colored.
You could modify the code to fix the problem: right after the "if" statement that checks for GD, copy the lines from the "else". That'll set the CAPTCHA length and tell it to use the .png files instead of the GD image rendering.
I don't know when it happened, but Spam Protector uses GD fonts to render the CAPTCHA. If the functions 'imagettftext' and 'imagejpeg' both exist, then GD will be used (line 711 of version 1.70, from the nightlies).
If GD is used, then the fonts are used and randomly colored.
You could modify the code to fix the problem: right after the "if" statement that checks for GD, copy the lines from the "else". That'll set the CAPTCHA length and tell it to use the .png files instead of the GD image rendering.
-
bdconnolly
- Regular
- Posts: 140
- Joined: Tue Apr 04, 2006 9:37 pm
No problem.
I'm using serendipity_event_spamblock 1.70, which you can obtain from the latest nightlies. Unarchive it and upload the files except your grayscale PNG files to the Serendipity plugins/serendipity_event_spamblock/ directory.
Edit serendipity_event_spamblock.php. On line 711, you should see:
Immediately afterward, on line 719, insert this code:
Your site should now use the PNG files to render the letters (on line 1181, the if will fail; instead the else on line 1234 will run, loading the captcha_char.png files).
Oh, crap. I just found out why it didn't work.
Go to line 654 of your already-modified file. There you'll see:
You see it's checking again, resetting the change we just made. Change the if to simply:
If these changes don't help, let me know what's going wrong and I'll help figure it out.
I'm using serendipity_event_spamblock 1.70, which you can obtain from the latest nightlies. Unarchive it and upload the files except your grayscale PNG files to the Serendipity plugins/serendipity_event_spamblock/ directory.
Edit serendipity_event_spamblock.php. On line 711, you should see:
Code: Select all
if (function_exists('imagettftext') && function_exists('imagejpeg')) {
$max_char = 5;
$min_char = 3;
$use_gd = true;
} else {
$max_char = $min_char = 5;
$use_gd = false;
}
Code: Select all
$max_char = $min_char = 5;
$use_gd = false;
Oh, crap. I just found out why it didn't work.
Go to line 654 of your already-modified file. There you'll see:
Code: Select all
if ($use_gd || (function_exists('imagettftext') && function_exists('imagejpeg'))) {
$max_char = 5;
$min_char = 3;
$use_gd = true;
} else {
$max_char = $min_char = 5;
$use_gd = false;
}
Code: Select all
if ($use_gd) {
You can also get GD to render in grayscale. Just find all the calls to imagecolorallocate(). They take four arguments: an image and R, G, and B components.
Make sure that the R, G, and B always match. Something like:
Make sure that the R, G, and B always match. Something like:
Code: Select all
$gs = mt_rand(50,235);
$color = imagecolorallocate($image, $gs, $gs, $gs);
-
bdconnolly
- Regular
- Posts: 140
- Joined: Tue Apr 04, 2006 9:37 pm