Author Topic: [MOD] reCAPTCHA for e-mail address (...no spam anylonger)  (Read 5884 times)

0 Members and 1 Guest are viewing this topic.

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
[MOD] reCAPTCHA for e-mail address (...no spam anylonger)
« 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.




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-directory

Step 4.1 Open templates/.../member_profile.html
Search for:
Code: [Select]
<td class="row2">{if user_email}<a href="{user_mailform_link}">{user_email_save}</a>{endif user_email}</td>Replace it with:
Code: [Select]
<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):
Code: [Select]
<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...
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
<?
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
« Last Edit: July 10, 2009, 02:42:44 PM by Schnick und Schnack »

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Re: [MOD] reCAPTCHA for e-mail address (...no spam anylonger)
« Reply #1 on: November 17, 2010, 02:39:10 PM »
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

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: [MOD] reCAPTCHA for e-mail address (...no spam anylonger)
« Reply #2 on: December 01, 2010, 09:58:03 AM »
Could you pls report these errors? Additional: How about the server-error-log?

 

Post your comments here