zubrag.com
Free php and cpanel scripts to automate your daily routine

Free PHP Scripts :: Anti Spam Image Generator

Anti-spam Image Generator will render PNG image with code to protect your blog/comments/feedback section from spammers and bots (known as CAPTCHA).

Requirements:
  • PHP 4.0.6
  • GD 2.0.1 or later
  • TTF font to use for rendering code. By default it uses arial.ttf. You can find it online.

Features:
  • You can define characters set to use (by default 0123456789)
  • Customizable code length (default is 6)
  • Easy to use / light server load, not overloaded with features

Sample usage:
  • Add this html code where you want to place antispam image: <img src="http://www.website.com/path/to/antispam.php">
  • Add field to the html form to enter code, name it anti_spam_code: <input name="anti_spam_code">
  • Add following check in the php code to check if user entered CAPTCHA correctly:
    @session_start(); // start session if not started yet
    if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) {
      // set antispam string to something random, in order to avoid reusing it once again
      $_SESSION['AntiSpamImage'] = rand(1,9999999);
    
      // here you add code to let user know incorrect code entered
      ...
    }
    else {
      // set antispam string to something random, in order to avoid reusing it once again
      $_SESSION['AntiSpamImage'] = rand(1,9999999);
    
      // everything is fine, proceed with processing feedback/comment/etc.
    
      ...
    }

Download Anti Spam Image Generator


Comments

webhost_africa April 13, 2007
Never seen anything like this on d web
admin [anti-spam] recoding.net April 15, 2007
For some reason i don't get anything come up? i changed it to .jpg and then i just get the location of the image displayed (if i go directly there) any help on this would be greatly appreciated

-Dan
Andre from Brazil April 21, 2007
great script .
a good example :
<?php
@session_start(); // start session if not started yet
if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) {
// set antispam string to something random, in order to avoid reusing it once again
$_SESSION['AntiSpamImage'] = rand(1,9999999);

echo "<script>alert('incorrect code')</script>";
echo "<script>history.go(-1)</script>";
}
else {
// set antispam string to something random, in order to avoid reusing it once again
$_SESSION['AntiSpamImage'] = rand(1,9999999);

include "includes/send_email.php";
}
?>
simkamsan [anti-spam] gmail.com September 20, 2007
Nice Scripts.
October 20, 2007
yo yoyo
fl-Ash November 26, 2007
font needs to be specified in the antispam.php for script to work, and font file specified to be copied on server. Really nice script still, thanks.
jacalyn [anti-spam] kal-design.co.uk November 27, 2007
Hi All.

I keep getting the error msg Cannot render TTF text. Can anyone shed any light please?
mrelnox [anti-spam] gmail.com November 29, 2007
if it stays blank check the following:

-) arial.ttf on the system?
-) define absolute system path to the font. ie.: $_SERVER['DOCUMENT_ROOT'].'/arial.ttf'
-) keep in mind that unix systems are case sensitive.. Arial.ttf != arial.ttf

thx btw itīs working perfect!
mail [anti-spam] andyreutimann.com December 13, 2007
I've implemented everything. The code image is placed as an image (<img src="./scripts/antispam.php">) but now the respective code will never be stored in the $_SESSION['AntiSpamImage'] variable... The session works, but the script seems not be able to save the value within the variable as soon as I implement the code image as a normal image... How can I solve this??
mail [anti-spam] upstairs.com December 13, 2007
I've found the solution. I just accidently deleted the "session_start" within the antispam.php...
Lee January 22, 2008
Still can't get the png to display - what is wrong with this script?!
mahesh2call [anti-spam] yahoo.com February 12, 2008
I can't get the image. i have used the code <img src="http://www.website.com/path/to/antispam.php"> to get the image. please suggest me the problem thru mail.
tes February 18, 2008
Image works great! Just don't know how to make validation work in a form, do you have a guide for it?

(Q) What code do I use for this?

// here you add code to let user know incorrect code entered

(Q) How about for this one?

// everything is fine, proceed with processing feedback/comment/etc.

Any clues? Sorry, I'm just clueless on this part
haris March 7, 2008
help me!!! why image blank when i upload to the server ...please answer
Don_O April 19, 2008
I had an issue getting this to work, but after a little searching, I found the problem. My server didn't support GD graphics. I guess this is not a standard install with lower versions of PHP. Two lines of code on the server and one line in my PHP.ini file and it is working. I found the below site that helped me through my GD issue.

http://www.boutell.com/gd/faq.html

This is a fantastic tool for getting rid of BOT porn URL submissions. I am super happy with it working. I have yet to fully deploy it, but it will be great! THANKS!!!
May 3, 2008
Really great script! Helped me a lot!
discretedeveloper [anti-spam] gmail.com May 11, 2008
The antispam works great on my pc while simulating it over apache.

however, I need help how come the antispam doesn't show up on my website after uploading it.

I already tried to change the output file from png to jpeg, I also looked at the server's versions of PHP and GD and all of this are updated. please help with this.

the address to the page with the antispam.php file is at:

http://discretedeveloper.com/subscribebymail.php

I am still trying to finish my site and this just holds me my progress.

if you may email me at my given address.

Thanx!

Robert John

Add Comment

!!! Comments posted here will not be answered. If you want to ask a question please post it on the forum.

E-mail or Name: Not required. Email will be protected from spammers

Comment: Please do not post unrelated comments

Anti-spam: Please enter (4f0ca597) into the box