wtrevino

Topic: How to hide email addresses in description using Recaptcha Mailhide

NOTE: this tutorial was written using JB 1.7 but my guess is there shouldn't be any problem if you use it on 1.8.

Maybe you've come across with the same problem as I have: Users sometimes insist in writing email addresses in the job description, perhaps not trusting the online application feature. This poses a problem if you want to keep your site 100% spambot free.

One good way of hiding in-text email addresses from non-human eyes is to use reCAPTCHA Mailhide. This tool will help you protect any in-text email address by asking people to solve a reCAPTCHA before they can view it so instead of seeing this-> user@example.com you will see this->  u...@example.com  and once you click on the dotted part of the email address a popup with the captcha will appear, only if you solve it you will be able to see the email address.

First, you will have to get mailhide public and private keys here.

Once you get them open your /config.php file and immediately after this line (70):

Code:

    define('SIDEBAR_CITIES', 'cities');

You should put this (replacing with your mailhide pub and priv keys):

Code:

    define('MAILHIDE_PUBLIC_KEY', 'your public key goes here');
    define('MAILHIDE_PRIVATE_KEY', 'your private key goes here');

Then open your page_job.php file and after this lines (98):

Code:

    else
    {
        //$info['description'] = nl2br($info['description']);
        $info['description'] = str_replace(array("\r\n", "\r", "\n"), "<br />", $info['description']);
    }

add the following:

Code:

        preg_match_all('/([\w\d\.\-\_]+)@([\w\d\.\_\-]+)/mi', $info['description'], $emails);
                        
        foreach($emails[0] as $email){            
            $mailhide_email = recaptcha_mailhide_html (MAILHIDE_PUBLIC_KEY, MAILHIDE_PRIVATE_KEY, $email);
            $info['description'] = str_replace($email, $mailhide_email, $info['description']);
            
        }

And that's it! There's no need to modify anything on your template. You can hide the email address in different ways, make sure to check the API here.

Last edited by wtrevino (2009-09-20 05:10:12)

evertsemeijn

Re: How to hide email addresses in description using Recaptcha Mailhide

Not tried nor tested i, but I had been thinking of using it too! IIt Should make it to the next release. Very usefull!

Member of Jobberbase Development Team - Templates/Usability

:: Looking for a jobboard installation and/or custom design? ::

redjumpsuit

Re: How to hide email addresses in description using Recaptcha Mailhide

the simplest way to hide your emails from being harvested by bots is to use the obfuscator function on the smarty template engine

you can read it here:
http://www.smarty.net/manual/en/languag … mailto.php

Monetize your job board using a simple PayPal payment solution for jobberBase 1.9.1!

TeamProjectsOnly

Re: How to hide email addresses in description using Recaptcha Mailhide

Are there settings to totally disable an email from the posts?

navjotjsingh

Re: How to hide email addresses in description using Recaptcha Mailhide

This tutorial can be improved a bit for v1.8 though the original code also works in 1.7 but this improvement can help you to enable/disable MailCaptcha too. Here's how.

Find this in your config.php:

Code:
define('CAPTCHA_PRIVATE_KEY', $settings['captcha_private_key']);

Add this after it:

Code:

define('ENABLE_MCAPTCHA', $settings['enable_mcaptcha']);
define('MAILHIDE_PUBLIC_KEY', $settings['mcaptcha_public_key']);
define('MAILHIDE_PRIVATE_KEY', $settings['mcaptcha_private_key']);

Now make this change to your existing jobberbase database:

Code:

INSERT INTO `settings` (`id`, `category_id`, `name`, `title`, `description`, `data_type`, `input_type`, `input_options`, `validation`, `value`) VALUES
(40, 4, 'enable_mcaptcha', 'Enable MailCaptcha', 'Before enabling MailCaptcha, make sure to add your private and public key.', 'boolean', 'radiobutton', 'no|yes', NULL, '0'),
(41, 4, 'mcaptcha_public_key', 'MailCaptcha Public Key', 'You can register these keys for free at mailhide.recaptcha.net.', NULL, NULL, NULL, NULL, '12345_YOUR_PUBLIC_KEY'),
(42, 4, 'mcaptcha_private_key', 'MailCaptcha Private Key', 'You can register these keys for free at mailhide.recaptcha.net.', NULL, NULL, NULL, NULL, '12345_YOUR_PRIVATE_KEY');

There is small change required in page_job.php too.

Find this code in page_job.php:

Code:

else
    {
        //$info['description'] = nl2br($info['description']);
        $info['description'] = str_replace(array("\r\n", "\r", "\n"), "<br />", $info['description']);
    }

And after that insert:

Code:

if (ENABLE_MCAPTCHA)
{
   preg_match_all('/([\w\d\.\-\_]+)@([\w\d\.\_\-]+)/mi', $info['description'], $emails);
                        
        foreach($emails[0] as $email){            
            $mailhide_email = recaptcha_mailhide_html (MAILHIDE_PUBLIC_KEY, MAILHIDE_PRIVATE_KEY, $email);
            $info['description'] = str_replace($email, $mailhide_email, $info['description']);
            
        }
}

That's all. This will ensure, that you can enable/disable MailCaptcha from Admin Panel in v1.8 from Admin>>Settings>>Recaptcha Anti-Spam.

evertsemeijn

Re: How to hide email addresses in description using Recaptcha Mailhide

redjumpsuit wrote:

the simplest way to hide your emails from being harvested by bots is to use the obfuscator function on the smarty template engine

you can read it here:
http://www.smarty.net/manual/en/languag … mailto.php

That's handy when you want to show the e-mail address, but sometimes the mailaddress is typed in the description field. This tutorials seems to be the best solution (especially with navjots new addition).

Member of Jobberbase Development Team - Templates/Usability

:: Looking for a jobboard installation and/or custom design? ::

Coltrane36

Re: How to hide email addresses in description using Recaptcha Mailhide

Thanks Trevino and Navjot... Worked first time, no issues