Ass - Anti-Spam System

This is a VERY SIMPLY SYSTEM to let you publishing your email,
on blogs and stuff like that, without the problem off spam bots.
SPAM BOTS can read ascii, unicode text; but they CAN'T READ IMAGES, but YOU CAN.

This script is just for email, if you don't insert a valid email,
ASS generate an image with the phrase "Invalid email".
If you pass your email directly, Ass will register it,
else if you pass the code obteined by registration you will get the image.

To use this system register your email, compiling the form below.
Copy the code returned, and for get the image use the follow url:
http://www.caggianolabs.net/ass/ass.php?string=your_code
in forums, blogs or whatever you want.
Consider that link as an image link.

EMail:
Color:
This is the code

<?php

    
//Anti-Spam System
    //Copyright (C) 2008 2009 Marco Caggiano
    /*
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.


        This script take an email in the form user@name.ext and generate an image.
        This is secure at 99% because spammer's bots cant interpret the text written in the image,
        they might do it, with some techniques, but its very difficult.
        Its the same mechanism as CAPTCHA, but its less annoying and speedfull,
        you dont have to do anything special: just call this script and take the image or the image URL.
    */

    //Database include: include your own
    //I use Query(), use your *own* query function
    
include ("../database.inc.php");

    isset(
$_GET["string"]) && !empty($_GET["string"]) || die("String parameter must be set and no empty");

    
$color 0;
    if(isset(
$_GET["c"]) && !empty($_GET["c"])) $color hexdec($_GET["c"]);

    
$b $color 0xFF;
    
$g = ($color & (0xFF << 8)) >> 8;
    
$r = ($color & (0xFF << 16)) >> 16;

    
$string htmlentities(escape($_GET["string"]));

    
$email "";

    if(!
preg_match("/.+\@\w+\.\w+/"$string)){

        
$result Query("SELECT email FROM ass WHERE id='$string' LIMIT 1");

        if(
countRows($result) <= 0){

            
$email "Invalid email";

        } else {

            
$row fetch($result);
            
$email $row['email'];

        }

    } else {

        
$code crc32($string);

        
$result Query("SELECT id FROM ass WHERE email='$string'");

        if(
countRows($result) > 0){

            die(
"The email has been already registered.<br />Its code is: <b>$code</b>.<br />Thanks, bye :).");

        }

        
Query("INSERT INTO ass(id, email) VALUES ('$code', '$string')");

        echo<<<EOT
        Your code is: <b>$code</b>.
        Use the follow link to get the image: http://www.caggianolabs.net/ass/ass.php?string=$code
        Example of usage:
        In forums: \[img\]http:\/\/www.caggianolabs.net/ass/ass.php?string=$code\[/img\]
        In HTML: <img src="http://www.caggianolabs.net/ass/ass.php?string=$code" />
EOT;

        exit;

    }

    
$width strlen($email) * 10;
    
$height 20;

    
$image imageCreate($width$height);

    
imageFill($image00imageColorAllocateAlpha($image0xFF0xFF0xFF0xFF));

    
imageString($image400$emailimageColorAllocate($image$r$g$b));

    
header("Content-Type: image/png");
    
imagePNG($image);

    
imageDestroy($image);

?>