Spam protecting forms
Moderator: General Moderators
Spam protecting forms
Hey,
Is there anyway to use captcha images to protect forms without having FreeType Support on you webserver?
...or does anyone know how to just use a number instead of an image? have seen that kind too
Is there anyway to use captcha images to protect forms without having FreeType Support on you webserver?
...or does anyone know how to just use a number instead of an image? have seen that kind too
Re: Spam protecting forms
what do you mean by free type support. All you need if the gd library and you can copy a font from windows to your directory
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Spam protecting forms
If you can't do a captcha type thing yourself because no Freetype, outsource it. This one looked quite fun http://research.microsoft.com/asirra/
Re: Spam protecting forms
haha dont think I'll use that ^^ lol
what I mean is this... I ran a GD Support test on my webserver and it said Freetype was not supported.
I have asked around and tried like 10 different captcha codes and all of them have required FreeType Support.
Is there any way to use/make a captcha without the need FreeType Support?
I have no clue what it really is, but I figured it has to do something with creating images...
Otherwise I can do with just a number instead of an image, do someone know where to find a securitycode script like this?
what I mean is this... I ran a GD Support test on my webserver and it said Freetype was not supported.
I have asked around and tried like 10 different captcha codes and all of them have required FreeType Support.
Is there any way to use/make a captcha without the need FreeType Support?
I have no clue what it really is, but I figured it has to do something with creating images...
Otherwise I can do with just a number instead of an image, do someone know where to find a securitycode script like this?
Re: Spam protecting forms
Yes, it is posible,
GD has few buil-in fonts,
just use function imagestring, at try variations of second parametar.
GD has few buil-in fonts,
just use function imagestring, at try variations of second parametar.
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Spam protecting forms
Didn't you like the little doggies?
Try this - from the above post, it should work!
You can nick the background image from http://www.keepchickens.info/captcha.png
If not you could do a question and answer thing - have a database table with a bunch of questions humans can answer and md5 the answer as a hidden field or store it in the session
Try this - from the above post, it should work!
Code: Select all
<?php
session_start();
$captchaTextSize = 7;
do {
// Generate a random string and encrypt it with md5
$md5Hash = md5( microtime( ) * mktime( ) );
// Remove any hard to distinguish characters from our hash
preg_replace( '([1aeilou0])', "", $md5Hash );
} while( strlen( $md5Hash ) < $captchaTextSize );
// we need only 7 characters for this captcha
$ResultStr = substr( $md5Hash, 0, $captchaTextSize );
$NewImage =imagecreatefrompng("../images/captcha.png");//image create by existing image and as back ground
$LineColor = imagecolorallocate($NewImage,233,239,239);//line color
$TextColor = imagecolorallocate($NewImage, 15, 103, 103);//text color-white
imageline($NewImage,1,1,40,40,$LineColor);//create line 1 on image
imageline($NewImage,1,100,60,0,$LineColor);//create line 2 on image
imagestring($NewImage, 5, 10, 5, $ResultStr, $TextColor);// Draw a random string horizontally
$_SESSION['key'] = md5($ResultStr);// carry the data through session
header("Content-type: image/jpeg");// out out the image
imagejpeg($NewImage);//Output image to browser
?>
If not you could do a question and answer thing - have a database table with a bunch of questions humans can answer and md5 the answer as a hidden field or store it in the session
Re: Spam protecting forms
Thanks for the code!
Is there a way to control the quality of the output jpg file? Its kinda bad ftm
...also, how do you change the font and fontsize?
Is there a way to control the quality of the output jpg file? Its kinda bad ftm
...also, how do you change the font and fontsize?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Spam protecting forms
imgejpeg wrote:bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )
Code: Select all
imagejpeg($NewImage, null, 100);//Output image to browserRe: Spam protecting forms
much better now
thanks jcart
... and again, how do you change fontsize and font family?
... and again, how do you change fontsize and font family?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Spam protecting forms
The 2nd parameter of imagestring(), I believe.
Re: Spam protecting forms
hmm... maybe,
but what should I enter? Im not a php coder, except the really basic stuff... so I have no clue
but what should I enter? Im not a php coder, except the really basic stuff... so I have no clue
Re: Spam protecting forms
if you have a look at andym01480 's code, could someone tell me how I can use it in my form?
- How do I get the captcha to show where I want it and what should I name the input field for the captcha code?
- How do I make it send the form when you have filled in the correct code and how do I make it display an error message if you enter the wrong code?
- How do I get the captcha to show where I want it and what should I name the input field for the captcha code?
- How do I make it send the form when you have filled in the correct code and how do I make it display an error message if you enter the wrong code?