This mod is usefull against auto-registrations, bots. It will display a picture with random code and visitor must type the code in the field.
As of v1.0 this mod works only with GD, no ImageMagick or NetPBM is supported. Also, GD must be compilled with TrueType library (you can check it in phpinfo())
--------[ Installation ]----------Step 1Download
this package.
Unzip it and upload all files to the root of your 4images installation and restore the following file-tree:
rndimg.php
fonts/comicbd.tff
bg/1.png
bg/2.png
bg/3.pngCHMOD 666 all files
Try to execute
rndimg.php by typing in your browser:
http://example.com/4images/rndimg.phpIf you see an image with code, then you can continue to the next step, otherwise its possible this mod will not work for you at all.
Step 2Open
register.phpFind:
else {
$msg .= (($msg != "") ? "<br />" : "").$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['email']), $lang['field_required']);
$error = 1;
}
Insert
below:
$code = $site_sess->get_session_var("rnd_code");
if (!$code || !isset($HTTP_POST_VARS['code']) || empty($HTTP_POST_VARS['code']))
{
$msg .= (($msg != "") ? "<br />" : "").$lang['rndimg_required'];
$error = 1;
}
elseif (strtoupper(trim($HTTP_POST_VARS['code'])) != $code)
{
$msg .= (($msg != "") ? "<br />" : "").$lang['rndimg_missmatch'];
$error = 1;
}
Step 2.1Find:
if ($error) {
Insert
below:
include(ROOT_PATH."rndimg.php");
$site_template->register_vars(array(
"lang_rndimg" => $lang['rndimg'],
"lang_rndimg_expl" => $lang['rndimg_expl'],
"rndimg_url" => $site_sess->url(ROOT_PATH."rndimg.php?".MD5(time()), "&")."&",
));
Step 3Open
lang/<your langauge>/main.phpAt the end,
above closing
?> insert:
$lang['rndimg'] = "Security code";
$lang['rndimg_expl'] = "Please type code from the image<br />Click the image to change it's background";
$lang['rndimg_required'] = "Security code is required";
$lang['rndimg_missmatch'] = "You have entered a wrong security code";
Step 4Open
templates/<your template>/register_form.htmlAdd
<tr>
<td class="row2"><b>{lang_rndimg}:</b><br /><img src="{rndimg_url}" onClick="this.src='{rndimg_url}'+((Math.round(Math.random()*(999-100)))+100);"></td>
<td class="row2 valign="top"><input type="text" name="code" size="5" value="" /><br /><span class="smalltext">{lang_rndimg_expl}</td>
</tr>
(design is your task
)
You can upload as many background images and fonts as you wish, no script changes required, the script will pick them randomly. The background images must be jpeg, gif or png type and should be bigger or equal then the WIDTH and HEIGHT settings that set in
rndimg.php.
Fonts must be .ttf type.
The default number of letters in the "code" is set to 5, you can change it in
rndimg.php in this line:
function get_code($num = 5, $safe = 1, $norepeat = 0)
when
$safe variable is set to true (1) the letters from this array:
$no = array("0","1","i","l","o","7"); //list of characters 0-9 and a-z to exclude from the list. lower case only!
will be filtered out from the "code", they will not be used. Set to false (0) if you dont want use the filter.
When
$norepeat is set to true (1) it will ensure that no the same letter/number will be generated more then ones. Default is allow duplicate letters/numbers.
There is also a little config that you can play with, which allow you to change size of the image, size of font, font color (shade of grey actualy)
If you would like integrate this mod into comments form, then you can follow
ch€ri{Bi}² instructions from this post:
http://www.4homepages.de/forum/index.php?topic=10200.msg68176#msg68176