This tiny snippet
keeps your users from spam regarding to your
e-mail address in the profile.
With reCaptcha the new e-mail address appears like
B...@rainbow.net instead of the whole Beautiful@rainbow.net.
You need to type 2 words to get the whole e-mail address.
Step 1. Register at
reCAPTCHA. It's free and btw a
nice project.
Step 2. Click on "My Account" and then on "e-mail protection" to receive the
api-keys.
(You'll need the
Public Key and the
Private Key later)
Step 3. Download
reCAPTCHA Library and copy the
recaptchalib.php to the
includes-directoryStep 4.1 Open templates/.../
member_profile.htmlSearch for:
<td class="row2">{if user_email}<a href="{user_mailform_link}">{user_email_save}</a>{endif user_email}</td>
Replace it with:
<td class="row2">{if user_email}
<?
require_once ("../../includes/recaptchalib.php");
$mailhide_pubkey = 'PublicKey';
$mailhide_privkey = 'PrivateKey';
echo recaptcha_mailhide_html ($mailhide_pubkey,$mailhide_privkey,"{user_email_save}");
?>
{endif user_email}</td>
And of course change
PublicKey and
PrivateKey (which you've already got from point 2) to your keys.
Step 4.2 Localisation (like the germany version)
Add (somewhere in the template):
<script>
var RecaptchaOptions = {
lang : 'de'
};
</script>
Change
de to your language: English=en, Dutch=nl, French=fr, Portuguese=pt, Russian=ru, Spanish=es, Turkish=tr
Step 5. Also be sure... that templates are allowed to
execute PHP code:
Open includes/
constants.php and search for...
define('EXEC_PHP_CODE', 1);
If this is "0" change it to "1".
Step 6. This
optional step allows you to change the way,
how the crypted e-mail address appears (normally e.g.
B...@rainbow.net). To change it to "e-mail address":
open includes/
recaptchalib.php and search for:
return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
"' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
Replace it with:
return "<a href='" . htmlentities ($url) . "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">e-mail address</a>";
That's all... You can do this, whereever an e-mail address appears:
<?
require_once ("../../includes/recaptchalib.php");
$mailhide_pubkey = 'PublicKey';
$mailhide_privkey = 'PrivateKey';
echo recaptcha_mailhide_html ($mailhide_pubkey,$mailhide_privkey,"{user_email_save}");
?>
Only be sure to have
- the right path for the recaptchalib.php
- the right keys, and
- the right variable (in this case
{user_email_save})
And by the way: Take also a look to the
new reCaptcha-Mod for your site. It's a nice alternative to the existing Captcha (for register, comments, uploads and postcards):
http://www.4homepages.de/forum/index.php?topic=22881.msg125037#msg125037