phpFox reCAPTCHA Plug-in

This modification will replace the default phpFox Captcha found on the "sign up" and "contact us" form.

What is reCAPTCHA?

Quote:

A CAPTCHA is a program that can tell whether its user is a human or a computer. You've probably seen them — colorful images with distorted text at the bottom of Web registration forms. CAPTCHAs are used by many websites to prevent abuse from "bots," or automated programs usually written to generate spam. No computer program can read distorted text as well as humans can, so bots cannot navigate sites protected by CAPTCHAs.
Learn more about reCAPTCHA: http://recaptcha.net/learnmore.html

Live Demo: http://sandbox.phpfox.com/natio/signup/

:: Steps to Install ::

1) Sign up at ReCaptcha for a free account: http://recaptcha.net/whyrecaptcha.html

Once you have signed up make sure to add a site so you get your API keys which will be needed later when configuring the script.

2) Log into your phpFox Admin CP and navigate to:
Quote:

Options >> Edit Options >> Signup
Set the following option to "No":
Quote:

Turn on Image Verification on sign up
3) Download the ZIP attachment and Unzip to your computer.

4) Open the file "plugins/recaptcha/config.php.new" with your favorite text editor.

Look for:
PHP:
ADD_YOUR_PUBLIC_KEY_HERE 
Replace that with your Public Key that ReCaptcha provided you earlier in Step 1.

Next look for:
PHP:
ADD_YOUR_PRIVATE_KEY_HERE 
Replace that with your Private Key that ReCaptcha provided you earlier in Step 1.

Save and close the file.

5) Rename the file:
Quote:

plugins/recaptcha/config.php.new
to
Quote:

plugins/recaptcha/config.php
6) Upload the folder "plugins/" to your phpFox root directory.

7) On your server open the file: /design/templates/default/_modules/Account/Signup.html

Look for:
HTML:
{if $bIsProtImage}
<br />
<table style="width:100%;" cellpadding="4" class="border2">
Above that add:
HTML:
{if function_exists('recaptcha_get_html')}
        <table style="width:100%;" cellpadding="4" class="border2">
            <tr>
                <td style="width:35%; text-align:right; font-size:9pt; vertical-align:top;">{language text="verification_code"}:</td>
                <td style="font-size:9pt; vertical-align:top;">{php} echo recaptcha_get_html(App::getParam('sPublicKey')); {/php}</td>
            </tr>
        </table>        
        {/if}
8) Next open the file: /include/modules/Account/classes/PhpFox_ComponentSignup.class.php

Look for:
PHP:
if ($bIsProtImage && !$oSrvSec->checkProtectionCode($oReq->get('sProtCode'))) 
Above that add:
PHP:
if (function_exists('recaptcha_check_answer'))
{
    
$oResp recaptcha_check_answer(App::getParam('sPrivateKey'), $_SERVER["REMOTE_ADDR"], $oReq->get('recaptcha_challenge_field'), $oReq->get('recaptcha_response_field'));        
    if (!
$oResp->is_valid
    {        
        
$this->addErrors(App::format('Mod_Account.error.wrong_code'));
    }
9) Open the file: /design/templates/default/_modules/Site/ContactUs.html

Look for:
HTML:
<table style="width:100%;" cellpadding="4" class="border2">
            <tr>
                <td style="width:35%; text-align:right; font-size:9pt; vertical-align:top;">{language text="verification_code"}:</td>
                <td style="font-size:9pt; vertical-align:top;">{captcha input='sProtCode'}</td>
            </tr>
            <tr>
                <td style="width:35%; text-align:right; font-size:9pt; vertical-align:top;">{language text='Mod_Account.enter_above_code_here'}: <span class="star">*</span></td>
                <td style="font-size:9pt; vertical-align:top;">
                    <input type="text" id="sProtCode" name="sProtCode" size="12" onfocus="this.className='inputmain';" onblur="this.className='';" />
                    <div style="font-size:8pt;"><i>({language text='Mod_Account.code_case_sensitive'})</i></div>
                </td>
            </tr>
        </table>
Replace with:
HTML:
{if function_exists('recaptcha_get_html')}
        <table style="width:100%;" cellpadding="4" class="border2">
            <tr>
                <td style="width:35%; text-align:right; font-size:9pt; vertical-align:top;">{language text="verification_code"}:</td>
                <td style="font-size:9pt; vertical-align:top;">{php} echo recaptcha_get_html(App::getParam('sPublicKey')); {/php}</td>
            </tr>
        </table>        
        {/if}
10) Open the file: /include/modules/Site/classes/PhpFox_ComponentContactUs.class.php

Look for:
PHP:
if (!$oSrvSec->checkProtectionCode($oReq->get('sProtCode')))
{
        
$this->addErrors(App::format('Mod_Account.error.wrong_code'));
Replace with:
PHP:
if (function_exists('recaptcha_check_answer'))
{
    
$oResp recaptcha_check_answer(App::getParam('sPrivateKey'), $_SERVER["REMOTE_ADDR"], $oReq->get('recaptcha_challenge_field'), $oReq->get('recaptcha_response_field'));        
    if (!
$oResp->is_valid
    {        
        
$this->addErrors(App::format('Mod_Account.error.wrong_code'));
    }
Thats all. Run into any problems let me know.


Attached Files

Reviews
utomo wrote at March 28, 2012, 1:16 am

It will be great if this included as default options.
we need to fight spam. and this can reduce our jobs to clean the spam. and use our time better

utomo