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... 177 days until FSU Football (2010)


Random Picture...
Warning: imagecreatefromjpeg(photos/20070101//7.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: 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(): Unable to open 'photos/20070101/thumbs/7.jpg' for writing in /home/content/m/i/k/mikeandchompy/html/inc/sidebar.php on line 16

Chris and Kristen also wishing you a happy new year.


Time Machine: 03-11-2009 · 03-11-2008 · 03-11-2007 · 03-11-2006 03-11-2009: My house is going to be clean like you don't even know for the many Fests this month. I have about four laundry loads left and some dog-washing and vacuuming left to do but on the whole I'm in pretty good shape for Chris' arrival Friday evening.

I've got a good 12 of 12 in the works since I have a lot to do. I already missed my 10am meeting at Wachovia but whatever, it's my money and I call the shots. That's what you get for paying me like .000004% interest. I still need to pick up Abby from Jamie's before I do another load of laundry and then drive out to Reston.

PromotionCode.org is almost up to 100 fans on Facebook so if you're not already a fan, it would be nice of you to become one as a personal favor to me. It's rare that I mention anything work related so you should feel honored to be a part of today's entry.

There was big news on the FriendFront last night but I'm not sure if it has been disseminated fully enough for a mention. You know who you are, you just let me know.
03-11-2008: Jamie flew back into town yesterday afternoon from Jacksonville and I made it to Reagan in about 15 minutes. With Brian's map I can now do no wrong. After I picked her up we caught a bus (gasp) to Tenleytown where we had lunch then got on the metro (gasp) so she could get fingerprinted for her internship and I could get my SMARTcard. The woman fingerprinting her kept trying to resend a fax and must have done it fifty times while we were there. Getting my SMARTcard was pretty easy although I was hoping it would somehow be smart enough to repel the stench of the homeless on the bus from infiltrating my nose but no, it's just not that smart.

After having dinner in Georgetown we came back to my house and built my dining room table and about 95% of the kitchen pantry. Because it was so late I didn't want to do any hammering or else that would have gotten done too. With those items complete I'm down to only needing to build my new dresser and a bookshelf. Once THAT'S done then I can finally finish up my office and empty out four of the remaining tubs. Awesome.
03-11-2007: Ah, Poker Night. The four of us trotted over to Renee and Ian's around 6:30 to settle in to some poker. Ian made some sort of delicious chicken and mashed potato dish (how can you lose with that combination?) and Chris volunteered some of now-famous pepperoni bread. Ian was the star of the show, ending his string of 2nd place finishes and ruining the nights of everyone else. We stuck around to see if Renee could make a comeback against her boy toy but it was not to be. After leaving our $5 in Ian's wallet we adjourned home. Once there Chris and I broke out some red wine and Jamie and Mike(r) met up with Carlos for a night of dancing. Since Chris and I are old we fell asleep early and the rest of the part returned around 3am-ish.

Week 7
1) Ian (RG, MC, MR)
2) Renee (CE)
3) Mike (CP,JB)
4) Chris
5) Michael
6) Christen
7) Jamie


PCS Standings
1) Mike (2.28) [15 Kills]
T2) Ian (3.00) [6 Kills]
T2) Amy (3.00) [0 Kills]
4) Chris (3.14) [8 Kills]
5) Jamie (4.80) [4 Kills]
6) Christen (5.00) [2 Kills]
7) Renee (5.70) [2 Kill]
8) Tim (7.00) [0 Kills]
I took the day off blogging but only because I was thinking of you.