Web Hosting Talk







View Full Version : [HowTo] Create signature confirmation images [Captcha]


azizny
07-19-2006, 06:35 PM
This is my first topic here. I hope some might find of interest and maybe usefulness..

On one of my sites, I started getting a lot of spam (Med's type website) through my forums.

I then started to think why not add image captcha, which is explained on wikipedia: en.wikipedia.org/wiki/Captcha

I looked for sources and most scripts I found dealt with database storing of info, which I don't want to increase the already high load on my mysql engine.

I then rewrote the script to work without database, simply by passing the variable via POST encoded, thus staying with purpose.

Requirements for this script:
+++++++++++++++++++++

* Working GD Library + ImageTTFText.

Files we are going to use:
+++++++++++++++++++++

1) show_image.php -> Which will display an image of a text it receives via HTTP_GET after decoding it
2) contact_me.php -> the normal form you want to use the image with (demo)
3) functions.php -> has two functions we are going to use, if you change this filename, change the includes on both contact.php/show_image.php

Working the script:
+++++++++++++++++++++

1) On your HTML form (contact_me.php in this example) add:
- First we will generate a encoded code, lets say hid_num:
--a hidden input called hide_num,that has the value of hid_num
--an img src which has the value for show_image.php?code=hid_num

2) We will send this code to show_image.php via HTTP and then decode it in show_image.php and display it as an image. This requires the use of a font, in our case our font name is "COOPBLA.TTF" -> Insure legalities before using the font, can be changes on show_image.php settings.

3) When we submit the forum we will decode POST hid_num and compare it with what the user entered, if ok pass, else we will reload the post with a different image and value and error message.

The complete script is attached, use by running contact_me.php.

Any questions feel free to ask.

Download script from: http://www.megaupload.com/?d=IP642DRI

Peace,

JimBob45506
07-22-2006, 07:49 AM
I just downloaded the files. Nice work! Thanks. :)

BostonGuru
07-31-2006, 11:24 PM
Great script for those who want to conserve their CPU for necessary SQL queries only.

I am very paranoid about security so I found a way to create a dynamic encryption key which changes each time the page is run.

1. copy the contents of the functions.php into the top of your contact_me.php, then delete the functions.php file.
2. Copy the contents of show_image.php into contact_me.php below the functions.php contents, but above the origional contact_me.php contents. For whatever reason you will get odd header errors if you put it at the bottom.
3. Enclose the show_image.php contents like this:
if($page=="image")
{
show_image.php contents
}
4. Place the following just about the if brackets you just created.

$_GET['page];
$microTime = mktime();


5. Enclose the origional contact_us.php within else brackets.
6. Located towards the bottom of the origional contact_me.php code change show_image.php?code=$image_link to index.php?page=image&code=$image_link.
7. Last you want to make sure that you removed the lines from the show_image.php and origional contact_me.php contents that calls the function.php file, because that code is now within the same file, and calling the functions.php will only cause problems.

Now you can set your keyfile to something like


$keyfile = md5($microTime.x93kjs8);


This will cause your encryption key to change each time the page is loaded.

TheAnz
09-06-2006, 04:59 AM
hello, can have the download link again, that one not valid, if can repidshare link please, thx

brutetal
11-14-2006, 04:13 AM
Could you reupload the file please? I would like to try this out.