Stop Spam Emails
Pet the dog
Lifelock Promotion Code
Red Zeppelin About Photos Sitemap | Brian Chris P-Chris Evil Mike Sam Amy Kathy
Everyone wants less spam. Sadly, to a certain extent is part of online life. As a webmaster there are certain things you can do to help prevent your site from receiving spam.

Below is the code I use on all my personal and professional sites that stops robots from spamming through my forms.

Where The Images Are Generated

<?php

//Good Letters
$letters =array(a,b,c,d,e,f,g,h,l,m,n,o,p,r,s,t,u,w,y,z);

//Bad Letters & Numbers
$numbers = array(1,2,3,4,5,6,7,8,9,q,j,x,i,v,k);

//Generate the length of the word
$count = rand(6,7);

//Create Word and convert it to uppercase for ease of reading
$text=$_GET['val'];
foreach ($numbers as $key) {
$text=str_replace("$key","","$text");
}

$text = strtoupper($text);

//Generate the unencrypted answer
$answer = trim(strtolower($text));

// Set the content-type
header("Content-type: image/png");

// Create the image
$im = imagecreatefrompng("bg.png");

// Create some colors
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

//A nice readable, yet rare font TTF font
$font = 'COREY_H.TTF';

// Add some shadow to the text
#imagettftext($im, 20, "0", 15, 30, $grey, $font, $text);

// Change Background semi-randomly
$b = rand(10,25);
$d=$b+1;
for ($i=1; $i<20; $i++){
imageline($im, $i*$b, 0, $i*$b, 250, $grey);
imageline($im, 0, $i*$d, 250, $i*$d, $grey);
}

// Add the text
imagettftext($im, 20, "0", 13, 28, $black, $font, $text);

// Actually put it on the screen
imagepng($im);
imagedestroy($im);

?>

In The Form

<?
$letters =array(a,b,c,d,e,f,g,h,l,m,n,o,p,r,s,t,u,w,y,z);
$numbers = array(1,2,3,4,5,6,7,8,9,q,j,x,k,v,i);
$goodtotal = rand(5,6);
$val = "";
for ($i=0;$i<$goodtotal;$i++) {
$tempgood = rand(0,19);
$val.="$letters[$tempgood]";
$tempbad = rand(0,10);
for ($j=0;$j<$tempbad;$j++) {
$randombadcharacter = rand(0,14);
$val.="$numbers[$randombadcharacter]";
}
}

?>

<img src="http://www.redzeppelin.org/php/antispam/antispam2.php?val=<? echo $val; ?>" />

<span class="red">*</span>Please enter the letters below to help us <a target="_blank" href="#" style="color:#333333; text-decoration:none;">stop spam</a> emails.<br />
<input type="text" name="capture"><br /><br />
<input type="submit" name="submit" value="Contact Us">

In The Form Handler

$attempt = $_POST['capture'];
$correct = $_POST['string'];
$correct = str_replace("k","","$correct");
$correct = str_replace("v","","$correct");
$correct = str_replace("q","","$correct");
$correct = str_replace("j","","$correct");
$correct = str_replace("i","","$correct");
$correct = str_replace("x","","$correct");
$correct = str_replace("0","","$correct");
$correct = str_replace("1","","$correct");
$correct = str_replace("2","","$correct");
$correct = str_replace("3","","$correct");
$correct = str_replace("4","","$correct");
$correct = str_replace("5","","$correct");
$correct = str_replace("6","","$correct");
$correct = str_replace("7","","$correct");
$correct = str_replace("8","","$correct");
$correct = str_replace("9","","$correct");
if ($attempt != $correct) {$error = 1;} else { mail("$to","$phone","$message","From: $email",); }

And there you have it. If you want to steal this stuff for your own sites--do it. No one likes spam.


Good Things Take Time... -518 days until FSU Football (2010)


Random Picture...
Warning: imagecreatefromjpeg(photos/20061120//12.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 5

Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 6

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 7

Warning: Division by zero in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 9

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 14

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'photos/20061120/thumbs/12.jpg' for writing in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 16

I thought for sure this skydiver was going to land on our boat but he narrowly missed us.


Time Machine: 02-05-2011 · 02-05-2010 · 02-05-2009 · 02-05-2008 I took the day off blogging but only because I was thinking of you.I took the day off blogging but only because I was thinking of you. 02-05-2009: Dear Mrs. Jones,

I wish to clarify that I am not now, nor have I ever been, an exotic dancer.

I work at Home Depot and I told my daughter how hectic it was last week before the blizzard hit. I told her we sold out every single shovel we had, and then I found one more in the back room, and that several people were fighting over who would get it. Her picture doesn't show me dancing around a pole. It's supposed to depict me selling the last snow shovel we had at Home Depot.

From now on I will remember to check her homework more thoroughly before she turns it in.

Sincerely,
Mrs. Smith
02-05-2008: Back in the good ol' days, before I knew anything about blogging or programming, I talked about my fish pretty regularly. The first fish I got was an Convict Cichlid that I cleverly named Al Capone. He got that name because I'd wake up in the morning and find his tankmates dead. Sadly, over the weekend, Al Capone finally got his own concrete shoes and put my official fish count at 0. RIP Al; you lived for four+ years and outlasted everyone else.