4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Sebas Bonito on July 10, 2009, 02:07:11 PM
-
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.
(http://wiki.recaptcha.net/images/b/be/Rcptacleanxk9.png)
Step 1. Register at reCAPTCHA (http://recaptcha.net/). It's free and btw a nice project (http://recaptcha.net/learnmore.html).
Step 2. Click on "My Account" and then on "e-mail protection" to receive the api-keys (http://mailhide.recaptcha.net/apikey).
(You'll need the Public Key and the Private Key later)
Step 3. Download reCAPTCHA Library (http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest) and copy the recaptchalib.php to the includes-directory
Step 4.1 Open templates/.../member_profile.html
Search 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 (http://www.4homepages.de/forum/index.php?topic=22881.msg125037#msg125037)
-
Hi,
i tryed to use this but i receive multiple lines of this error,
the link is there and clickable a popup appears but the
captcha is never accepted even it's right for sure...
I used the latest recaptchalib.php
Any ideas ?
Greetz X23
-
Could you pls report these errors? Additional: How about the server-error-log?