PDA

View Full Version : Image Verification form




janitorC7
Apr 3, 2007, 02:32 PM
This page has been spamed. I need to add an Image verification form to this. any ideas of how I would do this.

http://kidneysocal.org/brochure.html



ChicoWeb
Apr 3, 2007, 04:26 PM
Thats one hell of a form. I would also put some required fields on that thing!!

rogersmj
Apr 3, 2007, 04:39 PM
This page has been spamed. I need to add an Image verification form to this. any ideas of how I would do this.

http://kidneysocal.org/brochure.html

What you're looking for is known as a "captcha". Search for captcha libraries/plugins/classes that are compatible with whatever language you're using for your site.

Nicolasdec
Apr 3, 2007, 05:07 PM
How many Spam messages have you got???

janitorC7
Apr 3, 2007, 06:30 PM
How many Spam messages have you got???

ummm, wow.. a lot, proably arround 200 in the last week...

thanks guys

Nicolasdec
Apr 3, 2007, 06:41 PM
ummm, wow.. a lot, proably arround 200 in the last week...

thanks guys

WOW, are they most spambots?

janitorC7
Apr 3, 2007, 06:57 PM
WOW, are they most spambots?

I think they all are

jackbenimble4
Apr 4, 2007, 10:52 PM
I know I have a more advanced version of this script somewhere but can't find it so here's a more primitive one I built. You can save this as a php file, and then link to the php file as an image like <img src="thephpfile.php" />. It uses the GD Library to create an image with random characters of random colors. I used to have alternating backgrounds, as well as titled letters. This should probably help your problem somewhat though. Anyways, this script also sets a session variable 'imageVeriChars' to a hash of the letters that were on the image. That way when they submit the form, you can apply the md5 function to what they entered and compare it to what's in $_SESSION['imageVeriChars'].

Oh and './images/verificationimgbg.png' needs to be replaced with the path to a background .png image.

It'll take some fiddling to get to work, but it might be of some help to you.


<?php

$width = 80;
$height = 40;
$image = ImageCreate($width,$height);
$color = ImageColorAllocate($image,41,41,41);


srand((double)microtime()*1000000);

$string = md5(rand(0,9999));

$string = substr($string,17,5);

$bg = imagecreatefrompng("./images/verificationimgbg.png");

imagesettile($image, $bg);

ImageFilledRectangle($image,0,0,$width, $height,IMG_COLOR_TILED);

$textcolor = ImageColorAllocate($image,153,153,153);

$xposition = rand(1,32);

$yposition = rand(1,19);

if(!$string) {
die("String contained no value.");
}

ImageString($image, 8, $xposition, $yposition, $string, $textcolor);

session_start();



$_SESSION['imageVeriChars'] = md5($string);

if(!$_SESSION['imageVeriChars']) {
die("Session not set.");
}




// send the image
header("content-type: image/png");
ImagePNG($image);
ImageDestroy($image);

?>


Note: This hasn't been tested it since I found it buried deep in my machine and I'm not sure how well if at all it'll work.