Stop Spam Emails
Chompy Chompy Chompy
Lifelock Promotion Code TurboTax Promotion Code
Home About Photos Contact Non-Guilt Links Sitemap
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.

Random Picture...
Warning: imagecreatefromjpeg(photos/20070801//52.jpg): 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: imagecopyresized(): supplied argument is not a valid Image resource in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 13

Warning: imagejpeg(): Unable to open 'photos/20070801/thumbs/52.jpg' for writing in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 15

(Ok seriously, these are real ghosts Gingerbread-m...)

Time Machine: 05-11-2007 · 05-11-2006 · 05-11-2005 · 05-11-2004 I took the day off blogging but only because I was thinking of you.05-11-2006: I ditched karate last night even though there's an upcoming belt test because of a severe stomach ache. While I did have BW3's for lunch I didn't go hog-wild and deserve to have what felt like a full Keep Reading... 05-11-2005: Today was one of those days. Even though I got a solid seven hours of sleep last night and took a nap this afternoon I'm still tired. The molto-enormo-latte from Starbucks that I just drank didn't h Keep Reading...05-11-2004: How dare the Cubs play so badly? I mean seriously, it was ok to suck before this year because you didn't have more than two good players but now? Your payroll is something around $90,000,000. I fel Keep Reading...