PHP - Animated Captcha

Spacemail by SpaceshipSpacemail by Spaceship
Watch

xrvel

i love automationVIP Member
Impact
165
Hi, i want to share my animated captcha script.
Maybe you want to use it in your website or such :)

Image demo :





Download link :
http://dy.xrvel.googlepages.com/animatedcaptcha.zip

Last modified : November, 18th, 2008.


Improve your captcha ! :)
Code:
[list]
[*]Create more background images with image editor to improve your background combination.

[*]Use more TTF fonts to improve your font combination.

[*]Use various text color.
[/list]

History :
Code:
Version 1,4,1
[list]
[*]new property "regenerate_session_id" (boolean) (PHP 4 >= 4.3.2, PHP 5).
  if true, session id is regenerated when a user enters invalid guess.
  I believe this slightly improves the captcha defense against automation / bot.
  Please check "animatedcaptcha_example.php" for detail.
  But warning, all related data in $_SESSION are destroyed too.
[*]More fonts are included.
[*]More and larger background images.
[*]Random alphabets are used as character set (a-z). The previous one used (a-f and 0-9)
[*]Random string length on captcha generator file.
[*]Some code change.
[/list]

Version 1,3,2
[list]
[*]More distortion option.
[*]Only the letters and grids are distorted.
The background is not distorted.
[*]More fix.
[/list]

Version 1,3,1
[list]
[*]Add background from GIF file to the captcha. (the old one used plain background).
[*]Add some distortion in the letters.
[*]Grid numbers are reduced.
[*]Please check your old captcha file ([SIZE=1]"animatedcaptcha_generate.php" in the example[/SIZE]), and replace it with the new one.
[*]Recommended frame number is 2 now. (size +- 7-8 kb)
[/list]
 
Last edited:
9
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Nice script, if I create something that requires a CAPTCHA, I'll be sure to use it :)
 
0
•••
Perfect. I've been meaning to put a captcha onto my contact form, but i just got around to it. all the captchas i found were too much of a pain to install, this was perfect.

Rep'd!
 
0
•••
Nice. Thank you for using this :)
 
0
•••
Yummy Update

I have updated the script with these changes : :)
  • new property "regenerate_session_id" (boolean) (PHP 4 >= 4.3.2, PHP 5).
    if true, session id is regenerated when a user enters invalid guess.
    I believe this slightly improves the captcha defense against automation / bot.
    Please check "animatedcaptcha_example.php" for detail.
    But warning, all related data in $_SESSION are destroyed too.
  • More fonts are included.
  • More and larger background images.
  • Random alphabets are used as character set (a-z). The previous one used (a-f and 0-9)
  • Random string length on captcha generator file.
  • Some code change.
 
0
•••
HI

How does one add this to a script to protect it from spam...

Do you have instructions..

Tom
 
0
•••
ezimedia said:
HI

How does one add this to a script to protect it from spam...

Do you have instructions..

Tom
Hi,

For example in e-mail registration (such as Yahoo mail) usually we must enter image verification. If we do not enter the correct image text, the registration fails.
You can use this to protect your registration page / login page / comment page.
But you need to modify your old PHP script.
I have put an example in the download link.

For example you want to add captcha to your login page.

This is your old "login.php"
PHP:
<?php
$username = $_POST['username'];
$password = $_POST['password'];

if ($username == '' || $password == '') {
   header('Location: login-form.php?error=empty')
   exit();
} else {
   // connect to database, etc
}

?>

You can modify it into this
PHP:
<?php
session_start();// required

$username = $_POST['username'];
$password = $_POST['password'];

// Read the user's input
$captcha = $_POST['captcha'];

// Load the captcha class
require_once(dirname(__FILE__).'/animatedcaptcha.class.php');

// Create captcha object
$img = new animated_captcha();
$img->session_name = 'my_turing_test';
$img->magic_words('i am cool');

// Regenerate session id on invalid guess
$img->regenerate_session_id(true);

$valid = $img->validate($user_guess);// validate user's input

if (!$valid) {
   header('Location: login-form.php?error=captcha')
   exit();
} else if ($username == '' || $password == '') {
   header('Location: login-form.php?error=empty')
   exit();
} else {
   // connect to database, etc
}

?>

Kurniawan.
 
Last edited:
1
•••
thanks, it's look better...
:blink: :wave: :wave:
 
0
•••
Nice, but your images took about a minute to load for me, I am on 3.5 Mb/s connection.
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back