RECAPTCHA for submit

Register an Account
Pligg Chat Room
Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008, 09:10 PM
fhelik's Avatar
New Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 26
Ok these are the steps to get the Recaptcha in the submission page, so every user has to fill the captcha in order to continue with the submission. /

You will end up with something like this: (check the attachment)

(Before start you will need a Recaptcha keys, to get them go to recaptcha register and get the key, also download the recaptchalib.php from the same site and save it in your pligg base folder)

(Before we start make sure the User Registration Captcha is "true" under the admin, configuration, Captcha)

Step 1: open submit_step_2.tpl

Look for this:


HTML Code:
 <input type="submit" value="{#PLIGG_Visual_Submit2_Continue#}" class="submit" />		
		<input type="hidden" name="url" id="url" value="{$submit_url}" />
		<input type="hidden" name="phase" value="2" />
		<input type="hidden" name="randkey" value="{$randkey}" />
		<input type="hidden" name="id" value="{$submit_id}" /> 
Right before that insert this( remember to change YOURPUBLICKEY for yours):

Code:
         {php} 		
			require_once('recaptchalib.php');
			$publickey = "YOURPUBLICKEY"; // you got this from the signup page
			echo recaptcha_get_html($publickey);
		{/php}
Now open submit.php

look for this:

PHP Code:
check_actions('do_submit1');
    
$main_smarty->display($the_template '/pligg.tpl');
}

// submit step 2 
right after insert this (remember to change YOUR PUBLIC AND SECRET):

PHP Code:
//captcha
if(enable_captcha == 'true') {
            
        require_once(
'recaptchalib.php');        
        
// Get a key from http://recaptcha.net/api/getkey
        
$publickey "YOURPUBLICKEY";
        
$privatekey "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 '/register_error.tpl');
            return;
        }
        
// fin capthca 
a little below look for this:

PHP Code:
}

// submit step 3 
and replace it with this: ( I just added one more } )

PHP Code:
}}

// submit step 3 
Before start make backup of these 2 files, in case you make a mistake.
I made this from a code I found there in pligg, plus the resources of Recaptcha.net and recaptcha group.

I hope this helps, and work, please leave a comment after installation.

I don't know what people are doing wrong, but for those here are the files. remember to do the backup of the 3 files before replace. NOTE i am using yget template on indipop.net

check the attachment for the files.

ok I hope it works for you guys. please post here if success
Attached Thumbnails
RECAPTCHA for submit-recaptcha.gif  
Attached Files
File Type: zip recaptcha-for-submit.zip (8.5 KB, 151 views)

Last edited by fhelik; 01-09-2008 at 06:41 PM. Reason: new files
  #2 (permalink)  
Old 01-08-2008, 09:14 PM
gen3ric's Avatar
Casual Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 94
Awesome! Going to give it a shot right now...
  #3 (permalink)  
Old 01-08-2008, 09:23 PM
gen3ric's Avatar
Casual Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 94
Hmmm, I get a blank page after the captcha is entered and I hit submit. Could there be a syntax error?
  #4 (permalink)  
Old 01-08-2008, 09:42 PM
fhelik's Avatar
New Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 26
Quote:
Originally Posted by gen3ric View Post
Hmmm, I get a blank page after the captcha is entered and I hit submit. Could there be a syntax error?
make sure you have the reCAPTCHA Library, put it in the pligg base folder. (if the gaptcha appears, maybe is not this)

check that you have /register_error.tpl in your template folder

try this:
go to admin language find this: "PLIGG_Visual_Register_Error_BadCode", make sure is some text there.
1: submit 1 story and fill the gaptcha correct. It should go to next step.
2: submit 1 story and fill the captcha wrong. it have to show the error

NOTE: I use yget template. look in indipop.net, it is working fine. both for registration and submit.
  #5 (permalink)  
Old 01-09-2008, 10:03 AM
micxuy's Avatar
Casual Pligger
 
Join Date: May 2007
Posts: 87
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
  #6 (permalink)  
Old 01-09-2008, 06:42 PM
fhelik's Avatar
New Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 26
Quote:
Originally Posted by micxuy View Post
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
check the post I just upload my files, make backup and replace, i hope this works.
  #7 (permalink)  
Old 01-10-2008, 01:16 AM
micxuy's Avatar
Casual Pligger
 
Join Date: May 2007
Posts: 87
Hello; I haven tried it out but just my thought, we should put the captcha at the submit step 3. It is much better, because my user go back to change something, he has to enter the captcha again. Meanwhile at step 3, you onyl need to enter once.

Thanks
  #8 (permalink)  
Old 01-10-2008, 04:30 PM
Casual Pligger
Pligg Version: 9.8.2
Pligg Template: none
 
Join Date: Dec 2007
Posts: 33
Quote:
Originally Posted by micxuy View Post
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
I'm reveiving the same, but I think placement would make more sense in submit 3.
  #9 (permalink)  
Old 01-18-2008, 02:00 AM
Pligg Donor
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 3
So I see why you would want reCaptcha for adding new stories but what about the first step which is when they register? Wouldn't that alleviate the problem of spam bots creating accounts?
  #10 (permalink)  
Old 01-18-2008, 03:53 AM
Pligg Donor
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 3
Quote:
Originally Posted by MarekSpace View Post
So I see why you would want reCaptcha for adding new stories but what about the first step which is when they register? Wouldn't that alleviate the problem of spam bots creating accounts?
This works for me.

1) In register_center.tpl add this:

{if isset($form_captcha_error)}{ foreach value=error from=$form_captcha_error }<br /><span class="error">{$error}</span><br />{ /foreach }<br />{/if}

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

BEFORE THIS

<input type="submit" name="submit" value="{#PLIGG_Visual_Register_Create_User#}" class="log2" tabindex="36" />

2) In register.php add this:

require_once('recaptchalib.php');
$privatekey = "...";

$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) { // if both captchas don't match
$error = true;
}


BEFORE THIS

$vars = array('username' => $username);
check_actions('register_check_errors', $vars);

AND THIS

$main_smarty->assign('form_captcha_error', 'The reCAPTCHA code you entered was incorrect.');

AFTER THIS

$main_smarty->assign('form_password_error', $form_password_error);
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pligg 1.0 Recaptcha on Step2 msmanikandan Questions and Comments 1 07-14-2009 10:53 AM
RecaptchA CONFIGURED reklama Questions and Comments 4 11-15-2008 02:26 PM
[Mod] Dodging SPAM with recaptcha ednet Questions and Comments 22 08-09-2008 02:48 PM
[mod request] (re)captcha for ajax contact form? Rodney Questions and Comments 3 03-30-2008 02:00 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development