reCaptcha for submit – Pligg v9.9.5

Posted In Modules - By Geoserv On Thursday, December 11th, 2008 With 56 Comments

One of the most sought after modules for Pligg is adding reCaptcha for story submissions.

Pligg member fhelik came up with the solution by adding reCaptcha on step 2, this however isn’t the ideal place for it to be, the reason being, most of your spam is being submitted by a bot.  Once the bot registers an account, it then attempts to submit a submission, once it hits step 2, it will be blocked because of the reCaptcha, but what you are left with is an incomplete story submission that will show up in your “Upcoming” section.

Using fhelik, I simply modified it and added it to step 1, this way if it’s a bot doing the story submission, it won’t make it past submitting a URL, and it will prevent incomplete submissions from littering my “Upcoming” pages.

Backup each file before installing this module

I have this installed on Pligg v9.9.5, a demo can be seen at FAQ PAL.

Step 1: open submit_step_1.tpl

Find:

{if $Submit_Require_A_URL neq 1}{#PLIGG_Visual_Submit_Editorial#}{/if}

before, add:

{php}
require_once(‘recaptchalib.php’);
$publickey = "PUBLICKEY"; // you got this from the signup page
echo recaptcha_get_html($publickey);
{/php}

Step 2: open submit.php

Find:

// submit step 1
function do_submit1() {
global $main_smarty, $db, $dblang, $current_user, $the_template;

after, add:

//captcha
if(enable_captcha == ‘true’) {

        require_once(‘recaptchalib.php’);
        // Get a key from http://recaptcha.net/api/getkey
        $publickey = "ENTER YOURPUBLICKEY";
        $privatekey = "ENTER YOURPRIVATE";

        # the response from reCAPTCHA
        $resp = null;
        # the error code from reCAPTCHA, if any
        $error = null;

        # was there a reCAPTCHA response?
        if ($_POST["recaptcha_response_field"]) {
                $resp = recaptcha_check_answer ($privatekey,
                                                $_SERVER["REMOTE_ADDR"],
                                                $_POST["recaptcha_challenge_field"],
                                                $_POST["recaptcha_response_field"]);

                if ($resp->is_valid) {
                        echo "Succesfully verified that you are human.";
                } else {
                        # set the error code so that we can display it
                        $error = $resp->error;

                }
        }    

        if (!$resp->is_valid) { // if incorrect captcha code was entered
            $main_smarty->assign(‘register_error_text’, "badcode");
            $main_smarty->display($the_template . ‘/submit_errors.tpl’);
            return;
        }
        // fin capthca

Find:

}

// submit step 2
function do_submit2() {

Replace, with:

}}

// submit step 2
function do_submit2() {

Download the latest reCaptcha library from here and upload to your “root”. 

You will also need reCaptcha keys for your site, you will need to register and add your site to reCaptcha.  Register here.

In the above snippets, retype all instances of the single apostraphe ( ‘ ) as they are not appearing properly here. In the download they will appear properly however.

If the user/bot fails to enter the correct reCaptcha code, they will be forwarded to your error page controlled by submit_errors.tpl, I have not come with a custom error message for this, maybe someone can submit one.

This should eliminate almost all spam submissions.

  ReCaptcha for Submit (8.0 KiB, 390 hits)

Error page:

If the user enters the wrong reCaptcha code, heres a sample error page complete with error message and back button.

Download the file below and upload it to templates/yget .

  Captcha Error (370 bytes, 291 hits)

Go to submit.php and change:

       if (!$resp->is_valid) { // if incorrect captcha code was entered
            $main_smarty->assign(’register_error_text’, "badcode");
            $main_smarty->display($the_template . ‘/submit_errors.tpl’);
            return;
        }
        // fin capthca

to,

       if (!$resp->is_valid) { // if incorrect captcha code was entered
                $main_smarty->assign(‘submit_error’, ‘badcode’);
                $main_smarty->assign(‘tpl_center’, $the_template . ‘/captcha’);
                $main_smarty->display($the_template . ‘/pligg.tpl’);
                return;
        }
        // fin capthca

Again, you can test this on FAQPAL

Related Search:

  • pligg modules nulled
  • continue inurl:/submit html
  • closed inurl:/submit php
  • inurl:/register php attempting
  • inurl:/register php else
  • transmission inurl:/submit html
  • exists inurl:/submit html
  • challenges inurl:/submit html
  • romantic inurl:/submit html
  • add recaptcha on pligg

About - Geoserv has been working with the Pligg CMS for 2+ years.

  • http://www.erotikgiyim.com sexshop

    First issue has been solved. now I have another issue, I got blank page after click ubmit buton.
    Please help in solving this error

  • http://www.erotikderginiz.com seks market

    First issue has been solved. now I have another issue, I got blank page after click umit buton.
    Please help in solving this error

  • http://www.agorshop.com/ şişme bebek

    First issue has been solved. now I have another issue, I got blank page after click ubmit button. ;)

  • http://www.agorshop.com/ şişme bebek

    First issue has been solved. now I have another issue, I got blank page after click ubmit button. ;)

  • http://www.turkeytourmarket.com/ istanbul tour

    First issue has been solved. now I have another issue, I got blank page after click ubmit button. ;)

  • http://www.komododragonfacts.com Komodo Dragon

    reCaptcha is very effective, for sure. Thanks for explaining this.