reCaptcha for submit – Pligg 1.0

The Pligg CMS comes with many great components, SPAM protection isn’t one of them.  As with previous versions, Pligg developers have decided SPAM protection isn’t important.  Fellow members have come up with great solutions including our submit anti-spam solution but they ignored it.We released a way to prevent spam subissions by robots in version 9.9.5 that has worked magically for owners of the 9.9.5 version.

The modules works pretty well the same for version 1.0, why haven’t the developers adopted this method?  Who knows.

Here is how to do it for you 1.0 owners:

Step 1: open submit_step_1.tpl

Find:

<h2>{#PLIGG_Visual_Submit1_NewsSource#}</h2>
        <form action="{$URL_submit}" method="post" id="thisform">
                <label for="url">{#PLIGG_Visual_Submit1_NewsURL#}:</label>
                <input type="text" name="url" id="url" value="http://" size="55" />
               
                {checkActionsTpl location="tpl_pligg_submit_step1_end"}
               
                <input type="hidden" name="phase" value=1/>
                <input type="hidden" name="randkey" value="{$submit_rand}"/>
                <input type="hidden" name="id" value="c_1"/>
</form>

After, 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 = "6LcgbAIAAAAAAI9nYv__8BgVklHK71UijWSTbIP4 ";
        $privatekey = "6LcgbAIAAAAAAMUqdB3ROC19UhxV6KcAgh34Gtq_";

        # 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.

If you enjoyed this post, make sure you subscribe to my RSS feed!

  • SEO
    If wouldn't be nice if this site is located at the e recaptha , spammer fill here.
  • I'll install recaptcha on my blog. Thanks for information.
  • reCaptcha is really good for spam protection.
  • hey thanks for the updated info dear....i was really very thankful to you for the great info...
  • Do you share a very useful article. learned thanks to you
  • raghhav
    its ending up in blank page.
  • spicybookmarking
    Hello, I m getting this error.

    Fatal error: TPL: [in wistie/submit_step_1.tpl line 32]: syntax error: /php function does not exist (class.compiler.php, line 485) in /home/spicyboo/public_html/class.template.php on line 923

    can you please help me with this. thanks.
  • hey thanks for the updated info dear....i was really very thankful to you for the great info...
  • Thanks for this, very helpful for our blogs.
    .-= gurgle´s last blog ..Cervical Smear Tests =-.
  • Very nice way of protection against spammers. Thanks for sharing such nice info.
blog comments powered by Disqus