![]() | Welcome to Islandnet.com Locally owned and operated since 1993 |
| Create an Account • Pricing & Features • Domain Registration • Customer Sites • Help & Info | |
Saturday November 21 2009 | |
Captcha CodesReturn to the web gadgets pageA "captcha" code (an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") is a mechanism that helps to ensure that it is a human that is accessing your web gadget instead of an automated system of some sort. This greatly enhances security and reduces the likelihood of abuse. For example, using a captcha code on a guestbook form can help to eliminate "spam" from automated scripts. Captcha tests come in many forms, but the most common is a small graphic image that contains a randomly generated code word or number. A human can easily read and enter the code as part of the form submission, while a computer program cannot. If the code entered does not match the one displayed then the form submission is rejected. Typically the code in the graphic is made harder for a computer to "read" by using random colors, fonts, backgrounds, etc. Each web gadget will have its own way of specifying that a captcha code should be used, but the configuration of the captcha code itself is the same across all web gadgets. The configuration file for a web gadget that uses a captcha code will contain a section that looks like this:
As with all configuration options, the captcha settings are specified as part of the $CONFIG[] array of values. All of the captcha settings are optional and have default values.
These settings specify the hostname, username, password, and database to use for tracking captcha codes (the exact values will be different than shown above of course). These are not captcha-specific settings as each web gadget may use the same database for other purposes as well. You do not need to create any tables in the database, the web gadget will create tables as necessary. You can use an existing MySQL database if you want, but we suggest creating a new one for all your web gadgets to share. You can create MySQL databases in our helpdesk under the "Databases" tab of the "My Account" page.
Audio Captcha CodesOf course the main problem with captcha codes is that they are designed to be somewhat tricky to read (you may be surprised how many out there can now be "read" by a computer program). This can be a problem, especially for the visually impaired. One solution is to provide an audio version of the captcha code.If you want an audio version of the code, you first need an audio file for each possible letter or number that can appear in your captcha codes. These must be WAV files, and they must all be the same in terms of bitrate and sample size and should be mono. If you need a nice set of audio files, you can download these ones. You will need to place these sound files somewhere in your account where the gadget you're using can access them. Once you have the audio files you want, you'll need to add some new settings to your config file:
Using Captcha CodesEach web gadget that supports captcha codes may be slightly different, but in general there are two things that need to be done to use a captcha code. First, a code must be generated and displayed. Second, the gadget needs to know which input value to check against the generated captcha code.To generate and display a captcha code you simply need to embed an IMG tag that calls the web gadget in captcha mode. For example, if the gadget in question happens to be "inmail.php", then you might embed an image in your form with this code:
<img src="inmail.php?captcha"> The web gadget sees the 'captcha' parameter and knows to generate a new captcha code and output it as an image. Sometimes the generated image is hard to read, so it's always a good idea to provide the user with a way of generating a new one. This is easily done by adding a little bit of Javascript code to the IMG tag like this:
<img src="inmail.php?captcha" onclick="this.src='inmail.php?captcha'+(new Date()).getTime();"> Now whenever the image is clicked, the image src is changed, which causes a new code to be generated and a new image to be displayed. The current date and time are added to the end to ensure that the image src changes each time, otherwise the browser would simply use the last cached image. One of the main problems with captcha codes is that they are often incompatible with folks who are visually impaired. For this reason our captcha code system also supports speech. That is, you can optionally add a button beside the captcha code that will speak the code out loud when the user clicks on it. To add a speech button you would add something like this to your form:
<span id="speech"></span>
<img src="listen.gif" onclick="document.getElementById('speech').innerHTML=
'<embed src=inmail.php?speak'+(new Date()).getTime() +'.wav
hidden=true autostart=true loop=false width=0 height=0>'"
alt="" title="Click to hear the code spoken">The second line is wrapped for readability. Here's what it does: it adds an empty HTML span named "speech", followed by an image (named "listen.gif" in this example, but you will need to supply your own image). When the image is clicked, the contents of the empty span are rewritten to include an embedded sound file (which is actually a link back to the web gadget itself with the "speak" parameter). The settings on the embedded sound file cause it to play automatically once it loads. Like the example for the image, we add the current date and time to prevent the browser from simply playing the old cached audio file. We also add ".wav" to this value for those browsers that depend on the file extension for determining how to play audio. To see both the image and audio captcha support in action, check out the inMail Demo.
|
| Home • About Us • Contact Us • Terms of Use • Privacy Policy • Help Documents |
| Page generation time: 0.01 seconds |
|
